8 File Storage

Storing and Retrieving Programs

Programs are stored into program and data files using STORE and SAVE. Programs are retrieved using LOAD, GET, LINK, or MERGE. The RUN command can also be used to bring previously STOREd and SAVEd programs into memory and begin execution. ( see section , Storing a Program, on page 54)

NOTE: The statements LOAD, GET, LINK, MERGE, {RE-}STORE and [RE-}SAVE can not be executed on the commandline of the IDE. This functions are implemeted in a different way. ( see section , The Integrated Development Environment (IDE), on page 68 )

The STORE Statement

The STORE statement creates a program file and stores the program currently in memory into the program file. A program file has the extension .PROG. The program is stored in an internally coded format, allowing rapid access with LOAD or LOAD SUB. Syntax for the STORE statement is as follows:

STORE file spec [,ProtectCode] [;Option]

As an example, the following program line stores the program currently in memory onto the disk labeled PROGS under the name Life2:

210  STORE "Life2,PROGS"
The volume label need not be included when addressing the default storage device.

ProtectCode
The optional protect code must be specified in order to edit a protected program file or to save a program with password protection. When you load a protected program without the correct password, you will neither be able to edit the program, nor will you be able to store the program. If you give the wrong password, an error message is returned by the LOAD statement. When you specify a ProtectCode for the STORE and RE-STORE statements, the program will be stored protected. Since program protection is not prossible with program formats before Eloquence A.06.00, this will use the new A.06.00 program format.
Option
The Option argument contains either the desired program format or a comma separated list of program file options.
Program compatibility option

This option simply specifies the Eloquence revision, the program format should be compatible to.

Example:

STORE "PrgName";"A.05.01"

Program options

Alternatively, you can specify a comma separated list of options and settings which should be used to store the program file. The following options are currently supported:

 
optionpossible valuesComment
revA.xx.xxEloquence revision
fmtHP260 or "0"Compatible format
 EXT or "1"A.05.01 program format
 TAG or "2"A.06.00 program format

Example:

   STORE "PrgName";"rev=A.05.01"
   STORE "PrgName";"fmt=TAG"
   STORE "PrgName";"fmt=2"
Error Messages

62 - File is protected or wrong protect code specified

66 - You are not authorized to store this program

The RE-STORE Statement

A program file can be loaded into memory and edited, then re-stored into the same file using the RE-STORE statement. Syntax for this statement is as follows:

RE-STORE file spec [,ProtectCode] [;Option]

The LOAD Statement

Programs recorded with STORE are retrieved with the LOAD statement. Syntax for this statement is as follows:

LOAD file spec [,line id] [,ProtectCode]

The LOAD statement erases any program and data in memory and loads the program. Any information stored in common, however, is preserved if the loaded program has a COM statement. If the LOAD statement comes from the keyboard and no line id is specified, control returns to the keyboard after loading. If it comes from execution of a program line in memory, execution begins at the first line of the loaded program. When the line id is specified, however, execution of the loaded program begins at that line.

The program can only be loaded when the right protectcode is provided, otherwise an error 66 occures.

For example, the following program line loads the program in the previous example back into memory and execution then begins with line 20:

220  LOAD "Life2",20

The LOAD SUB Statement

The LOAD SUB statement loads subprograms from a program file to the end of the program currently in memory.

LOAD SUB file spec [,starting line number[,increment] ]

[;starting segment [,last segment] ]

With no optional parameters, LOAD SUB loads all subprograms (both FN and SUB) from the specified program file. The starting segment and last segment parameters can be used to specify certain subprograms in the file. For example, if you wish to load only the third subprogram, specify LOAD SUB;3,3. An error occurs if either value is greater than the number of subprograms in the specified program file.

If the first line number in the subprogram is not greater than the last line of the current program in memory, the subprogram is automatically renumbered. The renumbering starts after the last line of the current program, in increments of ten. Another starting line number can be specified, if desired, but it must be greater than the last number of the current program. Another line-numbering increment can also be specified, if desired.

The SAVE Statement

The SAVE statement creates a special data file and stores the program and any subprograms currently in computer memory into the file. This special data file has the extension .DATA. Syntax for the SAVE statement is as follows:

SAVE file spec [,beginning line id[,ending line id]]

The program is saved as string data, one program line per string. In this way, the file can be read, modified, or rewritten as string data by other programs.

When only the file spec is given, the entire program is saved. If the beginning line id is specified, the program is saved from that number to the end. If both line ids are specified, the program section from the beginning line id through the ending line id is saved.

