Writing record: – In the random-access file, a full record write into file instead of particular variable. Put statement is used to write a record into random access file. Syntax of the put statement is –

                Put <File Number> [,Record Number] <,Variable Name>

Where file number is the number of a file that has already opened, record number is an integer that indicates which record is to be written. The record number is optional. If is omitted, then the record read will be either the one following the most recent put or get operation, or the record number return by the most recent seek operation. If the record number is specified, only that record write by the put statement. The variable name is the name of variable that contains the data to be written to the file. An example of the put statement is –

                Put 1, 10, MyRec

In case of above example, the put statement write a record named as MyRec at 10th record position. Another example –

                Put 1, ,MyRec

The above example will write a record named as MyRec just after the current record position.

Advertisements