Skip to content

BASIC SAVE Statement

Sean P. Harrington edited this page Apr 1, 2024 · 5 revisions

SAVE

TYPE: USB BASIC disk statement


FORMAT: SAVE filespec

Action: Saves tokenized BASIC program in BAQ format to SD card.

  • filespec is a string expression containing an optional path and the full file name.

Examples:

SAVE "demo.baq"

Saves BASIC program file demo.baq from memory into current directory.

SAVE "/subdir/prog.baq"

Saves BASIC program file prog.baq from memory into subdirectory subdir.

SAVE "/main.baq"

Saves BASIC program file main.baq from memory into root directory.


FORMAT: SAVE filespec , ASC

Action: As above, but saves untokenized BASIC program to ASCII text file.

Examples

SAVE "source.bas",ASC

De-tokenizes BASIC program from memory and saves to ASCII file source.bas in current directory.


FORMAT: SAVE filespec , CAQ

Action: As above, but saves program in BAQ format even if SET SAVE ASCII ON is active.

  • The program in memory will save to a text file containing a human-readable BASIC program in ASCII format.

Examples

SAVE "source.baq",CAQ


FORMAT: SAVE filespec , TOK

Action: As above, but saves program as tokenized file without CAQ header.

Examples

SAVE "source.bas",TOK


FORMAT: SAVE filespec , * arrayvar

Action: Saves a BASIC array to a file on the SD card.

  • filespec is a string expression containing an optional path and the full file name.
  • arrayvar is the array variable name with no subscripts.
    • The array must be a numeric array.
      • Type mismatch results if a string array is specified/
      • The array must be explicitly declared with a DIM statement before saving it.
      • An array contains binary data with a length of 4 times the total number of elements bytes.

Examples:

DIM A(99)
SAVE "data.arry",*A

Saves contents of numeric array A() from memory to file data.arry to SD card.

DIM G$(2,12)
SAVE "text.arry",*G$

Saves contents of string array G$() from memory to file text.arry to SD card.


FORMAT: SAVE filespec , address, length

Action: Saves contents of memory to binary file on SD card into memory.

  • filespec is a string expression containing an optional path and the full file name.
  • address is the starting location in memory that the file will be saved from.
  • length is the number of bytes to save.

Example: SAVE"capture.scr",12288, 2048

Saves the SCREEN/COLOR RAM to a file named capture.scr on the SD card.


FORMAT: SAVE filespec , @page , address, length

Action: As above, but loads the file into paged memory.

  • page is a number in the range 0 through 255 that specified the memory page to save the file from.
  • address is a number in the range 0 through 16383 that specified the starting address in the page.
  • length is the number of bytes to save.
Clone this wiki locally