TITLE HELP for printing online help information SUBTTL Charles E. Boyd -- University of New Orleans SEARCH UUOSYM, MACTEN, SCNMAC .REQUEST REL:SCAN .REQUEST REL:WILD .REQUEST REL:HELPER TWOSEG 400000 ENTRY .HELP,.IHELP SALL COMMENT # Modifications 0 July 10, 1983 Version One completed 1 If .IHELP failed to set up correctly, don't allow a HELP command to exist either. 2 If program that create the help file was not MAKHLP then flag as an error. COMMENT # COMMENT #**************************************************************** * * * MOVEI T1,address of asciz string containing help file name * * PUSHJ P,.IHELP * * error * * * * .IHELP initializes the online help facility and must be called * * before attempt to call the .HELP command but after .SCAN has been * * initialized. Call scan to parse the input file, open it and read * * the 4 block pointer into an area called DB for safe keeping. Since * * this is a direct access file make sure that only one buffer is set. * * * COMMENT ****************************************************************# .IHELP::HRLI T1,(POINT 7,) ;Make a pointer our of address MOVEM T1,DADDR# ;Store file spec address MOVEI T1,[ILDB C,DADDR# ;This code will SKIPG C ;read in character HRREI C,.CHEOL ;from string pointed POPJ P,] ;to by DADDR PUSHJ P,.TYPRE## ;Make scan use it awhile PUSH P,T1 ;Save what scan was using PUSHJ P,.PSCAN## ;Reset input buffer (just in case) PUSHJ P,.FILIN## ;Parse the file spec JUMPGE T1,IHLP1 ;Nothing there then error return MOVEI T1,HLPSPC ;Address to store file spec MOVEI T2,.FXLEN ;Length of above area PUSHJ P,.GTSPC## ;Copy the file block to a safer spot MOVEI T1,HLPSPC ;Get address of this spot MOVEI T2,HLPOPN ;Get address of an open block MOVEI T3,HLPLKP ;Get address of a lookup block PUSHJ P,.STOPN## ;Convert the scan block to open/lookup blocks JRST IHLP1 ;Couldn't then error OPEN CH17,HLPOPN ;Open the channel JRST IHLP1 ; LOOKUP CH17,HLPLKP ;Lookup the file JRST IHLP1 ; MOVE T1,HLPLKP+.RBSPL ;[2]Get spool name CAME T1,[SIXBIT/MAKHLP/] ;[2]Did right program create it JRST IHLP1 ;[2]I guess not INBUF CH17,1 ;Set up only one buffer SETSTS CH17,.IODMP ;Need dump mode a while IN CH17,[EXP -1000B17!DB-1,0] SKIPA JRST IHLP1 ;Couldn't then error SETSTS CH17,.IOASL ;Back to ascii mode now POP P,T1 ;Get scan's original input routine back PUSHJ P,.TYPRE## ;Give it back to scan SETOM HLPON# ;[1]Flag that help successfully set up PJRST .POPJ1## ;Leave good IHLP1: POP P,T1 ;Get original input routine back SETZM HLPON# ;[1]Flag that .IHELP failed PJRST .TYPRE## ;Give it to scan and let him leave COMMENT #**************************************************************** * * * .HELP reads keywords from the command line and searches the pointer * * table set up with .IHELP and if a match is found prints out the text * * associated with that keyword. If more than one keyword is found * * following the word HELP on the command line the remaining words will * * be considered sub-topics of each other and the search will go down * * to the last sub-topic level to find the help information. As each * * sub topic category is found that topic name is printed one the tty * * so that if the search fails you know how deep the search went before * * it failed. * * * * REGISTER Usage: * * * * P1 - current search depth * * P2 - current pointer address * * P3 - byte & block count after a successful find * * P4 - address of keyword name block * * * * CALLING Sequence: * * * * (input help command line to scan) * * PUSHJ P,.HELP * * error * * * COMMENT ****************************************************************# .HELP:: SKIPN HLPON# ;[1]Was help set up ok? POPJ P, ;[1]No help available PUSHJ P,.SAVE2## ;Save the P registers MOVE T1,[2,,T2] ;[3]Get CRLF setting MOVEI T2,.TONFC ;[3]... MOVSI T3,(SIXBIT/TTY/);[3]... IONDX. T3, ;[3]... JFCL ;[3]... TRMOP. T1, ;[3]... JFCL ;[3]... PUSH P,T1 ;[3]Save it PUSH P,T3 ;[3]Save udx MOVE T1,[3,,T2] ;[3]Do a SET TTY CRLF MOVEI T2,.TOSET+.TONFC;[3]... SETZ T4, ;[3]... TRMOP. T1, ;[3]... JFCL ;[3]... SETZB P1,N ;Both keyword and level are empty MOVEI P2,DB ;Initialize pointer address MOVEI P3,5 ;Point to main help text MOVEI P4,NMLST ;Get address of name list SETZM CNT MOVE T1,[CNT,,NMLST] ;Set up to clear out name list BLT T1,NMLST+27 ;and do it MOVEM P2,NMLST+2 ;Initially point to first DB address HLP0: SKIPG C ;Any thing following HELP? JRST HLP1 ;Nope use the main message PUSHJ P,.NAMEW## ;Get a new keyword JUMPE N,HLP1 ;If no more go find current message location MOVEM N,(P4) ;Store name in name list MOVE T1,.LASWD##+1 ;Get name's mask MOVEM T1,1(P4) ;Store it in the name list ADDI P4,3 ;Skip to next name location JRST HLP0 ;Get the next name HLP1: MOVEI P4,NMLST ;Point to start of keyword list HLP1A: SKIPN (P4) ;If at the end of the list JRST HLP2 ;go set up to print message SOS P1 ;Increase depth counter HLP1B: PUSHJ P,FNDPTR ;Try to find the current keyword JUMPE P3,HLP3 ;No match maybe time to quit ADDI P4,3 ;Increment name table address JRST HLP1A ;Found go try for the next level HLP2: PUSHJ P,FNDPOS ;Find message location in the file PUSHJ P,.TCRLF## ; HLP2A: PUSHJ P,SIN ;Read a character JUMPLE C,HLP2B ;On end-of-message finish up MOVEI T1,(C) ;Type message characters PUSHJ P,.TCHAR## ;... JRST HLP2A ;Go get next character HLP2B: PUSHJ P,ADDHLP ;See if addition help is available PUSHJ P,.TCRLF## ; SUBI p4,3 ; AOS CNT ;Increment message count JUMPN P1,HLP1B ;If not at level one keep looking JRST HLP3A ;[3]... ;[3] PJRST .POPJ1## ;else must be finished HLP3: SUBI P4,3 ;Skip to previous name AOJL P1,HLP1B ;If not at top keep trying SKIPE CNT ;If something was printed HLP3A: AOS -2(P) ;Alls ok POP P,T3 ;[3]Get UDX POP P,T4 ;[3]Get CRLF original setting MOVE T1,[3,,T2] ;[3]Reset CRLF setting MOVEI T2,.TOSET+.TONFC;[3]... TRMOP. T1, ;[3]... JFCL ;[3]... POPJ P, ; COMMENT #**************************************************************** * * * This routines reads one character from the input file and returns * * it in register C. Any I/O error will just set the end-of-file flag. * * * COMMENT ****************************************************************# SIN:: SOSL IBCB+2 ;Characters still left in buffer? JRST SIN1 ;Yep IN CH17, ;Nope try to get another buffer JRST SIN ;No do the work SKIPA C,[.CHEOF] ;Bad so set the eof flag SIN1: ILDB C,IBCB+1 ;Get the character POPJ P, ;Leave FNDPTR: SETZ P3, ;Clear byte/blk pointer MOVE T3,(P4) ;Get current keyword AND T3,1(P4) ;Clear out the wild-card stuff PUSHJ P,.MKMSK## ;Make a mask of what's left in T1 MOVE P2,2(P4) ;Get where this keyword left off FND1: CAMN P1,(P2) ;Right level? JRST FND3 ;Yep test for a match CAMGE P1,(P2) ;Gone too far? POPJ P, ;Leave FND2: ADDI P2,3 ;Skip to the next DB pointer JRST FND1 ;and try again FND3: MOVE T3,(P4) ;Get the command keyword AND T3,1(P4) ;Mask out the wild card stuff MOVE T2,1(P2) ;Get the pointer name AND T2,1(P4) ;And out the wild card stuff CAMN T3,T2 ;A match? JRST FND4 ;Yep save data stuff AND T2,T1 ;Trunc the pointer name CAMN T3,T2 ;Partial match? SKIPE P3 ;Yes but is it the first? JRST FND2 ;Nope keep going MOVE P3,2(P2) ;Get byte/blk from pointer list ADDI P2,3 ;SKip to next item at this level MOVEM P2,2(P4) ;Remember where we are for next time MOVEM P2,5(P4) ;Remember also for next guy JRST FND1 ;Try again FND4: MOVE P3,2(P2) ;Get byte/blk pointer ADDI P2,3 ;SKip to next item at this level MOVEM P2,2(P4) ;Remember where we are for next time MOVEM P2,5(P4) ;Remember also for next guy PJRST .POPJ1## ;Finished COMMENT #**************************************************************** * * * FNDPOS locates the input pointer to the block and byte that contains * * the desired message. All byte locations start on a word boundary so * * all that needs to be done once a USETI has found the desired block * * is to divide the byte count by five and add that to the byte pointer * * address, then adjust the input byte count. * * * * CALLING Sequence: * * * * MOVE P3,[XWD byte,block] * * PUSHJ P,FNDPOS * * return * * * COMMENT ****************************************************************# FNDPOS::USETI CH17,(P3) ;Position to the right input block IN CH17, ;and read it into the buffer SKIPA ;Should work POPJ P, ; HLRZS P3 ;Get the byte count SUBM P3,IBCB+2 ;Substract from buffer count MOVNS IBCB+2 ;Make it positive PUSH P,P4 ;Save because of divide IDIVI P3,5 ;Convert to words POP P,P4 ; ADDM P3,IBCB+1 ;Increment byte pointer address POPJ P, ;all set COMMENT #**************************************************************** * * * ADDHLP prints out the list of additional sub-topics for which help * * is available under the given topic if any. * * * COMMENT ****************************************************************# ADDHLP: MOVE P2,2(P4) ;Get DB location SOS P1 ;Increment to the next sub-topic level ADD1: CAMN P1,(P2) ;At the right level? JRST ADD2 ;Yep go print the topic name CAMG P1,(P2) ;Deeper? AOJA P1,.POPJ## ;No, then finished ADDI P2,3 ;Skip to the next pointer JRST ADD1 ;Try again ADD2: MOVE T1,1(P2) ;Get keyword name PUSHJ P,.TSIXN## ;Type it PUSHJ P,.TTABC## ;Tab over ADDI P2,3 ;Increment to next pointer JRST ADD1 ;Try again RELOC 0 DB: BLOCK 1000 HLPSPC: BLOCK .FXLEN HLPOPN:EXP .IOASC,0,IBCB HLPLKP: EXP .RBAUT BLOCK .RBAUT IBCB: BLOCK 3 CNT: BLOCK 1 NMLST: BLOCK 3*10 T1==1 T2==2 T3==3 T4==4 P1==5 P2==6 N==7 C==10 P3==11 P4==12 P==17 CH17==17 END