home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / test / pdp11 / krthlp.mac < prev    next >
Text File  |  1996-10-17  |  22KB  |  596 lines

  1.     .title  KRTHLP    HELP for Kermit-11
  2.     .ident    "V04.64"
  3.  
  4. ; /E64/    14-Apr-96  John Santos
  5. ;    For RSTS, call ctrl/o cancel function instead of inline RT call
  6. ;    Check for errors after calling fparse
  7.  
  8. ; /63/    29-Jan-96  Billy Youdelman
  9. ;
  10. ;    translate "_" to "-" which searching for topics
  11. ;    move index data to separate file KRTIDX.MAC solving a size problem
  12. ;    increase text line and terminal input buffers to 132. bytes
  13.  
  14. ; /62/    27-Jul-93  Billy Youdelman  V03.62
  15. ;
  16. ;    add dummy file name for HPRINT via RT-11 V5.2/TSX V6.0 LP/LS
  17. ;    display all subtopic text when wildcarding through nested text
  18.  
  19. ; /BBS/     1-Dec-91  Billy Youdelman  V03.61
  20. ;
  21. ;    kill extra LF after listing subtopics
  22. ;    hfind - fixed wildcarding when no subtopics exist for a topic
  23. ;    help text file updated to reflect mods/additions/omissions
  24. ;    hindex - display sped up, prompting after it now uses full text,
  25. ;    also handles topic names greater than 18 bytes ala VMS help
  26. ;    added fake RMS stuff for RT-11/TSX, and did a general cleanup..
  27. ;    path for KRTHLP.HLP is now HLP, KRT, SY and DK
  28. ;    modified to check for correct copy of KRTHLP.HLP
  29. ;    on topic error nest in as far as possible instead of from the top
  30. ;    added HPRINT, dumps help text to LP
  31.  
  32. ;    Copyright 1986 Brian Nelson
  33. ;
  34. ;    26-Mar-86  18:41:25
  35. ;
  36. ;    This is a complete rewrite of Kermit-11's help.  It is a bit more
  37. ;    intelligent, in that it understands wildcarding (HELP SET *), and
  38. ;    can build subtopic prompting strings and process accordingly.
  39.  
  40.  
  41. ;       Directions for rebuilding the RMS Index for KRTHLP.HLP
  42. ;
  43. ;    If the help text file must be edited, added to or changed, one
  44. ;    must then rebuild the index data table located in KRTIDX.MAC.
  45. ;    Doing this is quite easy - simply run KRTIDX.BAS which will
  46. ;    create a new KRTIDX.MAC for you.
  47. ;
  48. ;    KRTHLP.HLP help text file format info:
  49. ;
  50. ;    The very first line contains an ident string with which this program
  51. ;    can verify it has the correct file, as otherwise with the internal
  52. ;    indexing in use here it may seem to be broken for no apparent reason.
  53. ;    This ident string contains the program version and last edit date:
  54. ;
  55. ;    V03.63 23-Dec-94        (or whatever it may later become..)
  56. ;
  57. ;    Topic/subtopic lines must begin with a single ascii digit (ie: "1")
  58. ;    representing the nesting level in the first column, followed by a
  59. ;    space (ascii 40), followed by the topic/subtopic name.  The text
  60. ;    following is preceded by a blank (CR/LF only) line.  Each line of
  61. ;    the text must include a space (or lower value char, such as a tab
  62. ;    or return) in column one, which is used to distinguish text from
  63. ;    topics.  The text is followed by another blank line, just prior to
  64. ;    the next topic or subtopic line.  Wildcarded nesting is currently
  65. ;    supported through 5 levels, topic text length is 63. bytes and
  66. ;    aggregate (topic/subtopics) length must be 127. or less bytes.
  67. ;    The maximun length of a line of help text is 132. bytes, although
  68. ;    it's best to stay within 80 columns if at all possible.
  69.  
  70.  
  71.     .include "IN:KRTMAC.MAC"
  72.     .iif ndf  KRTINC  .error    <; .include for IN:KRTMAC.MAC failed>
  73.  
  74. .if df    RT11                ; /E64/
  75.     .mcall    .RCTRLO
  76. .endc    ;RT11                ; /E64/
  77.  
  78.     CVTARG    = C.CRLF ! C.LSPA ! C.SSPA ! C.LCUC ! C.TSPA ; arg processing
  79.  
  80.  
  81.     .sbttl    Local data
  82.  
  83.     .psect    $pdata
  84. sub.0:    .word    sub.2 ,sub.3 ,sub.4    ; /62/ for nested wildcarded headers
  85. rtname:    .word    10$ ,20$ ,30$ ,40$ ,0    ; /63/ this is the help file path
  86. 10$:    .asciz    "HLP:KRTHLP.HLP"    ; /BBS/ try here first
  87. 20$:    .asciz    "KRT:KRTHLP.HLP"    ; /BBS/ then here, etc..
  88. 30$:    .asciz    "SY:KRTHLP.HLP"
  89. 40$:    .asciz    "DK:KRTHLP.HLP"
  90. addinf:    .ascii    "    Additional information is available on:"<cr><lf> ; /63/
  91.  fill7:    .byte    cr ,lf ,40 ,40 ,40 ,40 ,40 ,40 ; /BBS/ a newline and 7 blanks
  92.  fill:    .byte    40 ,0            ; or just one blank, for formatting
  93. bugtxt:    .asciz    "Upgrades"        ; /62/ for the BUG command
  94. dbldash:.asciz    " --"            ; /BBS/ a space and a double dash..
  95. errhdr:    .asciz    "?KRTHLP-W-"        ; /63/
  96. errmis:    .asciz    "Can't find KRTHLP.HLP on HLP, KRT, SY or DK"<cr><lf>
  97. errver:    .asciz    " is an incorrect version"<cr><lf>
  98. hlp2lp:    .asciz    "LP:KRTHLP.OUT"        ; /62/ where HPRINT sends a file
  99. nohelp:    .asciz    "% Help not found for the requested topic"<cr><lf> ; /63/
  100. ptopic:    .asciz    " Select topic, please: " ; /BBS/ for prompting
  101.     .even
  102.  
  103.     .psect    $rwdata    ,rw,d,lcl,rel,con ; /BBS/
  104. backlev:.word    0            ; /BBS/ last good topic in case error
  105. backup:    .word    0            ; /BBS/ for nesting in on an error
  106. hlpbuf:    .blkb    134.            ; /63/ read/write buffer for the file
  107. htopic:    .blkb    200            ; the current topic
  108. idxdmp:    .word    0            ; index was dumped
  109. prbuff:    .blkb    200            ; prompting buffer
  110. prmptd:    .word    0            ; /62/ select subtopic prompt done
  111. rmsidx:    .word    0            ; /BBS/ current place in RMS index
  112. sub.2:    .blkb    100            ; /62/ fill in with sub topics
  113. sub.3:    .blkb    100            ; /62/ as required by how far in
  114. sub.4:    .blkb    100            ; /62/ nested wildcarding goes..
  115. subwild:.word    0            ; /62/ <> if 1st char of input is "*"
  116. topics:    .word    0 ,0 ,0 ,0 ,0 ,0 ,0 ,0    ; /BBS/ list of topic/subtopic addrs
  117. topbuf:    .blkb    200            ; (nested) topics buffer
  118. toplev:    .word    0            ; level of current topic
  119. ttbuff:    .blkb    134.            ; /63/ terminal read buffer
  120. wild:    .word    0            ; <> if topic wildcarded
  121.  
  122.  
  123.     .psect    $code
  124.     .sbttl    BUG, HPRINT
  125.  
  126. c$phlp::tst    outopn            ; /63/ come here to print it too..
  127.     beq    10$            ; output channel is available
  128.     mov    #er$lby    ,r0        ; chan is busy
  129.     br    20$            ; handle error
  130. 10$:    calls    create    ,<#hlp2lp,#lun.ou,#text> ; open chan to LP:
  131.     tst    r0            ; did it work?
  132.     bne    20$            ; /63/ no
  133.     mov    sp    ,outopn        ; flag output channel is open
  134.     mov    #lun.ou    ,xprint        ; enable print routine in ttyout stuff
  135.     br    c$help            ; /63/
  136. 20$:    direrr    r0            ; no, say why..
  137.     return
  138.  
  139. c$bug::    strcpy    argbuf    ,#bugtxt    ; /62/ do this for
  140.     .br    c$help            ; /63/ the "BUG" command
  141.  
  142.  
  143.     .sbttl    HELP main_loop
  144.  
  145. ;    (1)  Try to open help file, if it fails print an error message
  146. ;    (2)  Parse the command line, filling in the topics pointer array
  147. ;    (3)  Find and print (if found) the requested help topic+[subtopic(s)]
  148. ;    (4)  If not found, build a new command line from the topics pointer
  149. ;         array, prompt and concatenate the requested topic
  150. ;    (5)  Go back to (2)
  151. ;    (6)  When done, close help file
  152.  
  153. c$help::call    hlpopn            ; come here for just plain help..
  154.     tst    r0            ; locate and open the help file?
  155.     beq    30$            ; /BBS/ ya..
  156.     jmp    140$            ; /62/ no, error already displayed..
  157.  
  158. 30$:    upcase    argbuf            ; /BBS/ keep this out of the loop!
  159.     clr    prmptd            ; /62/ haven't asked for a subtopic
  160.     clr    subwild            ; /62/ first char of input isn't a "*"
  161.  
  162. 40$:    clr    idxdmp            ; index has not been dumped yet
  163.     clr    wild            ; clear the wildcarding flag
  164.     clr    topics            ; init [sub]topics pointers
  165.     clrb    prbuff            ; /BBS/ clear sub-level prompt buffer
  166.     call    loahlp            ; /63/ load HELP text index overlay
  167.     mov    r0    ,rmsidx        ; /63/ goto the top of the RMS list
  168.     mov    argbuf    ,r5        ; /BBS/ point to possible command args
  169.     tstb    @r5            ; anything there?
  170.     beq    80$            ; no, dump root index
  171.     call    parse            ; ya, set up pointers
  172.     call    hfind            ; now locate the desired text
  173.     tst    r0            ; find anything?
  174.     beq    50$            ; yes, let's go dump the text
  175.     dec    r0            ; ok, was it a code of 1 or 2?
  176.     beq    60$            ; 1, which means not found
  177.     mov    sp    ,wild        ; 2, found something wildcarded
  178. 50$:    call    hprint            ; dump the help text out now
  179.     br    90$            ; then continue
  180.  
  181. 60$:    wrtall    #nohelp            ; /63/ "Help not found for .."
  182.     mov    backup    ,rmsidx        ; /BBS/ here on a topic error?
  183.     beq    70$            ; /BBS/ nope..
  184.     mov    backlev    ,toplev        ; /BBS/ ya, recover topic level
  185.     clr    backup            ; /BBS/ don't come back here from here
  186.     clr    idxdmp            ; /BBS/ haven't dumped an index yet
  187.     clr    wild            ; /BBS/ in case nothing was there to *
  188.     br    50$            ; /BBS/ print nested in as far as can
  189. 70$:    clr    topics            ; re-init [sub]topics pointers
  190.     clrb    prbuff            ; /BBS/ clear sub-level prompt buffer
  191.     clrb    hlpbuf            ; /BBS/ init one more buffer
  192.     call    loahlp            ; /63/ load HELP text index overlay
  193.     mov    r0    ,rmsidx        ; /63/ goto the top of the RMS list
  194. 80$:    .newline
  195.     mov    #'1    ,-(sp)        ; flag to..
  196.     call    hindex            ; ..dump the top-level index out now
  197.  
  198. 90$:    tst    idxdmp            ; did we ever print [sub]topic list?
  199.     beq    140$            ; /62/ no, just exit
  200.     mov    #prbuff    ,r3        ; ya, build a prompt string
  201.     mov    argbuf    ,r4        ; in the argbuf
  202.     mov    #topics    ,r5        ; pointers to the parsed arguments
  203.     clrb    @r4            ; /BBS/ init argbuf keep prbuff intact
  204. 100$:    mov    (r5)+    ,r2        ; get next parsed argument
  205.     beq    110$            ; all done, exit
  206.     cmpb    (r2)    ,#'*        ; wildcard argument?
  207.     beq    150$            ; /BBS/ ya, done
  208.     strcat    r4    ,r2        ; /BBS/ no, add in previous [sub]topic
  209.     strcat    r4    ,#fill        ; /BBS/ and a delimiter
  210.     br    100$            ; do next arg
  211. 110$:    tstb    @r3            ; /BBS/ anything in prompt buffer?
  212.     beq    120$            ; /BBS/ nope..
  213.     strcat    r3    ,#dbldash    ; /BBS/ ya, add " --" to prompt string
  214. 120$:    strcat    r3    ,#ptopic    ; finish creating the prompt
  215.     clr    subwild            ; /62/ first char of input isn't a "*"
  216. .if df    RT11                ; /E64/
  217.     .rctrlo                ; /BBS/ be sure output is on
  218. .endc    ;RT11                ; /E64/
  219. .if df    RSTS                ; /E64/
  220.     call    ttrctl            ; /E64/ be sure output is on
  221. .endc    ;RSTS                ; /E64/
  222.     .newline
  223.     calls    readcmd    ,<#ttbuff,r3>    ; /BBS/ use SL editor
  224.     tst    r0            ; successful terminal read?
  225.     bne    150$            ; /BBS/ no, got to exit
  226.     calls    cvt$$    ,<#ttbuff,r1,#cvtarg> ; remove garbage, upper case
  227.     tst    r0            ; anything left?
  228.     beq    140$            ; /62/ no, exit please
  229.     clrb    ttbuff(r0)        ; ya, ensure .asciz
  230.     cmpb    ttbuff    ,#'*        ; /62/ is first byte an asterisk?
  231.     bne    130$            ; /62/ no
  232.     mov    sp    ,subwild    ; /62/ first char of input is a "*"
  233. 130$:    strcat    r4    ,#ttbuff    ; append the data just read please
  234.     mov    sp    ,prmptd        ; /62/ prompted for subtopic flag
  235.     jmp    40$            ; and parse the command all over again
  236.  
  237. 140$:    clr    r0            ; /62/ here if error already handled
  238. 150$:    save    <r0>            ; /62/ moved hlpclo here..
  239.     tst    outopn            ; is chan to LP open?
  240.     beq    160$            ; no
  241.     calls    close    ,<#lun.ou>    ; ya, close it
  242.     clr    outopn            ; say it's now closed
  243. 160$:    clr    xprint            ; turn off hprint
  244.     calls    close    ,<#lun.in>    ; close the help text file
  245.     clr    inopn            ; flag channel is now free
  246.     unsave    <r0>            ; /62/
  247.     return
  248.  
  249.  
  250.     .sbttl    Parse command line
  251.  
  252. ;    P A R S E
  253. ;
  254. ;    passed:      r5    = address of command args (minus "HELP"), .asciz
  255. ;    return:    topics    = addresses to each topic/subtopic
  256. ;              extra embedded spaces are removed
  257.  
  258. parse:    save    <r3,r4,r5>
  259.     mov    #topbuf    ,r4        ; where to copy the text
  260.     mov    #topics    ,r3        ; where to place the pointers to it
  261.     clr    @r3            ; assume nothing was passed
  262. 10$:    tstb    @r5            ; all done?
  263.     beq    50$            ; yes, exit this routine
  264.     cmpb    @r5    ,#space        ; while (*ch && *ch == space) ch++
  265.     bne    20$            ; not a space, go copy the data
  266.     inc    r5            ; a space found, check next one
  267.     br    10$            ; next
  268. 20$:    mov    r4    ,(r3)+        ; insert current address
  269.     clr    @r3            ; ensure next one is cleared out
  270. 30$:    tstb    @r5            ; all done with this line?
  271.     beq    40$            ; yes, exit
  272.     cmpb    @r5    ,#space        ; space delimiter found?
  273.     beq    40$            ; yes, setup for next one
  274.     movb    (r5)+    ,(r4)+        ; no, copy some data over
  275.     br    30$            ; next please
  276. 40$:    clrb    (r4)+            ; ensure .asciz please
  277.     br    10$            ; next subtopic
  278. 50$:    unsave    <r5,r4,r3>
  279.     return
  280.  
  281.  
  282.     .sbttl    Find the topic in the help file
  283.  
  284. ;    input:    topics    = list of addresses of text to match
  285. ;    return:     r0    = 0 if success
  286. ;            = 1 if not found
  287. ;            = 2 if match and wildcarded topic/subtopic
  288.  
  289. ; /BBS/    modified to scan an internal index and return pointer in rmsidx
  290. ;    to block and offset of beginning of desired text in KRTHLP.HLP
  291.  
  292. hfind:    save    <r2,r3,r4,r5>
  293.     mov    #topics    ,r5        ; point to the help topic list
  294.     mov    #'1    ,r2        ; current topic level
  295.     clrb    htopic            ; clear out header
  296.     call    loahlp            ; /63/ load HELP text index overlay
  297.     mov    r0    ,r4        ; /63/ pointer to fake RMS list
  298.  
  299. 10$:    tst    @r5            ; anything to look for?
  300.     beq    110$            ; no, just leave pointing at beginning
  301.     mov    @r4    ,r1        ; /BBS/ get address of ascii topic
  302.     beq    100$            ; /BBS/ end of list, return(1)
  303.     cmpb    @r1    ,r2        ; topic levels match up?
  304.     blo    100$            ; /BBS/ if gt then quit looking..
  305.     bne    70$            ; no, read another record then
  306.     inc    r1            ; /BBS/ skip over the level flag now
  307.     inc    r1            ; /BBS/ skip over space
  308.     mov    (r5)    ,r3        ; get pointer to text to match up
  309.     cmpb    (r3)    ,#'*        ; wildcarding?
  310.     beq    80$            ; yes, return(2)
  311.  
  312. 20$:    tstb    (r3)            ; found end of the desired topic?
  313.     beq    60$            ; ya, check next level topic needed
  314.     tstb    (r1)            ; /BBS/ end of the line yet?
  315.     beq    70$            ; yes
  316.     movb    (r1)+    ,r0        ; /BBS/ no, get next byte
  317.     cmpb    r0    ,#'a!40        ; is this a lower case letter?
  318.     blo    30$            ; nope
  319.     cmpb    r0    ,#'z!40        ; maybe, if a "z" or below
  320.     bhi    30$            ; no
  321.     bicb    #40    ,r0        ; ya, convert to upper case
  322. 30$:    cmpb    (r3)    ,#'_        ; /63/ did user type an underscore?
  323.     bne    40$            ; /63/ no
  324.     cmpb    r0    ,#'-        ; /63/ ya, looking for a dash?
  325.     beq    50$            ; /63/ ya, call it a match
  326. 40$:    cmpb    (r3)    ,r0        ; /63/ do the characters match up?
  327.     bne    70$            ; /63/ no, read another record
  328. 50$:    inc    r3            ; /63/ yes, keep checking them
  329.     br    20$            ; /63/
  330.  
  331. 60$:    mov    r2    ,backlev    ; /BBS/ save this before the bump
  332.     mov    r4    ,backup        ; /BBS/ save copy of RMS index
  333.     inc    r2            ; increment level # and read
  334.     tst    (r5)+            ; another record from the help file
  335.     mov    @r4    ,r1        ; /BBS/ recover pointer
  336.     inc    r1            ; /BBS/ bump past topic level number
  337.     strcat    #htopic    ,r1        ; /BBS/ build up a header record
  338.     clr    prmptd            ; /62/ do main topic when wildcarding
  339. 70$:    add    #6    ,r4        ; /BBS/ bump index to next entry
  340.     br    10$            ; then back for more
  341.  
  342. 80$:    tstb    htopic            ; /62/ if eq it's H * or HPRINT * so
  343.     beq    90$            ; /62/ there's no first topic to see
  344.     tst    prmptd            ; /62/ already displayed main topic?
  345.     bne    90$            ; /62/ ya
  346.     tst    subwild            ; /62/ don't dump the index if first
  347.     bne    90$            ; /62/ char of inout is a "*"
  348.     save    <r1>            ; /62/ no, stash this address..
  349.     mov    backup    ,rmsidx        ; /62/ prep to dump the main text
  350.     mov    backlev    ,toplev        ; /62/ for a wildcarded [sub]topic
  351.     clr    wild            ; /62/ but only that for the moment
  352.     call    hprint            ; /62/ display main topic text & index
  353.     .newline            ; /62/ format the display
  354.     mov    sp    ,wild        ; /62/ restore wildcarded status
  355.     unsave    <r1>            ; /62/ pop address of topic name
  356. 90$:    dec    r1            ; /BBS/ back up to include a blank
  357.     strcpy    #hlpbuf    ,r1        ; /62/ used to build first header
  358.     mov    r2    ,toplev        ; save the topic level
  359.     mov    #2    ,r0        ; /62/ match with wildcarding
  360.     br    120$            ; /62/ done
  361.  
  362. 100$:    call    loahlp            ; /63/ load HELP text index overlay
  363.     mov    r0    ,rmsidx        ; /63/ reset to top of file
  364.     mov    #1    ,r0        ; /63/ nothing found (reached EOF)
  365.     clr    @r5            ; /BBS/ zap pointer to ng [sub]topic
  366.     br    130$            ; bail out
  367. 110$:    mov    r2    ,toplev        ; save topic level
  368.     dec    toplev            ; it will be off by one
  369.     clr    r0            ; found the topic
  370.     sub    #6    ,r4        ; /BBS/ back up to last good one
  371. 120$:    mov    r4    ,rmsidx        ; /BBS/ save a copy of where it is now
  372.     clr    backup            ; /BBS/ clear nested error rmsidx buff
  373. 130$:    unsave    <r5,r4,r3,r2>
  374.     return
  375.  
  376.  
  377.     .sbttl    Print help text found by HFIND
  378.  
  379. ;    assumes:    both PARSE and HFIND have been called already
  380. ;    return:   r0    = if < failure, the RMS error code
  381. ;              if 0 success
  382. ;              if 1 found subtopics to print out
  383.  
  384. ; /BBS/    patched to support indexing for help text in KRTHLP.HLP
  385.  
  386. hprint:    save    <r2,r3,r4>
  387.     clrb    sub.2            ; /62/ init wildcarded
  388.     clrb    sub.3            ; /62/ sub topics
  389.     clrb    sub.4            ; /62/ nested names buffers
  390.     clr    r2            ; /62/ init index display control flag
  391.     strcpy    #ttbuff    ,#htopic    ; get the default header string made
  392.     strcpy    #prbuff    ,r0        ; /62/ copy for select topic prompt
  393.     mov    #hlpbuf    ,r4        ; /BBS/ point to the buffer now
  394.     tst    wild            ; /BBS/ coming in wild?
  395.     beq    10$            ; /BBS/ nope..
  396.     .newline            ; /BBS/ format display..
  397.     strcat    #ttbuff    ,r4        ; /62/ build up a header record for
  398.     wrtall    r0            ; /62/ the first topic and print it
  399.     .newline            ; /BBS/ and tag it with a newline
  400.     clrb    (r0)            ; /BBS/ clear ttbuff name out now
  401.  
  402. 10$:    call    preset            ; /BBS/ goto needed record in krthlp
  403.     bcc    30$            ; /62/ it worked
  404. 20$:    jmp    170$            ; /62/ it didn't work
  405.  
  406. 30$:    calls    getrec    ,<r4,#lun.in,#132.> ; /62/ read the next record
  407.     tst    r0            ; error?
  408.     bne    20$            ; /62/ yes, exit
  409.     clrb    hlpbuf(r1)        ; ensure it's .asciz please
  410.     cmpb    (r4)    ,#space        ; leading space or control char?
  411.     blos    110$            ; yes, a normal line to print
  412.     add    #6    ,rmsidx        ; /BBS/ keep RMS index pointer current
  413.     cmpb    (r4)    ,toplev        ; is this a lower, higher or same?
  414.     blo    160$            ; lower level, exit
  415.     beq    60$            ; same level
  416.     mov    rmsidx    ,r3        ; /62/ save to dump text after index
  417.     cmpb    (r4)    ,r2        ; /62/ done this particular index yet?
  418.     ble    50$            ; /62/ ya, once is enough
  419.     movb    (r4)    ,r0        ; /62/ copy of current nesting level
  420.     sub    #'0+2    ,r0        ; /62/ convert, "2"=0 "3"=1 "4"=2
  421.     blt    40$            ; /62/ this should never happen
  422.     asl    r0            ; /62/ word indexing
  423.     strcpy    sub.0(r0),#errtxt    ; /62/ stash a copy for making headers
  424.  
  425. 40$:    movb    (r4)    ,r0        ; /BBS/ keep the high byte clear while
  426.     mov    r0    ,-(sp)        ; /BBS/ passing the level number
  427.     call    hindex            ; and print out whats leftover
  428.     tst    wild            ; if not wildcarded
  429.     beq    150$            ; then exit
  430.     .newline            ; /BBS/ format wildcarded display
  431.  
  432. 50$:    mov    r3    ,rmsidx        ; /62/ now back up and do topics text
  433.     call    preset            ; /62/ load buff with 1st block of it
  434.     bcs    170$            ; /BBS/ it didn't work..
  435.  
  436. 60$:    tst    wild            ; same level, is it wildcarded?
  437.     beq    160$            ; no, we must exit
  438.     movb    (r4)    ,r0        ; /62/ copy of current nesting level
  439.     sub    #'0+1    ,r0        ; /62/ convert to an integer
  440.     blt    100$            ; /62/ not a topic line
  441.     beq    70$            ; /62/ level "1"  hose "2" and up..
  442.     dec    r0
  443.     beq    80$            ; /62/ level "2"  hose "3" and up..
  444.     dec    r0
  445.     beq    90$            ; /62/ level "3"  hose "4" and up..
  446.     br    100$            ; /62/ level "4"  could need them all
  447. 70$:    clrb    sub.2            ; /62/ clear nested subtopic names
  448. 80$:    clrb    sub.3            ; /62/ as determined (and required)
  449. 90$:    clrb    sub.4            ; /62/ by the current topic level
  450.  
  451. 100$:    movb    (r4)    ,r2        ; /62/ topic level for index control
  452.     clrb    (r4)            ; /62/ don't print this line
  453.     strcpy    #ttbuff    ,#htopic    ; build a header string up
  454.     strcat    r0    ,#sub.2        ; /62/ fill in as    else null in
  455.     strcat    r0    ,#sub.3        ; /62/ required by    first byte to
  456.     strcat    r0    ,#sub.4        ; /62/ nesting level    skip past ..
  457.     mov    @rmsidx    ,r1        ; /62/ copy for subtopic string build
  458.     inc    r1            ; /62/ skip past the leading number
  459.     strcat    r0    ,r1        ; copy over leading space & topic name
  460.     strcpy    #errtxt    ,r1        ; /62/ save a copy for nested headers
  461.  
  462. 110$:    tstb    ttbuff            ; do we need to print the next topic?
  463.     beq    130$            ; no
  464.     .newline            ; ya
  465.     wrtall    #ttbuff            ; dump it please
  466.     tst    wild            ; /BBS/ if a wildcard dump
  467.     bne    120$            ; /BBS/ don't do this newline
  468.     .newline
  469. 120$:    clrb    ttbuff            ; clear topic name out now
  470. 130$:    tstb    (r4)            ; if this is a null
  471.     beq    140$            ; don't print it
  472.     wrtall    r4            ; ok to print, dump the text now
  473. 140$:    .newline
  474.     jmp    30$            ; /62/ next please
  475.  
  476. 150$:    mov    #1    ,r0        ; return(sub_topic_found)
  477.     br    170$
  478. 160$:    clr    r0            ; return(success)
  479. 170$:    unsave    <r4,r3,r2>
  480.     return
  481.  
  482.  
  483.     .sbttl    Preset an I/O channel to an exact block and offset ; /BBS/
  484.  
  485. preset:    mov    rmsidx    ,r0        ; get copy of indexing pointer
  486.     calls    prewind    ,<#lun.in,2(r0),4(r0)>    ; load and preset buffer
  487.     return                ; 2(r0)=block 4(r0)=offset
  488.  
  489.  
  490.     .sbttl    Print index
  491.  
  492. ;    passed:     2(sp)    = sub-topic level at which index is expected
  493. ;    assumption:    HLPBUF is already loaded with the current record
  494. ;            and rmsidx is pointing to it
  495.  
  496. ; /63/    modified to use an internal index which lives in KRTIDX.MAC
  497.  
  498. hindex:    save    <r2,r4,r5>
  499.     mov    sp    ,idxdmp        ; flag that we have been here
  500.     clr    -(sp)            ; allocate
  501.     clr    -(sp)            ; some buffers
  502.     mov    sp    ,r5        ; and a pointer to them
  503.     movb    2+<5*2>(sp),2(r5)    ; /BBS/ get the passed topic level
  504.     cmpb    2(r5)    ,#'1        ; is this the main menu today?
  505.     bhi    10$            ; no, don't reposition the file
  506.     clrb    hlpbuf            ; flag nothing's there
  507. 10$:    wrtall    #addinf            ; /63/ "Additional information .."
  508.     mov    #4    ,(r5)        ; number of topic names per line
  509.     mov    rmsidx    ,r4        ; /BBS/ recover index into RMS data
  510.  
  511. 20$:    mov    @r4    ,r1        ; /BBS/ get pointer to next record
  512.     beq    90$            ; /BBS/ nothing left
  513.     cmpb    @r1    ,2(r5)        ; /BBS/ check topic level
  514.     bhi    80$            ; /BBS/ higher level, ignore it
  515.     blo    90$            ; /BBS/ lower level, we need to exit
  516.     ; /BBS/ this displays topic names longer than 18. bytes ala VMS help
  517.     inc    r1            ; skip the level number on the line
  518.     inc    r1            ; then skip the space next to it
  519. 30$:    strlen    r1            ; compute the padding to next column
  520.     mov    r0    ,r2        ; get copy of length
  521. 40$:    sub    #18.    ,r2        ; assume worst case 18. spaces needed
  522.     neg    r2            ; we now have the number of spaces
  523.     bgt    50$            ; that is, if it's a positive number
  524.     neg    r2            ; preset for looping into next column
  525.     dec    (r5)            ; is there a next column to overwrite?
  526.     bne    40$            ; yes, pad to end of it
  527.     wrtall    #fill7            ; init a newline to beginning column
  528.     mov    #4    ,(r5)        ; reset the counter now
  529.     br    30$            ; and start fresh again..
  530. 50$:    wrtall    r1            ; add on the current name
  531.     dec    (r5)            ; is there room left for the next one?
  532.     beq    70$            ; nope
  533.     mov    #space    ,r0        ; load a space
  534. 60$:    call    writ1ch            ; dump it to TT
  535.     sob    r2    ,60$        ; until padded to length of 18. bytes
  536.     br    80$            ; then back for more..
  537. 70$:    wrtall    #fill7            ; init a newline to beginning column
  538.     mov    #4    ,(r5)        ; reset the counter now
  539. 80$:    add    #6    ,r4        ; bump to next entry
  540.     br    20$            ; back for more
  541.  
  542. 90$:    cmp    #4    ,(r5)        ; is the current line blank?
  543.     beq    100$            ; ya, skip the extra blank line
  544.     .newline            ; no, do a newline
  545.     ; /BBS/ end of VMS-style hindex patch..
  546. 100$:    clr    r0            ; success
  547.     mov    r4    ,rmsidx        ; /BBS/ save current RMS index pointer
  548.     cmp    (sp)+    ,(sp)+        ; pop some local buffers...
  549.     unsave    <r5,r4,r2>
  550.     mov    (sp)+    ,(sp)        ; move return address up
  551.     return
  552.  
  553.  
  554.     .sbttl    Open the help file
  555.  
  556. ; /BBS/ modified to check for correct version of KRTHLP.HLP..
  557.  
  558. hlpopn:    mov    #rtname    ,r3        ; top of list of file specs to try
  559. 10$:    tst    @r3            ; end of the list yet?
  560.     beq    40$            ; yes, can't find the help file
  561.     calls    fparse    ,<@r3,#srcnam>    ; use Kermit's DK, not the os default
  562. .if df    RSTS                ; /E64/
  563.     tst    r0            ; /E64/ did it work?
  564.     bne    30$            ; /E64/ no
  565. .endc    ;RSTS                ; /E64/
  566.     calls    open    ,<#srcnam,#lun.in,#text> ; try to open file
  567.     tst    r0            ; did it work?
  568.     bne    30$            ; no
  569.     mov    #hlpbuf    ,r4        ; check for correct help file
  570.     calls    getrec    ,<r4,#lun.in,#132.> ; /63/ read the first line of it
  571.     tst    r0            ; error?
  572.     bne    20$            ; ya
  573.     clrb    hlpbuf(r1)        ; no, ensure it's .asciz please
  574.     call    loahlp            ; /63/ load overlay containing hident
  575.     strlen    #hident            ; length of verifying string
  576.     calls    instr    ,<r4,r1,#hident,r0> ; check it
  577.     tst    r0            ; a match?
  578.     bne    50$            ; found it, file is ok
  579. 20$:    wrtall    #errhdr            ; /63/ "?KRTHLP-W-"
  580.     wrtall    #srcnam            ; the bad version's file name
  581.     wrtall    #errver            ; /63/ " is an incorrect version",cr
  582.     calls    close    ,<#lun.in>    ; dump the channel to it
  583. 30$:    tst    (r3)+            ; prep for the
  584.     br    10$            ; next one
  585.  
  586. 40$:    wrtall    #errhdr            ; /63/ "?KRTHLP-W-"
  587.     wrtall    #errmis            ; /63/ "Can't find KRTHLP.HLP ..",cr
  588.     mov    #er$fnf    ,r0        ; return file not found error
  589.     br    60$
  590. 50$:    mov    sp    ,inopn        ; flag file is open so PF2 will know
  591.     clr    r0            ; success
  592. 60$:    return
  593.  
  594.     .end
  595.  
  596.