*   
 ORG 100H
 XEQ 100H
*   
 COPY NPTDEFS
*   
 LXI D,TBUF READ SOURCE FILE NAME
 MVI A,PSN  ...TO LN1
 CALL PSCAN
 STA LASTCHARACTER
 CZ PERR
 MOV C,A
 STA COUNT
*   
*  CHECK FOR OPTIONAL FILE NAME FILE
*   
 LDA LASTCHARACTER
 CPI ','
 JNZ LAB1
 LXI D,FNFILE
 MVI A,PSN
 CALL PSCAN
 CZ PERR
LAB1 LXI H,FNFILE
 LXI D,PBUFF
 MVI A,PSOP+40H  OPEN WITH NO CREATE
 CALL PSCAN
 CC PERR
 MOV A,E
 CPI -1  CHECK FOR FILE OPEN
 CZ PERR
 STA FNUM
*   
*  GET FILE NAMES FROM FILE NAME FILE
*   
 LXI B,65
 LXI D,LN1
 MVI L,'%'
 CALL SYS
 DB DRDOP
 CALL SERR
 DCX D
 XCHG
 LXI D,TBUF
L1 LDAX D
 MOV M,A
 INX D
 INX H
 ORA A
 JNZ L1
*   
 DCX H
 XCHG .
 CALL DLMRD
 LXI D,LN2  GET SECOND SET OF FILE NAMES
 CALL DLMRD
 LDA FNUM
 CALL SYS
 DB CLOOP
 CALL SERR
*   
*  OPEN OUTPUT FILE
*   
 LXI D,PBUFF
 LXI H,SIFILE
 MVI A,PSCO+40H
 CALL PSCAN
 CC PERR
 MOV A,E
 CPI -1  CHECK FOR FILE OPEN
 CZ PERR
 STA FNUM
*   
*  BUILD SETIN FILE
*   
 LXI D,LINE1
 CALL DLMWR
 LXI D,LINE2
 CALL DLMWR
 LXI D,LINE3
 CALL DLMWR
*   
*  END FILE SETIN FILE
*   
 LDA FNUM
 CALL SYS
 DB EOFOP
 CALL SERR
*   
*  REWIND SETIN FILE
*   
 LDA FNUM
 MVI D,0
 CALL SYS
 DB SPAOP
 CALL SERR
*   
*  SET CI INPUT FILE NUMBER TO PSCL.CMD
*   
 LHLD SYSGLO
 LXI D,GLCIF
 DAD D
 MOV M,A
*   
 CALL SYS  LET PTDOS HANDLE THE REST
 DB RETOP
*   
*  DO DELIMITED READ TO DE WITH 0DH AS DELIMITER
*   
DLMRD LDA FNUM
 LXI B,65
 MVI L,0DH
 CALL SYS
 DB DRDOP
 CALL SERR
 RET
*   
*  DO DELIMITED WRITE TO DE WITH 0DH AS DELIMITER
*   
DLMWR LDA FNUM
 LXI B,55
 MVI L,0DH
 CALL SYS
 DB DWROP
 CALL SERR
 RET
*   
PERR EQU $
 MOV A,E
SERR EQU $
*   
 POP H
 CALL SYS
 DB ABTOP
*   
FNUM DB 0
ENDNAME DW 0
LASTCHARACTER DB 0
*   
LINE1 ASC "RUN "
LN1 DS 65-LN1+LINE1
*   
LINE2 ASC "RUN "
LN2 DS 65-LN2+LINE2
*   
LINE3 ASC "SETIN #0"
 DB 0DH
*   
FNFILE ASC "PAS.DEFS"
 DB 0,0,0,0
*   
SIFILE ASC "PAS.CMPL"
 DB 0
*   
 DB 'P'+80H  PARAMETERS FOR POSSIBLE CREATE
 DW 100H
 DB 0
*   
PBUFF DS 20
*   
TBUF DS 10
*   
COUNT DB 0
 END
*   
