home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / dec20 / helper.mac < prev    next >
Text File  |  2020-01-01  |  6KB  |  150 lines

  1. ;<IMPORTS.COLUMBIA.MACRO>HELPER.MAC.20, 21-Feb-84 13:20:00, Edit by FORDYCE
  2. ;[drf-3] Corrected some problems with using HELPRF as an entry point so
  3. ;         that if user program uses HELPRF as the HELPER entry point, then
  4. ;         he can better handle the cases when he wants to use his own
  5. ;         '[no...' message
  6. ;<IMPORTS.COLUMBIA.MACRO>HELPER.MAC.15,  7-Apr-83 21:29:53, Edit by FORDYCE
  7. ;[drf-2] Add second entry point HELPRF to allow caller the versatility of
  8. ;         specifying whether or not he wants the '[no help...]' message
  9. ;         output or not
  10. ;        Add HLPWRN to indicate the above at entry, and at end (before
  11. ;         returning to the caller) to indicate whether or not help was
  12. ;         output successfully
  13. ;           hrroi t2,[asciz/..../]
  14. ;           seto t3,     ; go ahead and output '[no help...]' msg if need be
  15. ;             or
  16. ;           setz t3,     ; don't output '[no help...]' msg
  17. ;           call helprF  ; new entry point
  18. ;                        ; at this point (ac3) = -1 ==> (no) help output ok
  19. ;                        ;               (ac3) =  0 ==> no help output
  20. ;
  21. ;<IMPORTS.COLUMBIA.MACRO>HELPER.MAC.14, 22-Mar-83 13:52:15, Edit by FORDYCE
  22. ;[drf-1] Add GJ%IFG to GTJFN call in case some users have HLP: defined as
  23. ;          something like <HELP*>
  24. ;        Zero out left half of ac1 as returned on ok GTJFN call to get
  25. ;          rid of flags returned by GTJFN
  26.  
  27.         title Helper -- Help file printer
  28.  
  29.         search CUsym
  30.         %setenv
  31.  
  32.         entry   helper, helprf          ; What we're known as
  33.  
  34.  
  35. ; Helper
  36. ;
  37. ; Types the desired help file at the job's controlling
  38. ; terminal.  Actually, it will type any 7-bit ASCII file,
  39. ; but the error messages all refer to help files.
  40. ;
  41. ; Input:
  42. ;
  43. ;   t2/ 7-bit byte pointer to ASCIZ filespec.
  44. ;
  45. ; Effects:
  46. ;   If the specified file is found and accessible
  47. ;     then it is typed, otherwise an appropriate
  48. ;     error message is typed.
  49. ;
  50. ; Returns +1 always.
  51. ;
  52. ; Calling sequence:
  53. ;
  54. ;       search  CUsym
  55. ;       extern  helper
  56. ;         :
  57. ;       %setup
  58. ;         :
  59. ;       move    t2, [point 7, [asciz\HLP:FILE.HLP\]]
  60. ;       call    helper
  61. ;         :
  62. ;
  63. ;                               F. da Cruz, CUCCA, 8-Feb-78
  64. ;                               C. Ryland          1-Jun-78
  65.  
  66. ; Get a JFN for the file and open it.
  67.  
  68. helprF: saveac <t1,t2>          ;[drf-2] Save our work ac's
  69.         stkvar <hlpjfn>         ;[drf-2] Local for help file jfn
  70.         setom hlpwrn            ;[drf-2] Assume out '[no help...]' msg
  71.         skipn t3                ;[drf-2] unless otherwise instructed
  72.          setzm hlpwrn           ;[drf-2] So instructed
  73.         jrst helpr2             ;[drf-2] Continue normally
  74. helper: saveac <t1,t2>          ; Save our work ac's
  75.         stkvar <hlpjfn>         ; Local for help file jfn
  76.         setom hlpwrn            ;[drf-3] assume output '[no ...' message
  77. helpr2: setom hlpjfn            ; Don't have one yet [drf-2]
  78.         movx t1, gj%sht!gj%old!gj%ifg   ; Short form, old file [drf-1]
  79.         push p,t2               ;[drf-2]
  80.         hrli t2,440700          ;[drf-2] Save original bp
  81.         movem t2,hlpbp          ;[drf-2]
  82.         pop p,t2                ;[drf-2]
  83.         GTJFN                   ; Get help file jfn
  84.          erjmp nohelp           ; Exit on error
  85.         hrrzm t1, hlpjfn        ; Save the jfn
  86.         hrrz t1,t1              ;[drf-1] get rid of flags that GTJFN returns
  87.         movx t2, fld(7,of%bsz)!of%rd ; 7-bit bytes, read only
  88.         OPENF                   ; Open help file
  89.          erjmp nohelp           ; Again, exit on error
  90.         setom hlpwrn            ;[drf-2] Indicate something output to terminal
  91.  
  92. ; Type the file at the terminal, a byte at a time.
  93.  
  94. hlplup: move t1, hlpjfn         ; Load the jfn
  95.         BIN                     ; Get a byte
  96.          erjmp hlpeof           ; On error, go find cause
  97.         movei   t1, (t2)        ; Copy the byte
  98.         PBOUT                   ;  and type it
  99.          %jserr (,hlpend)       ; Allow for unlikely error
  100.         jrst    hlplup          ;  and loop for more
  101.  
  102. ; Get here when a BIN error has occurred.
  103.  
  104. hlpeof: move t1, hlpjfn         ; Load jfn
  105.         GTSTS                   ;  and get the status of the file
  106.          %jserr (,hlpend)       ;  taking care of errors...
  107.         txnn t2, gs%eof         ; Was it an end of file?
  108.          %ermsg <error reading help file>, hlpend ; no, tell them and leave
  109.         move t1, hlpjfn         ; Yes, it was eof, so
  110.         CLOSF                   ;  close the file,
  111.          jfcl                   ;  ignoring errors
  112.         setom hlpjfn            ; Empty the jfn, since it's gone
  113.                                 ;  and fall through to...
  114.         move t3,hlpwrn          ;[drf-2] Put saved value in ac3
  115.  
  116. ; Get here to finish up in all cases, always returning to caller.
  117.  
  118. hlpend: move t1, hlpjfn         ; Get the help jfn
  119.         camn t1, [-1]           ; Empty?
  120.          ret                    ; Yes, all finished
  121.         RLJFN                   ; No, try to relinquish it
  122.          erjmp r                ; Just ignore failure
  123.         ret                     ; All done
  124.  
  125. ; Get here if there was a GTJFN or OPENF error.
  126.  
  127. nohelp: move 3,hlpwrn           ;[drf-3]
  128.         move t1,hlpbp           ;[drf-2]
  129.         ildb t2,t1              ;[drf-2]
  130.         cain t2,40              ;[drf-2] If a space, then ok
  131.          setz t3,               ;[drf-2] Indicate to caller no help output
  132.         skipn hlpwrn            ;[drf-2]
  133.          jrst hlpend            ;[drf-2]
  134.         %typecr < [help is not currently available]>
  135.         jrst hlpend             ; Tell 'er and clean up
  136.  
  137. hlpwrn: block 1                 ;[drf-2]
  138. hlpbp:  block 1                 ;[drf-2]
  139.  
  140.         end
  141.  
  142.  
  143.  
  144. ; Local modes:
  145. ; Comment Start:;
  146. ; Comment Rounding: +1
  147. ; Mode: Midas
  148. ; End:
  149.  
  150.