English, asked by sanudolai00, 6 months ago

Write a sequential file annotation?​

Answers

Answered by laura2020
0

Answer:

sequential file is an ordinary text file. Each character in the file is assumed to be either a text character or some other ASCII control character such as newline. The character is in the character set specified when the file is opened. By default this is the platform-native character set.

Sequential files provide access at the level of lines or strings of text: that is, data that is not divided into a series of records. However, a sequential file is not well suited for binary data, because a number in a sequential file is written as a character string.

Opening sequential files

A sequential file can be opened in one of three modes: input, output, or append. After opening a file, you must close it before opening it in another mode.

The syntax is:

Open fileName [For {Input | Output | Append} ] As fileNumber [Len = bufferSize] [Charset = MIMECharsetName]

Where Input means read-only access to the file, Output means write-only access, and Append means write-only access starting at the end of the file. Access in all three sequential modes is one line at a time. To get an unused fileNumber, use the FreeFile function.

bufferSize is the number of characters loaded into the internal buffer before being flushed to disk. This is a performance-enhancing feature: the larger the buffer, the faster the I/O. However, larger buffer sizes require more memory. The default buffer size for sequential files is 512 bytes.

MIMECharsetName designates the character set. The default is the platform-native character set, except that if a UTF-16 or UTF-8 byte order mark (BOM) is present, the BOM character set is used, and on OS/400® the CCSID is used if a BOM is not present. See MIME charset names for a list of valid MIME charset values.

When you try to open a file for sequential input, the file must already exist. If it doesn't, you get an error. When you try to open a nonexistent file in output or append mode, the file is created automatically.

Writing to sequential files

You can write the contents of variables to a sequential file that was opened in output or append mode using the Print # or Write # statement.

The parameters to Print can be strings or numeric expressions; they are converted to their string representations automatically.

This example writes the contents of Var1 and Var2 (separated by tabs, because of the commas in the statement) to the file numbered idFile.Print#idFile, Var1, Var2

Similar questions