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 / FOR-NXT2.LBR / FOR.ZZ0 / FOR.Z80
Text File  |  2000-06-30  |  15KB  |  679 lines

  1. ; FOR.Z80
  2. ;
  3. ; Takes a list of (ambiguous) file specifications as parameters and stores
  4. ; them in a file (FORFILES.SYS), optionally expanding the ambiguous names.
  5. ; Explicit directory specifications are retained in front of the names.
  6. ; The output file FORFILES.SYS is set to System status.  This is an ordinary
  7. ; text file, with one filename (or other list element) on each line.
  8. ;
  9. ; Alternatively, arbitrary strings, all named directories, or an ascending
  10. ; sequence of integers may be written to the file.
  11. ;
  12. ; Syntax:
  13. ;
  14. ;    FOR <[du:|dir:]fn.ft> [<[du:|dir:]fn.ft>] [/X]
  15. ;
  16. ; where the 'X' option indicates that all ambiguous filenames are to be
  17. ;    expanded.  If an ambiguous filename is prefaced with a DU: or DIR:
  18. ;    specification, its expansions will all also contain the directory
  19. ;    specification.
  20. ;
  21. ; -or-
  22. ;    FOR 'one string' "another string" \a third string\ /S
  23. ;
  24. ; where the 'S' option is REQUIRED to indicate that the list elements are
  25. ;    delimited strings.  Any non-blank character except the virgule (/)
  26. ;    and comma may be used as a delimiter.
  27. ;
  28. ; -or-
  29. ;    FOR /o
  30. ;
  31. ; where 'o' can be:
  32. ;    D  --  list all named directories
  33. ;    Rn --  list all integers up to that contained in register 'n',
  34. ;        one per line.  The list is zero-based
  35. ;    Nn --  list all integers up to 'n', one per line (zero-based).
  36. ;
  37. ;    If the 'Nn' or 'Rn' forms are used and a 1-based list is needed,
  38. ;    the first element can be removed with 'NEXT' and not used.  Any
  39. ;    parameters preceding one of these option specifications will be
  40. ;    ignored.
  41. ;
  42. ; In all circumstances, only one option is appropriate.  As presently written,
  43. ; program control is transferred directly based upon the option, rather than
  44. ; using an array of option flags.
  45. ;
  46. ; Delimiters BETWEEN list elements (whether filenames or strings) may be
  47. ; either spaces or commas.
  48. ;
  49. ;
  50. ; Author: Dreas Nielsen
  51. ; History --
  52. ;    Date        Version        Comments
  53. ;    ----        -------        --------
  54. ;    7/15/86        0.1        First code
  55. ;    1/10/87        0.2        Fixed ambiguous filenames
  56. ;    1/11/87        1.0        First complete version
  57. ;
  58. ;
  59. ;================[  Equates and External Routines  ]================
  60. ;
  61. VERS    EQU    10
  62. ;
  63. FALSE    EQU    0
  64. TRUE    EQU    NOT FALSE
  65. ;
  66. DEBUG    EQU    FALSE
  67. ;
  68. CR    EQU    0DH
  69. LF    EQU    0AH
  70. BELL    EQU    7
  71. SPACE    EQU    20H
  72. CTRLZ    EQU    1AH
  73. EOF    EQU    1AH
  74. BDOS    EQU    5
  75. INFERR    EQU    1    ;error code for "can't open input file"
  76. OFERR    EQU    2    ;error code for "can't open output file"
  77. RDERR    EQU    3    ;error code for "can't read input file"
  78. WRTERR    EQU    4    ;error code for "can't write output file"
  79. CLZERR    EQU    5    ;error code for "can't close output file"
  80. PARMFL    EQU    '/'
  81. XPARM    EQU    'X'
  82. LINLEN    EQU    300    ;max # of chars in output line
  83. CMDLIN    EQU    080H
  84. SYSFCB    EQU    05CH
  85. BUFSIZ    EQU    8    ;8 128-byte sectors (1k) for I/O buffers
  86. FCBLEN    EQU    36
  87. BSZOFF    EQU    0    ;offset of buffer size indicator from I/O ctl block
  88. BADOFF    EQU    6    ;offset of buffer addr indic. from I/O ctl block start
  89. FCBOFF    EQU    8    ;offset of fcb from I/O ctl block start
  90. ;
  91.     EXT    Z3INIT,QPRINT,SKSP,PRINT,PUTUD,GETUD,LOGUD,DIRF,MFN2
  92.     EXT    CODEND,PUTER2,FXO$OPEN,FX$PUT,FXO$CLOSE
  93.     EXT    ZPRSFN,DIRQ,MFN2,FILLB
  94.     EXT    DNSCAN,FNAME,GETNDR,GETREG,EVAL10,MHLFDC
  95. ;
  96. ;================[  Beginning of Program  ]================
  97. ;
  98.     DB    'Z3ENV'
  99.     DB    1
  100. Z3ENV:    DW    00
  101.     DB    VERS
  102. ;
  103. START:    LD    HL,(Z3ENV)
  104.     CALL    Z3INIT
  105. ;
  106. ; Reset error flag
  107.     XOR    A
  108.     CALL    PUTER2
  109. ;
  110. ; Save stack and set a new one
  111.     LD    (SAVESP),SP
  112.     LD    HL,STK
  113.     LD    SP,HL
  114. ;
  115. ; Print signon message
  116.     CALL    QPRINT
  117.     DB    'FOR  v. ',[VERS / 10] + '0','.',[VERS MOD 10] + '0',CR,LF,0
  118. ;
  119. ; Save currently logged DU
  120.     CALL    PUTUD
  121. ;
  122. ; Check for no parameters (help)
  123.     LD    A,(SYSFCB+1)
  124.     CP    ' '
  125.     JP    Z,HELP
  126. ;
  127. ; Store null at end of cmdline
  128.     LD    HL,CMDLIN
  129.     LD    A,(HL)
  130.     INC    A
  131.     LD    E,A
  132.     XOR    A
  133.     LD    D,A
  134.     ADD    HL,DE
  135.     LD    (HL),A
  136. ;
  137. ; Allocate space for file list and move command line
  138.     CALL    CODEND
  139.     LD    (PARAMS),HL
  140.     LD    DE,CMDLIN+1
  141. MOVCL:    LD    A,(DE)
  142.     LD    (HL),A
  143.     INC    HL
  144.     INC    DE
  145.     OR    A
  146.     JR    NZ,MOVCL
  147. ;
  148. ; Allocate space for DIR: specification, if needed.
  149.     LD    (DIRNAM),HL
  150.     LD    DE,24
  151.     ADD    HL,DE
  152. ;
  153. ; Allocate filename buffer used with DIRF
  154.     LD    (FNBUF),HL
  155.     LD    DE,13
  156.     ADD    HL,DE
  157. ; Allocate buffer for packed name string
  158.     LD    (NMDEST),HL
  159.     LD    DE,LINLEN
  160.     ADD    HL,DE
  161. ;
  162. ; Allocate output buffer and initialize it
  163.     LD    (OUTPLOC),HL
  164.     CALL    FBINIT        ;allocate I/O ctl buffer for output
  165.     LD    (FREE),HL
  166.     LD    HL,(OUTPLOC)
  167.     LD    DE,OFNAM
  168.     CALL    INITNAM
  169. ;
  170. ; Examine command line for option specification.  If no options are specified,
  171. ; the list is presumed to be of filenames which are not to be expanded or
  172. ; undelimited strings (without embedded spaces or commas).  This routine finds
  173. ; the LAST parameter flag on the line, as there may be some embedded in
  174. ; delimited strings.
  175. GETOPT:
  176.     LD    HL,00        ;zero out parameter address
  177.     LD    (PFADR),HL
  178.     LD    HL,(PARAMS)
  179. GETO2:    LD    A,(HL)
  180.     INC    HL
  181.     OR    A        ;end of list?
  182.     JR    Z,GETO3
  183.     CP    PARMFL
  184.     JR    NZ,GETO2
  185.     LD    (PFADR),HL
  186.     JR    GETO2
  187. ;
  188. GETO3:    LD    HL,(PFADR)
  189.     LD    A,H
  190.     OR    L        ;if this is null...
  191.     JR    Z,RAWFILES    ;...no parameter flag was found
  192. ;
  193. ; Examine char after '/' and proceed accordingly
  194.     CALL    SKSP
  195.     LD    A,(HL)
  196.     CP    'X'
  197.     JR    Z,AMBFILS    ;ambiguous filenames
  198.     CP    'S'
  199.     JP    Z,STRINGS    ;delimited strings
  200.     CP    'D'
  201.     JP    Z,DIRNAMES    ;directory names
  202.     CP    'R'
  203.     JP    Z,REGS        ;register value
  204.     CP    'N'
  205.     JP    Z,NUM        ;integer value
  206.     JP    HELP        ;because it is an unrecognized option
  207. ;
  208. ; Parameter list is unambigous filenames or undelimited strings.
  209. RAWFILES:
  210.     CALL    OPENOUT
  211.     LD    HL,(PARAMS)
  212. RAW1:    LD    A,(HL)        ;skip to first non-delimiter
  213.     INC    HL
  214.     CALL    LISTDEL
  215.     JR    Z,RAW1
  216.     OR    A
  217.     JR    Z,RAW6
  218.     DEC    HL        ;point back 1 to fetch 1st char again
  219. ;
  220. RAW2:    LD    DE,(NMDEST)    ;transfer token
  221. RAW3:    LD    A,(HL)
  222.     INC    HL
  223.     OR    A        ;end of list?
  224.     JR    Z,RAW4
  225.     CALL    LISTDEL        ;space or comma?
  226.     JR    Z,RAW4
  227.     LD    (DE),A
  228.     INC    DE
  229.     JR    RAW3        ;get next char of current token
  230. ;
  231. RAW4:                ;write current token and look for next
  232.     CALL    WRTTOK
  233.     JR    NZ,RAW2        ;next token found -- get and write it
  234. ;
  235. RAW6:                ;end of list found
  236.     CALL    CLOSOUT
  237.     JP    DONE
  238. ;
  239. ;----------------
  240. ; Parameter list is a list of ambiguous filenames.
  241. AMBFILS:
  242.     CALL    OPENOUT
  243.     LD    HL,(PARAMS)    ;save prefix (DU: or DIR:) if it exists
  244. AMB0:    LD    A,(HL)        ;skip to first non-delimiter
  245.     INC    HL
  246.     CALL    LISTDEL        ;is (A) a list delimiter?
  247.     JR    Z,AMB0        ;if so, get next character
  248.     OR    A
  249.     JP    Z,AMB3        ;if end of list, quit
  250.     DEC    HL        ;point back 1 to 1st char of token
  251.     PUSH    HL        ;save starting point
  252.     CALL    NXTDLM        ;see if next delimiter is a colon
  253.     POP    HL        ;get starting addr. back
  254.     LD    DE,(DIRNAM)    ;destination buffer; HL points to source
  255.     CP    ':'
  256.     JR    NZ,NOMOV
  257. ;                ;move DU:/DIR: spec into buffer
  258. MOVDU:    LD    A,(HL)
  259.     LD    (DE),A
  260.     INC    HL
  261.     INC    DE
  262.     CP    ':'
  263.     JR    NZ,MOVDU
  264. ;
  265. NOMOV:    XOR    A        ;null-terminate DU:/DIR: spec buffer
  266.     LD    (DE),A
  267. ;
  268. ; Parse the filename pointed to by HL into FCB format
  269.     PUSH    HL        ;save ptr to filename
  270.     LD    HL,(DIRNAM)
  271.     LD    A,(HL)
  272.     OR    A
  273.     JR    Z,P2        ;don't scan if no DU/DIR
  274.     XOR    A        ;DU before DIR
  275.     CALL    DNSCAN
  276.     JR    Z,P2        ;if invalid, stay here
  277.     CALL    LOGUD
  278. P2:    POP    HL        ;get filename
  279.     LD    DE,SYSFCB
  280.     CALL    FNAME        ;parse filename into FCB
  281.     JR    Z,AMB2
  282.     LD    (CLPTR),HL    ;save pointer to tokens
  283.     LD    HL,(FREE)    ;buffer area for directory load
  284.     LD    A,10100000B    ;non-system files sorted by name
  285.     CALL    DIRQ        ;load directory
  286.     CALL    GETUD        ;return home to write file
  287. ;
  288.     INC    HL        ;point to first name
  289.     EX    DE,HL        ;...with DE
  290. WRNAMS:    LD    A,B        ;for all filenames in buffer...
  291.     OR    C
  292.     JR    Z,WRNAM3
  293.     PUSH    DE        ;(save ptr to name)
  294.     LD    DE,(DIRNAM)    ;...move directory name to write buffer
  295.     LD    HL,(NMDEST)
  296. WRNAM1:    LD    A,(DE)
  297.     INC    DE
  298.     OR    A
  299.     JR    Z,WRNAM2
  300.     LD    (HL),A
  301.     INC    HL
  302.     JR    WRNAM1
  303. WRNAM2:    POP    DE        ;HL = mem buffer, DE = name
  304. ;
  305.     PUSH    BC        ;write 13 nulls, so name will be null-term.
  306.     LD    B,13
  307.     XOR    A
  308.     CALL    FILLB
  309.     POP    BC
  310. ;
  311.     CALL    MFN2        ;convert fname to packed string in wrt buffer
  312.     PUSH    DE
  313. ;
  314.     CALL    WRTSTR        ;write name to file
  315.     POP    DE
  316.     LD    HL,16        ;set DE to point to next name
  317.     ADD    HL,DE
  318.     EX    DE,HL
  319.     DEC    BC        ;count down number of names written
  320.     JR    WRNAMS
  321. ;
  322. WRNAM3:                ;done with this token, look for next
  323.     LD    HL,(CLPTR)
  324. AMB2:    LD    A,(HL)
  325.     INC    HL
  326.     OR    A
  327.     JR    Z,AMB3
  328.     CP    PARMFL
  329.     JR    Z,AMB3
  330.     CALL    LISTDEL
  331.     JR    Z,AMB2
  332.     DEC    HL        ;if another token found, point to 1st char
  333.     JP    AMB0        ;go back and process it
  334. ;
  335. AMB3:    CALL    CLOSOUT
  336.     JP    DONE
  337. ;
  338. ;
  339. ;----------------
  340. ; Chop parameter list into delimited strings.
  341. ;
  342. STRINGS:
  343.     CALL    OPENOUT
  344.     LD    HL,(PARAMS)
  345. STR1:    LD    A,(HL)        ;skip to first non-comma, non-space
  346.     INC    HL
  347.     CALL    LISTDEL
  348.     JR    Z,STR1
  349.     OR    A
  350.     JR    Z,STR5
  351.     DEC    HL
  352. ;
  353. STR2:    LD    A,(HL)
  354.     LD    (DELIM),A    ;save delimiter for comparison
  355.     INC    HL
  356.     LD    DE,(NMDEST)
  357. STR3:    LD    A,(HL)
  358.     INC    HL
  359.     OR    A
  360.     JR    Z,STR4
  361. DELIM    EQU    $+1
  362.     CP    00        ;the current string delimiter is used here
  363.     JR    Z,STR4
  364.     LD    (DE),A
  365.     INC    DE
  366.     JR    STR3
  367. ;
  368. STR4:
  369.     OR    A        ;if not null, bump HL by 1 more to account...
  370.     JR    Z,STR5        ;...for DEC HL in WRTTOK
  371.     INC    HL
  372. STR5:    CALL    WRTTOK
  373.     JR    NZ,STR2
  374. ;
  375. STR6:
  376.     CALL    CLOSOUT
  377.     JP    DONE
  378. ;
  379. ;
  380. ;  List all directory names.
  381. ;
  382. DIRNAMES:
  383.     CALL    GETNDR
  384.     JP    Z,DONE
  385.     LD    A,(HL)
  386.     JP    Z,DONE
  387. ; There is a buffer and there is at least one entry in it
  388.     CALL    OPENOUT
  389. DIRN1:    LD    A,(HL)
  390.     OR    A
  391.     JR    Z,DIRNZ        ; end of list reached
  392.     INC    HL
  393.     INC    HL        ; now pointing to name
  394.     PUSH    HL        ; save this pointer
  395.     LD    DE,(NMDEST)    ; transfer name to output buffer
  396.     LD    B,8
  397. DIRN2:    LD    A,(HL)
  398.     CP    ' '
  399.     JR    Z,DIRN3
  400.     LD    (DE),A
  401.     INC    HL
  402.     INC    DE
  403.     DJNZ    DIRN2
  404. ;
  405. DIRN3:    LD    A,':'
  406.     LD    (DE),A
  407.     INC    DE
  408.     XOR    A
  409.     LD    (DE),A
  410.     CALL    WRTSTR
  411. ;
  412.     POP    HL        ; advance to next directory name
  413.     LD    DE,16
  414.     ADD    HL,DE
  415.     JR    DIRN1
  416. ;
  417. DIRNZ:    CALL    CLOSOUT        ; all done with directory names
  418.     JP    DONE
  419. ;
  420. ;
  421. ; Write all numbers up to the value contained in the register specified by
  422. ; the character at (HL+1).  The list will be zero-based and will run up to
  423. ; the register value - 1.
  424. ;
  425. REGS:
  426.     INC    HL
  427.     LD    A,(HL)
  428.     OR    A
  429.     JR    Z,REGERR    ; premature eol
  430.     SUB    '0'
  431.     CP    0
  432.     JR    C,REGERR    ; illegal value
  433.     CP    10
  434.     JR    NC,REGERR
  435. ; A register value is specified and it is legal
  436.     LD    B,A
  437.     CALL    GETREG
  438.     LD    E,A
  439.     LD    D,0
  440.     JR    WRTNUMS
  441. ;
  442. REGERR:
  443.     CALL    PRINT
  444.     DB    'Improper register value.',CR,LF,0
  445.     XOR    A
  446.     DEC    A
  447.     CALL    PUTER2
  448.     JP    DONE
  449. ;
  450. ;
  451. ; Write a zero-based list of numbers, up to (but not including) the value
  452. ; indicated by the string at (HL+1).
  453. ;
  454. NUM:
  455.     INC    HL
  456.     LD    A,(HL)
  457.     OR    A
  458.     JR    Z,NUMERR
  459.     CALL    EVAL10
  460.     JR    WRTNUMS
  461. ;
  462. NUMERR:    CALL    PRINT
  463.     DB    'Unspecified numeric argument.',CR,LF,0
  464.     XOR    A
  465.     DEC    A
  466.     CALL    PUTER2
  467.     JP    DONE
  468. ;
  469. ;  Write out numbers up to the value in DE if DE > 0
  470. WRTNUMS:
  471.     LD    A,E
  472.     OR    D
  473.     JP    Z,DONE        ; don't write anything if arg is 0
  474.     PUSH    DE
  475.     CALL    OPENOUT
  476.     POP    DE
  477.     LD    HL,00        ; HL counts up to limit in DE
  478. WRTNUM1:
  479.     PUSH    DE        ; save limit
  480.     LD    DE,(NMDEST)    ; format & write number
  481.     CALL    MHLFDC
  482.     XOR    A
  483.     LD    (DE),A
  484.     PUSH    HL
  485.     CALL    WRTSTR
  486.     POP    HL
  487.     POP    DE        ; get limit back
  488.     INC    HL        ; compute next number to write
  489.     PUSH    HL        ; save it while comparing to limit
  490.     OR    A        ; clear carry flag
  491.     SBC    HL,DE        ; at limit yet?
  492.     LD    A,H
  493.     OR    L
  494.     POP    HL        ; get current value back
  495.     JR    Z,WRTNUMZ    ; if at limit, go quit
  496.     JR    WRTNUM1        ; else go back and write the next number
  497. ;
  498. WRTNUMZ:
  499.     CALL    CLOSOUT
  500.     JP    DONE
  501. ;
  502. ;
  503. ;
  504. ; Print help message and fall through to exit.
  505. HELP:
  506.     CALL    PRINT
  507.     DB    'Syntax is:',CR,LF
  508.     DB    '   FOR <[du:|dir:]fn.ft> [<[du:|dir:]fn.ft>] [/x]',CR,LF
  509.     DB    'or',CR,LF
  510.     DB    '   FOR ''one string'' "another string" \a third string\ /s',CR,LF
  511.     DB    'or',CR,LF
  512.     DB    '   FOR /o',CR,LF
  513.     DB    'Options:'CR,LF
  514.     DB    '   x -- Expand ambiguous filenames',CR,LF
  515.     DB    '   s -- List elements are delimited strings',CR,LF
  516.     DB    '   o -- May be:',CR,LF
  517.     DB    '            D  --  list all named directories',CR,LF
  518.     DB    '            Rn --  list all integers up to that contained in register ''n'',',CR,LF
  519.     DB    '                   one per line.  The list is zero-based.',CR,LF
  520.     DB    '            Nn --  list all integers up to ''n'', one per line (zero-based).',CR,LF
  521.     DB    0
  522. ;
  523. ;
  524. ; Clean up and exit program.
  525. DONE:
  526.     CALL    GETUD
  527.     LD    SP,(SAVESP)
  528.     RET
  529. ;
  530. ;
  531. ;================[  Subroutines  ]================
  532. ;
  533. ; Initialize file I/O control buffers.
  534. ; Enter with  HL = first free address in memory
  535. ;             B  = number of 128-byte sectors for the file buffer
  536. ; Return:     HL = first free address after buffer
  537. ;
  538. FBINIT:
  539.     PUSH    DE
  540.     PUSH    BC
  541.     LD    (HL),B
  542.     LD    DE,BADOFF    ;loc of buf addr in I/O ctl block
  543.     ADD    HL,DE
  544.     PUSH    HL
  545.     LD    DE,[FCBLEN + FCBOFF - BADOFF]
  546.     ADD    HL,DE
  547.     EX    DE,HL
  548.     POP    HL
  549.     LD    (HL),E
  550.     INC    HL
  551.     LD    (HL),D
  552.     EX    DE,HL        ;get buf start addr in HL
  553.     LD    DE,128        ;incr HL by buf len in bytes
  554. FBINI1:    ADD    HL,DE
  555.     DJNZ    FBINI1
  556.     POP    BC
  557.     POP    DE
  558.     RET
  559. ;
  560. ;----------------
  561. ; Move filename into fcb of I/O ctl block.  Enter with HL = I/O ctl blk addr,
  562. ; DE = addr of string to move.  Drive is set to current.
  563. INITNAM:
  564.     PUSH    BC
  565.     PUSH    DE        ;save while adding fcb offset
  566.     LD    DE,FCBOFF
  567.     ADD    HL,DE        ;point to input fcb
  568.     XOR    A        ;set current drive
  569.     LD    (HL),A
  570.     INC    HL        ;point to name field of fcb
  571.     POP    DE        ;get source addr
  572.     EX    DE,HL        ;put dest addr in DE, source in HL
  573.     LD    BC,11
  574.     LDIR
  575.     POP    BC        ;restore original contents
  576.     RET
  577. ;
  578. ;----------------
  579. ; Open output file
  580. OPENOUT:
  581.     LD    DE,(OUTPLOC)
  582.     CALL    FXO$OPEN
  583.     RET
  584. ;
  585. ;----------------
  586. ; Close output file
  587. CLOSOUT:
  588.     LD    DE,(OUTPLOC)
  589.     CALL    FXO$CLOSE
  590.     RET
  591. ;
  592. ;----------------
  593. ; Find next delimiter in string pointed to by HL.  Return with delim. in A,
  594. ; HL pointing past char.  Delimiters are:
  595. ;    <NULL>  <SPACE>  /  ,  :
  596. NXTDLM:    LD    A,(HL)
  597.     INC    HL
  598.     CP    ':'
  599.     RET    Z
  600.     CP    ','
  601.     RET    Z
  602.     CP    ' '
  603.     RET    Z
  604.     OR    A
  605.     RET    Z
  606.     CP    '/'
  607.     RET    Z
  608.     JR    NXTDLM
  609. ;
  610. ;----------------
  611. ; Is (A) a list-element delimiter (a comma or space?).   Return Z if true.
  612. LISTDEL:
  613.     CP    SPACE
  614.     RET    Z
  615.     CP    ','
  616.     RET
  617. ;
  618. ;----------------
  619. ; Write the string pointed to by NMDEST to the output file.  String will be
  620. ; terminated with a CR/LF.
  621. WRTSTR:
  622.     LD    DE,(OUTPLOC)
  623.     LD    HL,(NMDEST)
  624. WRT2:    LD    A,(HL)
  625.     INC    HL
  626.     OR    A
  627.     JR    Z,WRT3
  628.     CALL    FX$PUT
  629.     JR    WRT2
  630. WRT3:    LD    A,CR
  631.     CALL    FX$PUT
  632.     LD    A,LF
  633.     CALL    FX$PUT
  634.     RET
  635. ;
  636. ;----------------
  637. ; Null-terminate the current token and write it out, then search for the next.
  638. ; Return Z if the end of the input has been reached, NZ otherwise.  On return,
  639. ; HL points to the next non-blank, non-comma character.
  640. WRTTOK:
  641.     XOR    A        ;store null at end of token
  642.     LD    (DE),A
  643.     PUSH    HL
  644.     CALL    WRTSTR
  645.     POP    HL
  646.     DEC    HL        ;point to delim again in case it's a null
  647. WRTT:    LD    A,(HL)        ;skip over multiple delimiters
  648.     INC    HL
  649.     OR    A        ;No blank lines can be generated by multiple
  650.     RET    Z        ;delimiters.
  651.     CP    PARMFL
  652.     RET    Z
  653.     CALL    LISTDEL
  654.     JR    Z,WRTT
  655.     DEC    HL        ;we'll fetch the non-delimiter again
  656.     RET
  657. ;
  658. ;
  659. ;================[  Storage  ]================
  660. ;
  661. SAVESP:    DS    2
  662. PARAMS:            ;addr of list of files (command line)
  663.     DS    2
  664. FREE:    DS    2    ;addr of beginning of free memory
  665. XPAND:    DB    0    ;flag: NZ=expand ambiguous names, 0=don't.
  666. DIRNAM:    DS    2    ;addr of buffer for directory name
  667. FNBUF:    DS    2    ;addr of buffer for file name
  668. NMDEST:    DS    2    ;address of destn for packed name string
  669. PFADR:    DS    2    ;address following last parameter flag in command line
  670. CLPTR:    DS    2    ;temp. storage for pointer to cmd line
  671. OUTPLOC:
  672.     DS    2    ;addr of output file buffer
  673. OFNAM:    DB    'FORFILESS','Y'+80H,'S'
  674. STKBOT:    DS    48
  675. STK:    DS    2
  676. ;
  677. ;
  678.     END    START
  679.