Amos Professional Manual  Contents  Index

Disc Access

Sequential files
A sequential file is one that allows you to read your information only in the sequence in which it was originally created. Normally with an Amiga, if you need to change a single item of data in t lie middle of a sequential file, you must call up that file from disc, read the whole file up to and including the item of data you want to alter, change the data and then write the whole file back o the disc.

AMOS Professional lets you have access to sequential files either for reading data, or for writing it, but never for both at the same time. Before the theory is explained, here is some practice. Type in this example, which opens a file called "", allows you to input some data, then closes the file:

E> Open Out 1 ,""
   Input "Please tell me your name ";N$
   Print #1,N$
   Close 1

Now the information stored in that file can be read back, as follows:

E> Open In 1 ,""
   Input #1,N$
   Print "I remember you! Hello ";N$
   Close 1

Every time you want to access a sequential file, it must be opened, then the information can be accessed, then the file must be closed. Those three steps must be done in exactly that order. Here is the list of commands you can use for handling sequential files.

instruction: open a file for output
Open Out channel,filename$

Use this command to open a sequential file, ready for data to be added to its end. Give the channel number and filename, as explained above. If the file already exists, it will be erased.

instruction: add data to an existing file
Append channel,filename$

This works like OPEN OUT, but it allows you to add to your files at any time after they have been defined. If the filename already exists, your new data will be appended to it, in other words it will be added to the end of that file.

instruction: open a file for input
Open In channel,filename$

Use this command to prepare a file so that data may be read from it. If the filename does not already exist, AMOS Professional will report a "File not found" error.

Back    Next