home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
pocketbk
/
utilsr
/
scbank23
/
src
/
makehelp
< prev
next >
Wrap
Text File
|
1994-12-21
|
3KB
|
171 lines
titlelength=0
headers=0
for dummy in `echo "for(i=1;i<=2;i++)i" | bc`
do
#Find all menu numbers
for menu in `cat $1 | nawk '/^\+[0-9][0-9]/ {printf("%s\n",substr($0,2,2))}'`
do
cat $1 | nawk -F, '
{
for (i=1; i<=NF; i++)
{
if ($i=="*" thismenu)
many++
}
}
{ if (substr($0,1,3)=="+" thismenu)
{
for (i=1; i<=NF; i++)
{
if ((substr($i,1,1)!="+")&&(substr($i,1,1)!="*"))
{
outstr=""
for (j=i; j<=NF; j++)
{
if (j!=NF)
{
outstr=outstr $j ", "
}
else
{
outstr=outstr $j
}
}
next
}
}
}
}
END {
printf("%s,%s,%s\n","#" thismenu,many,outstr)
}' thismenu=$menu
cat $1 | nawk -F, '
BEGIN {
reduce=0
}
{
if (substr($0,1,1)=="+")
{
reduce++
header=1
thisheader=$1
}
else
{
header=0
}
for (i=1; i<=NF; i++)
{
if ($i=="*" thismenu)
{
for (j=i; j<=NF; j++)
{
if ((substr($j,1,1)!="+")&&(substr($j,1,1)!="*"))
{
outstr=""
for (k=j; k<=NF; k++)
{
if (k!=NF)
{
outstr=outstr $k ", "
}
else
{
outstr=outstr $k
}
}
if (header==0)
{
printf("%s,%s\n",NR+titlelength-reduce,outstr)
}
else
{
printf("%s,%s\n",thisheader,outstr)
}
next
}
}
}
}
}
' thismenu=$menu headers=$headers titlelength=$titlelength
done > /tmp/menu_headers
titlelength=`wc -l /tmp/menu_headers | awk '{print $1}'`
done
#Fix submenus
for menu in `cat $1 | nawk '/^\+[0-9][0-9]/ {printf("%s\n",substr($0,2,2))}'`
do
row=`cat /tmp/menu_headers | nawk -F, '
{
if ($1=="#" thismenu)
{
print NR
}
}' thismenu=$menu`
cat /tmp/menu_headers | nawk -F, '
{
if ($1=="#" thismenu)
{
printf("%s\n",substr($0,5,length($0)-4))
}
else if ($1=="+" thismenu)
{
printf("%s,%s\n",where,substr($0,5,length($0)-4))
}
else
{
print $0
}
}' thismenu=$menu where=$row > /tmp/menu_headers1
cp /tmp/menu_headers1 /tmp/menu_headers
done
#lose line with titiles
cat $1 | grep -v '^\+' > /tmp/titleless
cat /tmp/titleless | nawk 'BEGIN {
i=0
first=0
}
/^\*/ {
if (first!=0)
{
doit()
i=0
}
title=$0
first=1
}
!/^\*/{
if (first!=0)
{
aline[i]=$0
i++
}
}
END {
doit()
}
function doit()
{
last=1
do
{
pos=index(substr(title,last,length(title)-last),",")
last=last+pos
} while (substr(title,last,1)=="*")
printf("%d,%s\n",i,substr(title,last,length(title)-last+1))
for (k=0; k<i; k++)
{
printf("-1,%s\n",aline[k])
}
}' > /tmp/menutext
cat /tmp/menu_headers /tmp/menutext