Nascom Newsletter |
August 1983, Volume 3, Number 3 |
|
|
|
Page 32 of 37 |
|
|
|
---|
including the fle opening commands described above, require additional variable names to specify the data (or filename) to be saved “or loaded. There are a number of significant restrictions associated with these names in ROM BASIC. Again you should realise that these are associated with the simple BASIC Routine Handler incorporated within NAS-DOS for use with the ROM BASIC. These restrictions are not inherent in NAS-DOS itself, and the Extended BASIC, XBASIC, for example, incorporates ore sophisticated transfer of data between files and variables which are not subject to these restrictions. The main restrictions are as follows:
1. Only simple character strings may be loaded or saved. Numbers! mist be converted using the STRS and VAL functions before/after disc access. The variable cannot be an. array element. Thus if you have a 20 element numeric array AC) which you wish to store on disc you would need to use lines of the fora
100 FOR I=1 10 20 110 AS= STRSCACI)) 120 ASUSR(32) , As 130 NEXT
to save the elements in character string form.
2. While more than one string can be loaded/saved in a single USR( ) statement the strings are stored directly on disc with no separator between them, although after each disc write statement an’ end-of-record character (OD hex) is output to disc Therefore in order to read back the data where more than one item has been stored ina record the strings must be of known fixed length otherwise the disc read statement will not be able to determine where one string ends and the next begins. Where the length of the string 18 variable you will need to fix the length by padding it out to the requied length with additional spaces. Note that this applies where more than one variable 18 read/weitten in a single USK call – if only one variable is referenced each time NAS-DOS will use the end-of-record separator which is put in the file after each disc write Statement to determine where data which ix being read terminates.
These limitations do not affect XBASIC, which allows almost any type of variable to be read or written see the XBASIC. manual for more detasis on this.
There are essentially tho different types of data file which can be saved on disc – at least using NAS-DOS. These are knows as Sequential files and randoa files. We will describe sequential files here and introduce random files. next moath we will describe random files in more detail.
Sequential files are very comparable with gata written onto magnetic tape. Generally to get any item on the file. you. must Start. from the beginning and read (or write) each item in turn until you get to the required point. If you are writing the file you “must then wite any remaining data. Because the end=
This is an OCR’d version of the scanned page and likely contains recognition errors.
|
|
|
Page 32 of 37 |
|
|
|
---|