Hi there
Sequential file techniques provide a straightforward way to read and write files
the best reason for using sequential files is their degree of portability to other programs, programming languages, and computers. Because of this, you can often look at sequential files as the common denominator of data processing, since they can be read by word-processing programs and editors (such as PowerBASIC's), absorbed by other applications (such as database managers), and sent over the Internet to other computers.
The idea behind sequential files is simplicity itself: write to them as though they were the screen and read from them as though they were the keyboard.
Create a sequential file using the following steps:
1. Open the file in sequential output mode. To create a file in PowerBASIC, you must use the OPEN statement. Sequential files have two options to prepare a file for output:
OUTPUT: If a file does not exist, a new file is created. If a file already exists, its contents are erased, and the file is then treated as a new file.
APPEND: If a file does not exist, a new file is created. If a file already exists, PowerBASIC appends (adds) data at the end of that file.
2. Output data to a file. Use WRITE# or PRINT# to write data to a sequential file.
3. Close the file. The CLOSE statement closes a file after the program has completed all I/O operations.
To read a sequential file:
1. First, OPEN the file in sequential INPUT mode. This prepares the file for reading.
2. Read data in from the file. Use PowerBASIC's INPUT# or LINE INPUT# statements.
3. Close the file. The CLOSE statement closes a file after the program has completed all I/O operations.
Answered by
Reeta K
, an ibibo Master,
at
2:38 PM on June 09, 2008