Hardware Reference
In-Depth Information
Figure 6.11 Output produced by the inpout32.dll PowerBASIC for Windows
demonstration program
2
Send data to the file (using PRINT# ).
3
Close the file (using CLOSE# ).
As an example, let's assume that we have an integer array of 32 floating
values, a(), to be stored in a disk file. If the data file is to be called 'TEMP.DAT'
and is to be stored on a floppy disk inserted into drive A:, the following code
can be used in simple DOS BASIC:
REM Save data in disk file
SUB Savedata
SHARED a()
PRINT "Saving data on disk - please wait!"
OPEN "A:TEMP.DAT" FOR OUTPUT AS #1
FORN%=0TO31
PRINT #1, a(n%)
NEXT n%
CLOSE #1
END SUB
The stages required for loading data from a disk file are as follows:
1 Open the file for input (using OPEN ... FOR INPUT ) and include a filename or
complete file specification and an associated channel number for the buffer
which will be used for subsequent operations on the file.
2 Retrieve data from the file (using INPUT# ).
3 Close the file (using CLOSE# ).
The following code can be used to retrieve the data stored by the previous
example, loading it back into array a():
REM Load data from disk file
SUB Loaddata
PRINT "Loading data from disk - please wait!"
OPEN "A:TEMP.DAT" FOR INPUT AS #1
FORn%=0TO31
Search WWH ::




Custom Search