home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / b / krthlp.mac < prev    next >
Text File  |  2020-01-01  |  22KB  |  581 lines

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