SpartaDOS X Reference Manual

Programming with SpartaDOS X




Set File Position — POINT

Index


Purpose To allow direct access to specific points within a disk file (or past the end of a file if necessary).
 
Syntax

X=POS
Y=0 (see text)
POINT #IOCB,X,Y

or

A=INT(POS/65536)
B=INT((POS-A*65536)/256)
C=POS-A*65536-B*256
POKE 844+IOCB*16,C
POKE 845+IOCB*16,B
POKE 846+IOCB*16,A
XIO 37, #IOCB,aux1,aux2,"Dd:"
 

Remarks Unlike Atari DOS and compatibles, which use an absolute physical disk position (sector and offset into sector) for the NOTE and POINT functions, SpartaDOS X uses a relative position within the file. POS is the desired offset into the currently open file. For example, if POS was 612, the next GET from the file would get the 613th byte of the file. This value will refer to the same position in the file even if the file is physically moved to another disk. The file must be open for this operation.

Because of a limitation in Atari BASIC, BASIC XL, and BASIC XE, the first method shown, using the POINT command, will only work with positions up to and including 32767. If a value greater than 32767 is given a BASIC error will occur. To POINT to a greater location with these languages (and possibly others) it is necessary to use the second method. The POINT command is bypassed by poking the three byte file position directly into the IOCB registers and executing the XIO. Aux1 and aux2 must be the values used when the file was opened.

Other languages, such as Action! and Turbo BASIC XL, have no such limitation on the POINT command, allowing it to be used instead of the lengthy XIO method. In this case, use the following format:

Y=INT(POS/65536)
X=POS-Y*65536
POINT #IOCB,X,Y

If you are a user of an earlier version of SpartaDOS, you should notice that NOTE and POINT now work the same way with Atari DOS disks as they do with SpartaDOS disks. POINT will not use sector number and offset regardless of disk format.

Using NOTE and POINT with SpartaDOS X and an Atari DOS disk may prove to be time consuming since, to determine the relative offset into the file, it is necessary to read the file from the beginning every time a POINT is used. This also causes segmented binary files to take much longer to load from Atari DOS disks than from SpartaDOS disks. NOTE and POINT tables created by other DOS types (including earlier versions of SpartaDOS for files on Atari DOS disks will, of course, no longer be valid.
 

Sparse Files  

On a SpartaDOS diskette, it is possible to point past the end of a file opened in append mode. When data is placed in a file past the end, the file is given the new length, but no physical sectors are used for the space between the old and the new data. In the sector map of the file, the unallocated sectors are represented by a sector number of 0. Should you at any time write to a position in this gap, a sector will be allocated. This gap may not be read, and a file containing gaps may not be copied. An error will occur if either of these is attempted.


Previous page

Next page