Difference between revisions of "STORE"

From Recital Documentation Wiki
Jump to: navigation, search
(Class)
 
Line 1: Line 1:
 
 
 
==Purpose==
 
==Purpose==
 
Save the result of an expression in a memory variable
 
Save the result of an expression in a memory variable
Line 41: Line 39:
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital Server, Recital  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Commands]]
 
[[Category:Commands]]
 
[[Category:Memory Variables]]
 
[[Category:Memory Variables]]
 
[[Category:Memory Variables Commands]]
 
[[Category:Memory Variables Commands]]

Latest revision as of 16:20, 25 November 2009

Purpose

Save the result of an expression in a memory variable


Syntax

STORE <exp> TO <memvar> [,<memvar>,…]


See Also

:=, AVERAGE, COUNT, PARAMETERS, PRIVATE, PUBLIC, SUM


Description

The STORE command saves the result of the expression <exp> into a memory variable. This is equivalent to the assignment statement:

<memvar>=<exp>

If the memory variable does not exist, then it is created. If the memory variable already exists, its contents are updated. Recital automatically performs type conversions for memory variables. If, for example, an existing memory variable called NAME contains a character string, and the command STORE 10 TO NAME is issued, the memory variable will automatically be converted to a numeric memory variable. Memory variables are normally created with the STORE command, the assignment command '=', the PUBLIC command, or the PRIVATE command. When a program is being executed, Recital gives field variables the 'highest precedence' in expressions. In other words, if a field name in a table is the same as the name of a memory variable, then Recital will take the value of the field variable. To overcome this you can use the special alias name 'm->' or 'm.' to reference the memory variable. You only need to use this notation where an expression can be specified.

Memory variables created with the STORE command are declared PUBLIC if they are created at the '>' prompt, and PRIVATE otherwise. When assigning expressions to memory variables, Recital allows character variables to be added together, full date arithmetic is also supported.

Numeric memory variables may be incremented and decremented by 1 by placing '++' or '--' at the beginning of a command line. The SET DECIMALS and SET FIXED commands can be used to specify numeric accuracy for calculations involving decimal places. The STORE command and the assignment command '=' cannot be used to modify the contents of field variables - the REPLACE command should be used for this purpose. Recital allows any word to be used as a memory variable, but it is strongly recommended that Recital keywords are not used, as any program written in this way is more difficult to read and maintain. Memory variables can be saved in a file by issuing the SAVE TO command and restored with RESTORE FROM. Memory variable files are normal text files containing a series of STORE commands. They can be viewed and modified with MODIFY COMMAND. When Recital detects an error in a program, it will SAVE the active memory variables in a file in the current directory called "error.mem". This file also contains the information that is displayed with the DISPLAY STATUS command, and can be viewed with MODIFY COMMAND to inspect the values of the memory variables at the time the error was detected. The DISPLAY MEMORY command can be used to inspect the current status of memory variables. There is no fixed limit to the number of memory variables that can be declared in Recital. Memory variables that are PRIVATE to a procedure or program are automatically released when the RETURN statement is encountered. The RELEASE command can be used to release memory variables if they are no longer needed. The CLEAR MEMORY command releases all current memory variables.


Example

store "hello " to string1
store string1 + "world" to string2
? string2
hello world
area = length * width
area = "change to a string"


Products

Recital Server, Recital