SAVE

From C64-Wiki
Jump to: navigation, search
BASIC keyword
Keyword: SAVE
Abbreviation: S Shift+A
Type: Command
Token code: 148/$94
Handling routine
in BASIC ROM:
57686–57700
$E156–E164
List of all BASIC keywords


Remark: This article describes the BASIC-Command SAVE in BASIC V2 at the Commodore 64.

Typ: Statement
General Programming-Syntax: SAVE ["<filename>"] [,<device number>] [,<secondary number>]

A written BASIC or computer code program, which exists in temporary RAM-memory, can be saved with the BASIC command SAVE permanently to a storage device such as a datasette, diskdrive or harddisk as a filetype program (PRG). The Command SAVE can also be used in BASIC programs.

For saving programs on diskdrive or harddisk, a filename must be entered; however, a filename isn't required for saving on datasette. For finding of files faster and easier on datasette, it is useful to use filenames when saving programs. Programs which are saved on datasette will be saved twice. This is used for VERIFYING (look VERIFY).

The device number specifies the attached storage device:

  • datasette (device number 1)
  • diskdrives (device numbers 8-11, optional first diskdrive 8, second diskdrive 9, etc.)

If a device number isn't provided, the default will be 1 (datasette).

The secondary number determines how the program is saved:

0 The program will be saved as BASIC program
1 The program will be saved absolute. Needed for computer code programs.
2 Is only needed with the datasette for writing the "end of tape" (EOT) marker.

If a secondary number isn't provided, the default will be 0.

If the filename already exists on disk, the save command will not work even though no error is indicated on screen. To do a "save and replace", prefix the filename with "@0:" (example below).

To ensure that the current program was correctly saved, use the VERIFY statement.

Examples[edit]

SAVE
(anonymous writing as BASIC program on a datasette)
SAVE "FILENAME",1
(save as BASIC program with filename on datasette)
SAVE FILE$,1,2
(save as BASIC program with charstring FILE$ on datasette with marker "end of tape")

SAVE "DATEINAME",9,1
(save a program with filename on secondary diskdrive 9 absolute)
SAVE "@0:FILENAME",8
(save BASIC program as FILENAME to disk, replacing file if it already exists.)


10 REM tool at tape / cassette
20 SAVE "THISPROGRAMM",8: REM SAVING ON DISK
30 REM the program continued 
BASIC V2.0 (second release) Commands

ABS | AND | ASC | ATN | CHR$ | CLOSE | CLR | CMD | CONT | COS | DATA | DEF | DIM | END | EXP | FN | FOR | FRE | GET | GET# | GOSUB | GOTO | IF | INPUT | INPUT# | INT | LEFT$ | LEN | LET | LIST | LOAD | LOG | MID$ | NEW | NEXT | NOT | ON | OPEN | OR | PEEK | π  |POKE | POS | PRINT | PRINT# | READ | REM | RESTORE | RETURN | RIGHT$ | RND | RUN | SAVE | SGN | SIN | SPC | SQR | STATUS/ST | STEP | STOP | STR$ | SYS | TAB | TAN | THEN | TIME/TI | TIME$/TI$ | TO | USR | VAL | VERIFY | WAIT