home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / ZCPR33 / A-R / ERRSET13.LBR / ERRSET13.ZZ0 / ERRSET13.Z80
Text File  |  2000-06-30  |  6KB  |  239 lines

  1.  
  2. ; Program: ERRSET
  3. ; Author: Jay Sage
  4. ; Version: 1.3
  5. ; Date: June 1, 1987
  6.  
  7.  
  8. ;            * * *   IMPORTANT NOTE   * * *
  9. ;
  10. ; This program is copyrighted 1987 by NAOG/ZSIG.  It may be copied and
  11. ; modified freely for personal use but may not be sold or distributed for a
  12. ; fee.  Modified versions must be submitted to and approved by NAOG/ZSIG
  13. ; before they may be distributed.  See the file ZSIGPOL1.DOC on Z-Nodes for
  14. ; the ZSIG policy on signing out and modifying programs.
  15.  
  16. version    equ    13
  17.  
  18. ; This program displays, clears, or sets the error handler command line.
  19. ; Error messages are given if there is no message buffer (and hence no
  20. ; external error handling) or if an attempt is made to load an error command
  21. ; line that is too long.  For the sake of neatness, ERRSET clears extraneous
  22. ; bytes in the the message buffer beyond the terminating null of the new
  23. ; command line.  The built-in help screen describes the syntax.
  24.  
  25. ; UPDATE HISTORY
  26.  
  27. ; Version 1.3
  28. ;    Updated to ZCPR33 compatibility using Z33LIB routines.
  29.  
  30. ; Version 1.2
  31. ;    Corrected mistake resulting from misconception that error handler
  32. ;    command line buffer was only 16 bytes long.  It was originally 32
  33. ;    bytes long, but ZCPR33 has taken some of that space.  ERRSET now
  34. ;    allows a number set by the CMDLEN equate.  A value of 25 is
  35. ;    recommended.  A value of 28 is the largest allowed with ZCPR33.
  36.  
  37. ;=============================================================================
  38.  
  39. ;            E Q U A T E S
  40.  
  41. no    equ    0
  42. yes    equ    not no
  43.  
  44. usedseg    equ    no        ; If yes, uses separate data segment and
  45.                 ; ..requires special linking
  46.  
  47. cmdlen    equ    25
  48.  
  49. tbuff    equ    80h
  50. fcb    equ    5ch
  51. cr    equ    0dh
  52. lf    equ    0ah
  53. tab    equ    09h
  54. bell    equ    07h
  55. eot    equ    1ah
  56.  
  57. ;=============================================================================
  58.  
  59. ;        E X T E R N A L    R E F E R E N C E S
  60.  
  61.  
  62.     ext z3init,print,pstr,getmsg,sksp,z33chk,geterc,puterc
  63.  
  64.  
  65. ;=============================================================================
  66.  
  67. ;        Z C P R    I N I T I A L I Z A T I O N
  68.  
  69.  
  70. ; External ZCPR3 Environment Descriptor
  71.  
  72. entry:
  73.     jp    start
  74.     defb    'Z3ENV'        ; This is a ZCPR3 utility
  75.     defb    3        ; zcpr33 type 3 environment
  76. z3eadr:
  77.     defw    0        ; Filled in by CPR or install program
  78.     defw    entry        ; Load address for ZCPR33 type 3 environment
  79.  
  80.  
  81. ;=============================================================================
  82.  
  83. ;        M A I N    P R O G R A M    C O D E
  84.  
  85. start:
  86.     ld    hl,(z3eadr)    ; Pt to ZCPR3 environment
  87.     call    z3init        ; Initialize Z3 system
  88.  
  89.                 ; Check for option or help request
  90.  
  91.     call    getfirst    ; Get first non-space character in tail
  92.     jp    z,display    ; Branch if null command line
  93.  
  94.     cp    '/'        ; Branch if not an option request
  95.     jr    nz,start1
  96.  
  97.     inc    hl        ; Point to next character
  98.     ld    a,(hl)        ; ..and get it
  99.     cp    'C'        ; Clear option?
  100.     jr    z,cancel
  101.     cp    'Z'        ; Zero option?
  102.     jp    nz,help        ; If not, branch to help message
  103.  
  104. cancel:
  105.     call    getmsg        ; Get pointer to message buffer
  106.     ld    (hl),0        ; Reset error-handler-installed flag (ZCPR30)
  107.     call    geterc        ; Get pointer to error command line
  108.     ld    b,cmdlen    ; Zero out error command line
  109.     xor    a
  110. cancel1:
  111.     ld    (hl),a
  112.     inc    hl
  113.     djnz    cancel1    
  114.  
  115.     call    print
  116.     defb    cr,lf
  117.     defb    ' External error handling turned off'
  118.     defb    0
  119.     jp    quit
  120.  
  121. start1:
  122.     call    puterc        ; Copy user's command line to error line
  123.     jr    nz,start2    ; If successful, branch to START2
  124.  
  125.     call    print        ; Otherwise report error
  126.     defb    cr,lf,bell,' Command line too long',0
  127.     jr    cancel
  128.  
  129. start2:
  130.     call    getmsg        ; Get pointer to message buffer
  131.     ld    (hl),0ffh    ; Set error-handler-installed flag (ZCPR30)
  132.  
  133. display:
  134.     call    z33chk        ; See if ZCPR33 is running (Z set if so)
  135.     jr    z,dsp33        ; If so, skip over ZCPR30-style checking
  136.  
  137.     call    getmsg        ; Get pointer to first byte of message buffer
  138.     ld    a,(hl)        ; See if error handler is engaged
  139.     or    a
  140.     jr    z,noerrh    ; Case for error handler not engaged
  141.  
  142. dsp33:
  143.     call    geterc        ; Get pointer to error command line
  144.     ld    a,(hl)        ; Get first byte
  145.     or    a        ; Check for null line
  146.     jr    nz,errh        ; If not null, branch
  147.  
  148. noerrh:
  149.     call    print
  150.     defb    cr,lf
  151.     defb    ' No error handler loaded'
  152.     defb    0
  153.     jr    quit
  154.  
  155. errh:
  156.     call    print
  157.     defb    cr,lf
  158.     defb    ' Error handler command line set to: '
  159.     defb    0
  160.  
  161.     call    pstr        ; Print error handling command line
  162.  
  163. quit:
  164.     call    print
  165.     defb    cr,lf
  166.     defb    0
  167.  
  168.     ret
  169.  
  170. ;-----------------------------------------------------------------------------
  171.  
  172. ; Get the first non-space character in the command line tail and set the
  173. ; zero flag to reflect end-of-line status.
  174.  
  175. getfirst:
  176.     ld    hl,tbuff+1    ; Point to command tail
  177.     call    sksp        ; Skip over leading spaces
  178.     ld    a,(hl)        ; Get first character
  179.     or    a
  180.     ret
  181.  
  182. ;-----------------------------------------------------------------------------
  183.  
  184. ; Copy characters from HL to DE up to number allowed in error command line.
  185.  
  186. copy:
  187.     ld    b,cmdlen    ; Maximum characters to copy
  188. copy1:
  189.     ld    a,(hl)        ; Get next character from command tail
  190.     or    a        ; End of tail?
  191.     ret    z
  192.     ld    (de),a        ; Copy the character
  193.     inc    hl        ; Increment pointers
  194.     inc    de
  195.     djnz    copy1        ; Continue copying
  196.     ret
  197.  
  198. ;-----------------------------------------------------------------------------
  199.  
  200. help:
  201.     call    print
  202.     defb    cr,lf,lf
  203.     defb    tab,tab,'ERRSET Version '
  204.     defb    version    / 10 + '0'
  205.     defb    '.'
  206.     defb    version    mod 10 + '0'
  207.     defb    ' [ZSIG]'
  208.     defb    cr,lf,lf
  209.     defb    '  Syntax:'
  210.     defb    cr,lf,lf
  211.     defb    tab,'ERRSET',tab,tab,'display current error command line'
  212.     defb    cr,lf
  213.     defb    tab,'ERRSET CMDLINE',tab,'set new error command line'
  214.     defb    cr,lf
  215.     defb    tab,'ERRSET /C',tab,'clear external error handling'
  216.     defb    cr,lf
  217.     defb    tab,'ERRSET /Z',tab,'zero out external error handling'
  218.     defb    cr,lf,lf
  219.     defb    '  Example:  ERRSET A15:VERROR'
  220.     defb    cr,lf,lf
  221.     defb    tab,'An explicit DU: or DIR: prefix can speed error handling.'
  222.     defb    cr,lf
  223.     defb    tab,'NOTE: the command line entered is not checked '
  224.     defb    'for validity.'
  225.     defb    cr,lf,lf
  226.     defb    0
  227.     ret
  228.  
  229. ;-----------------------------------------------------------------------------
  230.  
  231.      if    usedseg
  232.     dseg
  233.      endif
  234.  
  235. dummybuf:
  236.     defs    cmdlen
  237.  
  238.     end
  239.