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
/
ZSYS
/
SIMTEL20
/
SYSLIB
/
STEST.LBR
/
STEST013.Z80
< prev
next >
Wrap
Text File
|
2000-06-30
|
3KB
|
136 lines
;
; PROGRAM: STEST013
; AUTHOR: RICHARD CONN
; PURPOSE: TO TEST THE F$APPL FUNCTION OF SYSLIB. STEST012 IS EXECUTED
; WITH COMMANDS LIKE:
; STEST013 FILE
; THE USER WILL BE PROMPTED FOR TEXT TO INPUT, AND THIS TEST WILL BE
; APPENDED AFTER THE LAST PIECE OF TEXT IN THE FILE.
;
;
; Externals
;
ext initfcb
ext print,bbline
ext f$exist,f$make,f$write,f$close,eval10
ext f$appl
;
; Equates
;
fcb equ 5ch
fcb2 equ 6ch
tbuff equ 80h
cr equ 0dh
lf equ 0ah
ctrlz equ 'Z'-'@'
;
; Test program
;
call print
db 'STEST013 - Text Append file test for SYSLIB',0
ld a,(fcb+1) ; check for help
cp '/'
jp z,help
cp ' '
jp nz,go
;
; Print help message
;
help:
call print
db cr,lf,'Syntax: STEST013 file cn'
db cr,lf,' "file" is the name of a file to append to'
db cr,lf,' The user is prompted for text to input'
db 0
ret
;
; Start
;
go:
ld de,fcb ; pt to fcb
call initfcb ; init for possible MAKE
call f$exist ; does file exist?
jp nz,start
call f$make ; create file if not
ld a,ctrlz ; mark file as empty
ld (tbuff),a
call f$write ; write 1 record
call f$close ; close it
start:
call f$appl ; open file for append on last record
jp z,start1
cp 3 ; empty file?
jp z,start1
call print
db cr,lf,'File Append Error',0
ret
start1:
ld hl,tbuff ; find continuation point
start2:
ld a,(hl) ; get char
inc hl ; pt to next
cp ctrlz ; done?
jp nz,start2
dec hl ; pt to ctrlz
loop:
ld (hl),ctrlz ; store ctrlz as if done
push hl ; save ptr
call print
db cr,lf,'Input Line (CR to End)> ',0
xor a ; no caps
call bbline ; get line from user
pop de ; ptr to buffer in DE
ld a,(hl) ; get first char
or a ; none?
jp z,done
ex de,hl ; HL pts to dest, DE to source
loop1:
ld a,(de) ; get next char
or a ; done?
jp z,loop2
call putch ; put char to disk
jp loop1
loop2:
ld a,cr ; put CRLF
call putch
ld a,lf
call putch
jp loop
;
; Put char in A to disk
;
putch:
ld (hl),a ; store it
inc hl ; pt to next
inc de
ld a,h ; record full?
or a ; 0=no
ret z
push de ; save ptr to source
ld de,fcb ; write record
call f$write
pop de ; get ptr to source
ld hl,tbuff ; pt to tbuff as dest
ret ; continue
;
; Fill last record with ^Z
; DE pts to next char in record
;
done:
ld a,ctrlz ; write ^Z
ld (de),a
inc de ; pt to next
ld a,d ; done?
or a ; 0=no
jp z,done
ld de,fcb ; write last record
call f$write
call f$close ; close file
ret
end