Appendix A: System Routines — Symbol Table Utilities
1031
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
SymAdd
Declaration:
HSYM
SymAdd
(const BYTE *
SymName
)
Category(ies):
Symbol Table (low-level)
Description:
Add the given symbol name to the symbol table and return an HSYM to the
new symbol table entry. If the symbol already exists and it has a value, that
value will be deleted (unless it is a folder name, then NULL is returned).
Inputs:
SymName
— Pointer to tokenized symbol name.
Outputs:
HSYM of newly created symbol or zero if not enough memory.
May throw an ER_LOCKED error if the symbol already exists and is locked.
Assumptions: VarStore
or the file system are normally used to create symbols.
Side Effects:
May cause heap compression.
NOTE:
This routine does not check for reserved symbols and so caution must be used
when using this routine.
Availability:
All versions of the TI
-
89 / TI
-
92 Plus.
TI
-
89 / TI
-
92 Plus
Differences:
None
See Also: SymDel, VarStore, FOpen
Example:
Access_AMS_Global_Variables;
BYTE foldName[] = {0,'t','m','p','1',0};
BYTE symName[] = {0,'s','y','m','1',0};
BCD16 fNum = 1.234;
HSYM hsym1;
if (FolderFind(foldName+5) == FL_NOTFOUND) {
if( !FolderAdd( foldName+5 ))
ER_throw( ER_MEMORY );
}
FolderCur( foldName+ 5, TRUE );
if (hsym1 = SymAdd( symName+5 )) {
push_Float( fNum );
VarStore( symName+5, STOF_ESI, 0, top_estack ); /* give it a value */
/* HSYMs better match! */
if (hsym1 != SymFind(symName+5))
ER_THROW( FIRST_INTERNAL_ERR );
handleVarLinkKey(SDT_ALL); /* show new symbol */
/* hsym1 is now invalid since user can add/delete variables in VAR-LINK */
if (!SymDel( symName+5 ))
DlgNotice( NULL, "You deleted tmp1\\sym1 in VAR-LINK" );
}