100 extend 110 & ! HLPFMT.BAC & & ! Program to format the BBS:HELP.BAC & ! data base file. & & ! By John Wilson, 22-Sep-85. & ! 120 dim stack%(10%,2%) & \ open '[10,9]help.hlp' for input as file 1% & \ open 'bbs:help.ndx<40>' as file 2% & \ dim #2%, index%(150%) & \ open 'bbs:help.dat<40>' as file 3% & \ blk%,offset%=1% & \ ptr%=0% & \ sp%=11% & \ gosub 130 & \ goto 32767 130 ! start a new topic record & index%(ptr%)=blk% & \ index%(ptr%+1%)=offset% & \ lngth%=0% 140 input line #1%, l$ & \ goto 150 if l$='>$<'+chr$(13%)+chr$(10%) & \ lngth%=lngth%+len(l$) & \ gosub 1000 & \ goto 140 150 index%(ptr%+2%)=lngth% & \ input #1%, no% & \ index%(ptr%+3%)=no% & \ ptr%=ptr%+4% & \ return unless no% & \ for i%=1% to no% & \ input #1%, l$ & \ index%(ptr%+2*(i%-1%))=len(l$) & \ gosub 1000 & \ next i% & \ sp%=sp%-1% & \ stack%(sp%,0%)=ptr% & \ stack%(sp%,1%)=no% & \ stack%(sp%,2%)=0% & \ ptr%=ptr%+2%*no% 160 index%(stack%(sp%,0%)+2*stack%(sp%,2%)+1%)=ptr% & \ gosub 130 & \ i%=stack%(sp%,1%)-1% & \ goto 170 unless i% & \ stack%(sp%,1%)=i% & \ stack%(sp%,2%)=stack%(sp%,2%)+1% & \ goto 160 170 sp%=sp%+1% & \ return 500 & ! HELP.HLP file format: & & ! spiel, ending with a line containing only '>$<' & ! number of subtopics & ! list of subtopics, one per line & ! recurse for each subtopic & ! 600 & ! HELP.NDX file format: & ! topic record: & ! word & ! 0 block number of spiel & ! 1 offset in block of spiel & ! 2 length of spiel & ! 3 number of subtopics & ! subtopic entry: & ! 0 length of name (name follows spiel) & ! 1 pointer to topic record & ! 1000 & ! routine to write a record to the output file & ! record in l$; blk% and offset% are updated & & & #3%, l$; & \ offset%=offset%+len(l$) & \ while offset%>512% & \ blk%=blk%+1% & \ offset%=offset%-512% & \ next & \ return 32767 end