142
Chapter 13: Memory Management
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
For TEXT_VAR_TAG, GDB_VAR_TAG, PIC_VAR_TAG, DATA_VAR_TAG, or
GEN_DATA_TAG the source is not copied but the destination is verified to have
the same data type (TEXT, GDB, PIC, DATA, or OTH). If
SourceSize
is not zero
then the destination is allocated to the given size; it is up to the caller to do the
actual copying of data.
VarStore
may throw the following errors:
ER_DATATYPE, ER_DOMAIN — The value stored is in the wrong domain or of
the wrong type for the variable being stored to.
ER_DIMENSION — Illegal index when storing to a list or matrix.
ER_FOLDER — The variable is a folder, which cannot be
stored to.
ER_ILLEGAL_IN_FUNC — Functions can only store to local variables.
ER_INVALID_VAR_REF — The variable cannot be stored to in the current
mode, see
VarRecall
also.
ER_LOCKED, ER_VAR_IN_USE — The variable is locked or in-use and cannot be
stored to.
ER_MEMORY — Not enough memory to do the store operation.
ER_PROTECTED — The variable cannot be stored to by the current
app in the current mode.
ER_RESERVED — The given variable is a system reserved
variable and the value to be stored is invalid for
this variable.
INVALID_PATHNAME_ERROR — Invalid variable name.
13.3.2.6. General Data Storage
Most of the data that will be stored in a variable will be on the estack or in a
buffer in the heap. To store floating-point data contained in a C variable, use
push_Float
(var) and use
top_estack
as the EStackIndex for
VarStore
. This
automatically rounds the mantissa to 14 digits and adds the float tag. The caller
must remember to restore
top_estack
to its original value.
Example:
BCD16 flt;
const BYTE Name[] = { '\0', 't', 'e', 'm', 'p', '\0' };
EStackIndex old_top = top_estack;
push_Float( flt ); /* round to 14 digits, add float tag */
VarStore( Name+5, STOF_ESI, 0, top_estack );
top_estack = old_top; /* restore original top_estack */
Some variables are system protected. These include programs and functions
(TI
-
BASIC or ASM), data variables, graph databases, third-party data-types