Nascom Newsletter |
Volume 3 · Number 3 · August 1983 |
Page 31 of 37 |
---|
program a line
POKE3360,n
where n represents the disc number – either a constant or a variable.
Before you can load or save data from within a program the name of the file used has to be identified to NAS-DOS. NAS-DOS allows one file name ta be used for input and another for output. It does not allow multiple input or output files, so in applications here several input or output files are to be handled the appropriate ones must be opened before access is attempted. There are three forms of file opening command:
USR(11),FN$ – opens a file for reading.
USR(12),FN$ – opens an existing file for output.
USR(13),FN$ – opens a new output file.
Note that in the case of a new output file the length of this file, in sectors of 256 bytes, should have been set by a POKE3367,n instruction, where n is the number of sectors. If there is insufficient space on the disc for this number of sectors the maximum available space will be used.
FN$ is the file name to be used, and must be a string variable (not an array) of length 8 characters. If the name is less than 8 characters long you MUST include extra spaces in declaring the name – eg
FN$="MIKE "
NAS-DOS returns in the function an indication of whether the file name specified existed – a non-zero result indicates that the file name did not exist. Your program should check this error condition and trap any error before any further file access is attempted.
Note that NAS-DUS organises disc file so that all the contents of a file must be contiguous – ie the file is not divided and spread over the disc. Thus it is possible to delete a lot of small files spread around the disc and have an apparently large amount of disc space available, but as this is not contiguous it may be impossible to create large disc file, even though its size is less than the total free disc space. The disc utilitiy REORG could be used to copy and compress the free space, although in practice this is an extremely rare problem. When files are deleted in NAS-DOS the space occupied by the file itself is freed for future use automatically, although the entry in the directory is merely marked as a deleted file, rather than being removed from the directory. Any deleted files in the directroy are removed by the ]C command of NAS-DOS. This technique can be very useful in sometimes allowing apparently deleted files to be found ane recovered relatively easily from disc if a (user!) program goes berserk and overwrites the directory.
Most disc access commands using the USR function in ROM BASIC,
Page 31 of 37 |
---|