02-19-2008 4:54 PM
hi all
what is the pseudo logic for reading and writing sequential files
02-29-2008 8:36 PM
Hi,
the pseudologic for opening and writing sequential files is :
To open a file, you use the statement
OPEN DATASET <file name> FOR <options> IN <TEXT/BINARY MODE.>
FOR options:
-
1) For output
Opens the file for writing. If the file already
exists, its contents are deleted, but this applies only after the end of the program. If the statement occurs in a program, the cursor is simply positioned at the beginning of the file. You must then specify CLOSE DATASET in order to delete the file. If the file does not exist, it is generated.
2) For input
Opens an existing file for reading. If the file is already open, the cursor is positioned at the beginning of the file. You do not have to specify FOR INPUT explicitly.
3) For appending
Opens the file for writing at the end of the file. If the file does not exist, it is generated. If the file is already open, the cursor is positioned at the end.
IN options:
-
1) In Binary mode
The data is not interpreted by the read and write operations READ DATASET and TRANSFER. The data areas specified for these key words are input or output directly. You dont have to specify IN BINARY MODE explicitly.
2) In text mode
If you open a file with this option, the system assumes that the file has a line structure. Each time READ DATASET or TRANSFER is executed, one line is always input or output and the data is always processed up to the end-of-line selection. If the data area is too large for the line that is read, the remaining area is padded with blanks. If it is too small, the end of the line is lost.
You can transfer the records into a sequential file using TRANSFER command.
Each TRANSFER statement transfers one data record to a sequential file.
CLOSE DATASET<file name>
You use this statement to close a sequential file explicitly.
Reward points if you find it useful.
Regards,
chandrasekhar