CGV
Common Global String Variables
This string function is used to create and maintain global string variables. Global variables share data among all programs, including public programs, and are not affected by the BEGIN, CLEAR, and START directives.
Syntax
Section titled “Syntax”CGV ( string-value-1 [, string-value-2 ][,ERR=line-ref|,ERC=error-code])string-value- is any string. The "!LIST" option, which is discussed below, can be specified for string-value-1.
line-ref- is the program line number or label to branch to if an error is produced by this function.
error-code- is a programmer-defined error code. Valid values are positive or negative whole numbers.
Remarks
Section titled “Remarks”This function allows you to manipulate a global variable by creating a global variable name, assigning a value, retrieving the current value, or deleting the global variable name. You can also list all defined global variables.
The CGV function is used in an assignment statement to accomplish the global variable operation.
The global variable name is limited to a maximum of 32 characters. If you exceed this limit, an ERR=46 results.
The length of a global variable name plus the length of the variable’s string value is limited to 64,997. The maximum number of global variables is limited to 65,000. If an operation would exceed either of these limits, an ERR=32 results.
To create a new global variable, string-value-1 and string-value-2 must both be specified. String-value-1 specifies the global variable name and string-value-2 specifies the initial string value assigned to the variable. (If a global variable with the same name already exists, it is overwritten with the new string value.) If the first character of the global variable name is an exclamation mark (“!”), the global variable is defined as a protected global variable (protected from certain delete operations). When you create a new global variable, it is added to the end of the global variable storage with the new value assigned.
To change an existing global variable, string-value-1 and string-value-2 must both be specified. String-value-1 specifies the global variable name and string-value-2 specifies the new string value assigned to the variable. If the global variable name did not exist, it is created. When you change an existing global variable, the global variable is repositioned at the end of the global variable storage.
To retrieve the current value of a global variable, string-value-1 must specify the global variable name and string-value-2 is not specified. If the global variable name does not exist, an ERR=49 results.
To delete an existing global variable, string-value-1 must specify the name of one of the following delete operations.
- The !CLEARALL delete operation removes all unprotected global variables. Do not specify string-value-2. If string-value-2 is specified, an ERR=49 results.
- The !CLEAR delete operation removes a protected or unprotected global variable name specified in string-value-2. This is the only delete operation that can remove a protected global variable. If string-value-2 is not specified or specifies a nonexistent global variable, an ERR=49 results.
- The !CLEARTO delete operation removes the unprotected global variable specified in string-value-2 and all other unprotected global variables created or changed since the last operation on the specified global variable. (It deletes unprotected global variables from the global variable storage starting at the latest global variable and going back to the specified global variable.) If string-value-2 is not specified or specifies a nonexistent global variable, an ERR=49 results. If string-value-2 specifies a protected variable, the system automatically uses the next most recent unprotected global variable.
To list all of the current global variables, specify “!LIST” for string-value-1. Each name will be retrieved in chronological order. Names will be separated by the $00$ character.
Examples
Section titled “Examples”LET A$ = CGV ("CUST","709")creates a global variable named CUST and assigns it the value “709”. The value “709” is also assigned to A$.
LET A$ = CGV ("CUST","805")changes the value in the CUST global variable to “805”. The value “805” is also assigned to A$.
LET A$ = CGV ("CUST")assigns A$ the current value of the CUST global variable.
LET A$ = CGV ("!CUST",C$)creates a protected global variable named !CUST and assigns it the value in C$. The value in C$ is also assigned to A$.
LET A$ = CGV ("!CLEAR","INVENTORY_NUM")deletes the global variable named INVENTORY_NUM. A$ is used as a dummy variable; a null string is returned to A$.
LET A$ = CGV ("!CLEAR","!VENDOR")deletes the protected global variable named !VENDOR. A$ is used as a dummy variable; a null string is returned to A$.
LET A$ = CGV ("!CLEARALL")deletes all unprotected global variables (!CUST is not deleted). A$ is used as a dummy variable; a null string is returned to A$.
LET A$ = CGV ("!CLEARTO","CUST")deletes all unprotected global variables starting at the latest global variable and going back to and including the CUST global variable. A$ is used as a dummy variable; a null string is returned to A$.
See also
Section titled “See also”LET directive
From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF