SAVE

BASin

SAVE

Statement/Command

SAVE sends a program to a file in order to store it for later retrieval.

How to use SAVE

SAVE is normally used as a direct command but may form a statement in a program. It is followed by a filename which is a string value, for example

SAVE "filename"

The filename may contain up to ten characters. Specifying an empty or null ("") filename will bring up a windows requester to prompt you for a filename. On execution, the message

Start tape, then press any key

is displayed. On pressing any key, the program is saved to a file, and on conclusion, the report 0 Ok, 0:1 appears.

Automatic running

If the stored program is to run automatically on loading, then SAVE should be used in conjunction with LINE. The program name is followed by LINE and a numeric value, for example

SAVE "filename" LINE 1

The value following LINE is rounded down if necessary, and should then be either 1 or the number of a line in the program. The program is then sent to the file in the same way as a normal SAVE. On loading, the program starts automatically from the line having defined the line number or, if no such line exists, from the next line in the program. In practice, using LINE 1 causes the whole program to run automatically.

Note that an auto-running program will not clear variables or the screen (effectively, the program uses a GO TO instead of a RUN to start the program).

SAVE and the silicon disc

SAVE can also be used to store a file on the 128k Spectrum's silicon disc. To do this, insert a ! character between the keyword SAVE and the filename, for example

SAVE !"udgs" CODE USR "A",21*8

You can use any of the commands used with SAVE such as CODE, DATA or SCREEN$.

The silicon disc stores just under 64kb of data, and is very useful for rapid access to stored information which would otherwise take up too much memory.

Saving other types of data

SAVE can also store other types of data - sections of memory and variable arrays can be stored, and SAVE also has a special command to save the screen display. See SAVE CODE, SAVE DATA, and SAVE SCREEN$ for further information

Format

  • SAVE string-expr [LINE int-num-expr]

See also

Chapter 20.

  • 128k Commands in BASin