#: 12713 S10/OS9/6809 (CoCo)
27-Oct-91 00:26:11
Sb: #12705-#End of files
Fm: Kevin Darling 76703,4227
To: Denise Tomlinson 71021,3274 (X)
Denise,
Basic09 is neat. Great for writing quick little tools and packing them into
new commands. One way to seek to the end, is to use the Syscall subroutine
to access a low-level OS-9 status call, to get the filesize. Then seek
to that spot and start adding on from there.
WARNING: seeking to a higher
number will always expand the file to that size. Do NOT do something like
a "seek #path,4000000" because it'll try to grab 4 megabytes from your
disk... and all you can do is wait until it gets it or errors out .
Anyway, here's a sample you can run on a small ascii test file you've made:
PROCEDURE filesize
TYPE stack=CC,A,B,DP:BYTE; X,Y,U:INTEGER
DIM regs:stack
DIM path:BYTE \(* BYTE not INTEGER in this case
DIM I_GetStt:BYTE \I_GetStt=$8D
DIM SS_Size:BYTE \SS_Size=$02
INPUT "file ",f$ \ (* get a test file name that exists
OPEN #path,f$
regs.A=path
regs.B=SS_Size
RUN syscall(I_GetStt,regs) \ (* get the filesize
high=regs.X
IF high<0 THEN
high=65536.+high
ENDIF
low=regs.U
IF low<0 THEN
low=65536.+low
ENDIF
filesize=high*65536.+low
PRINT "filesize=",filesize \ (* print the filesize
SEEK #path,filesize \ (* seek to end of file
PRINT #path,"*test" \ (* optionally, add a string to the file
CLOSE #path
END
There is 1 Reply.
|