Skip to content

PSAVE

Protected Save

This directive writes the current contents of program memory to a file on a disk using a password to encrypt the program file, prohibiting a programmer from LISTing any program line number or labels past line 00100. This encryption does not impair program execution. The program file can be made LISTable by LOADing with the proper password.

[P]SAVE [program-name [, size, disk-num, sector-num]]
[,ERR=line-ref|,ERC=error-code] [, PWD=passwd]
P
is the optional designator for a password protected SAVE.
program-name
is any string of 8 characters or fewer used to name the program and its program file.
size
is an integer in the range of 1 to 5,242,880 (5*1024*1024) specifying the size of the program (number of bytes).
disk-num
specifies the logical disk directory that contains this file. Valid values are 0 through 35.
sector-num
is a required parameter. The only valid value is 0.
line-ref
is the program line number or label to branch to if this directive produces an error.
error-code
is a programmer-defined error code. Valid values are positive or negative whole numbers.
passwd
is any string in the range of 4 to 8 characters in length. This parameter is not allowed without the optional P for password SAVE (PSAVE). This parameter is case sensitive; uppercase characters are different from lowercase characters.

PWD=passwd generates a syntax error (ERR=20) if used with SAVE instead of PSAVE.

ERR=line-ref does not cause a syntax error if used in Thoroughbred Basic Console Mode, but has no meaning unless used in Thoroughbred Basic Run Mode.

If an attempt is made to LIST a program that was previously PSAVEd and then LOADed without using PWD=passwd, an ERR=18 results if the program contains program line numbers above line number 00100.

If a PSAVE directive is used to save a program but the PWD=passwd clause is not specified, the program is never LISTable beyond program line number 00100 but LOADs and RUNs as if no encryption were used.

[P]SAVE does not require size, disk-num, and sector-num if the program file was previously defined by either a PROGRAM directive or a previous [P]SAVE using size, disk-num, and sector-num.

An attempt to use [P]SAVE when the program file already exists on an available logical disk directory generates an ERR=12.

An attempt to use [P]SAVE without size, disk-num, and sector-num when the program file does not already exist on an available logical disk directory generates an ERR=12.

The PSAVE directive looks up labels and element names and converts them into permanent locations. If you modify a program or format after issuing a PSAVE directive, the locations may change. Before you run the program, you must use the PSAVE directive so that Thoroughbred Basic can find and use the labels or element names.

PSAVE PWD="PASSWORD"

saves the program currently in memory using the PGN system variable for program-name, replacing the current copy on disk and encrypting the program with a password of “PASSWORD”.

PSAVE "TEST"

saves the program in memory into the program file space previously defined for the file “TEST” with a permanent encryption that does not allow LISTing of any program line above 00100.

PSAVE PROGRAM_NAME$, 100, 2, 0, ERR=7999, PWD="noname"

If PROGRAM_NAME$ = “TEST1”, the program in memory is placed in logical disk directory number 2 for 256 bytes (even though 100 is specified), under the name TEST1, starting at the next available sector that has sufficient space to contain this program file, encrypted with the password noname. If this statement generates an error it branches to line 7999.

PSAVE PGN, PSZ, 2, 0, ERR=7999, PWD=PASSWORD$

If the system variable PGN (program name) contains TEST1, the system variable PSZ (program size) is 100, and PASSWORD$ contains noname. This statement performs the same operation described in the previous example.

ENCRYPT and SAVE directives
PGN and PSZ system variables

From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF