For example:
E> EXAMPLE Read A$: Print A$ Data "I am Main Program Data" Procedure EXAMPLE Read B$: Print B$ Data "I am Procedure Data only" End Proc
READ
structure: read data into a variable
Read list
When READ loads items of information that have been stored in a DATA statement into a list of variables, it uses a special marker to jump to the first item in the first DATA statement of your listing. As soon as that item of data has been read, the marker moves on to the next item in the list.
It must be remembered that the variables to be read must be of exactly the same type as the data held at the current position. If you match up one type of stored data with a different type of variable after a READ command, the appropriate error message will be given. Here is an example of correct matching:
E> N=Rnd(100) Read A$,B,C,D$ Print A$,B,C,D$ Data "Text string",100,N,"AMOS"+"Professional"
RESTORE
structure: set the current READ pointer
Restore Label
Restore LABEL$
Restore Line
Restore number
To change the order in which your data is read from the order in which it was originally stored, you can alter the point where a READ operation expects to find the next DATA statement. The RESTORE command sets the position of this pointer by referring to a particular label or line number, and both labels and numbers may be calculated as part of an expression.
For example:
E> Restore LAST Read A$ Print A$ Data "First" Data "Middle" LAST: Data "Last"
Each Amos Professional procedure has its own individual data pointer, so any calls to the command will apply to the current procedure only.
RESTORE is one of the AMOS Professional programmer's most useful devices to force the computer to select information, depending on the actions of the user. It can be used for educational and business routines as well as adventure and role-playing games.