The following example saves the program currently in memory, beginning with line 30, into a special data file named MONEY on the default storage device:

230   SAVE "MONEY",30
As another example, this program line saves lines 50 through 250 into the special data file Prog1 on a disk named Software:

240   SAVE "Prog1,Software",50,250
NOTE: The words "special data file" refer to a file that contains information on the maximum number of records, the length of records, and the number of records currently in the file.

NOTE: The STORE and LOAD operations are faster than SAVE and GET. STOREd programs are already coded in an internal format, while SAVEd programs must be coded before they can be executed.

The GET Statement

The counterpart of the SAVE statement, the GET statement, returns into computer memory a program saved previously with the SAVE statement. GET will also read into memory any string data file consisting of valid Eloquence statements. Syntax for the GET statement is as follows:

GET file spec[,line id[,line id]]

If no line ids are specified, the GET statement erases any program and data in memory (except that associated with a COM statement), as it loads the specified file. Once the file is in memory, execution begins at the first line of the loaded program.

When one line id is specified, the loaded program is renumbered and executed starting with the specified line id. If a second line id is specified, the loaded program is renumbered starting with the first line id and is executed starting with the second line id. Any lower-numbered lines from a previous program are retained. The numbering remains the same on the storage medium.

Here is an example addressed to the default storage device:

250  GET "MONEY",50
The file MONEY is retrieved and renumbered; any lower-numbered lines already in memory are retained. Execution of the program starts at line 50.

Listed below is another example:

260   GET "Prog1,Software",50,10
This program is also renumbered with any lower-numbered lines being retained. Execution begins with line 10 already in memory.

NOTE: ERROR 18 occurring during a GET, LINK or MERGE operation indicates that a line being entered into memory is too long to be accepted (512 characters maximum).

NOTE: The STORE and LOAD operations are faster than SAVE and GET. STOREd programs are already coded in an internal format, while SAVEd programs must be coded before they can be executed.

The LINK Statement

The LINK statement is identical to the GET statement discussed previously, except that the current values of all variables are retained. Syntax for this statement is as follows:

LINK file spec [,line id [,line id]]

If no line ids are specified, the program is loaded, erasing the current program in memory.

The first line id specifies that the loaded program is to be renumbered and starts with the line number of the specified line. If two line ids are specified, execution begins with the second line specified.

In effect, GET performs a SCRATCH V operation on the new program, whereas LINK performs a CONT (continue) operation, involving no initialization of variables.

NOTE: ERROR 18 occurring during a GET, LINK or MERGE operation indicates that a line being entered into memory is too long to be accepted (512 characters maximum).

The RESAVE Statement

A program stored in a special data file can be loaded into memory and edited. It can then be resaved into the same file using the RESAVE statement. Any data RESAVE will purge and overwrite data already in the specified file.

When no line ids are specified, the entire program is saved. When one line id is specified, the program is saved from that line to the end. When two line ids are specified, that block of lines is saved.

NOTE: The words "special data file" refer to a file that contains information on the length of records, the number of records currently in the file, and the maximum number of records defined for the file.

NOTE: The STORE and LOAD operations are faster than SAVE and GET. STOREd programs are already coded in an internal format, while SAVEd programs must be coded before they can be executed.

The MERGE Statement

The MERGE statement takes program lines from a data (.DATA) file and positions them in memory, either in front of the program currently there, between consecutive lines in the program currently there, or behind the program currently there.

MERGE file spec [,line id [ ,line id ]]

If the first line id is specified, the program lines in the specified file are renumbered beginning with that line. The spacing between renumbered lines remains the same. The second line id specifies where program execution should begin.

To further explain the MERGE statement, suppose you have two files (OLD.DATA and NEW.DATA) and the line numbers in these files are as follows:

OLD.DATA     NEW.DATA
   1            10
   2            20
   3            30
Listed below are three examples using the sample files. Each example shows a different MERGE statement and its result.

GET "OLD"               GET "OLD"               GET "NEW"
MERGE "NEW"             MERGE "NEW",100         MERGE "OLD",21

Result:                 Result:                 Result:
1                       1                       10
2                       2                       20
3                       3                       21
10                      100                     22
20                      110                     23
30                      120                     30
NOTE: ERROR 18 occurring during a GET, LINK or MERGE operation indicates that a line being entered into memory is too long to be accepted (512 characters maximum).


Eloquence Language Manual - 19 DEC 2002