Chapter 8: Integrating a Flash Application
73
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
expression to be evaluated may not store to any global variables, perform any
kind of I/O (displaying values on the Home screen, graphing, and so on), or
cause a switch to another application.
/* Evaluate the expression pointed to by pExpr (must be locked if in
the heap).
*/
SINT CmdLine( char *pExpr )
{ Access_AMS_Global_Variables;
SINT errNo;
SET_SIDE_EFFECTS_FORBIDDEN; // No I/O or programs
TRY
push_quantum( END_OF_SEGMENT_TAG );
push_parse_text( (BYTE *) pExpr );
push_simplify_statements( top_estack );
errNo = ER_OKAY;
ONERR
errNo = errCode;
ENDTRY
SET_SIDE_EFFECTS_PERMITTED;
return errNo;
}
void tCmdLineDriver( void )
{ Access_AMS_Global_Variables;
SINT errNo;
EStackIndex saveTop;
BYTE e1[] = {0,'e','1',0};
char szBuf[256];
memset( szBuf, 0, sizeof(szBuf) );
strcpy( szBuf, "solve(x*x+3x-3=0,x)" );
while (KB_ENTER == Dialog( &dGetStr,-1,-1, szBuf, NULL)) {
saveTop = top_estack;
if (errNo = CmdLine( szBuf ))
ERD_dialog( errNo, FALSE );
else {
DlgNotice( "OK", "Answer stored in 'e1'" );
VarStore( e1+3, STOF_ESI, 0, top_estack );
}
top_estack = saveTop;
}
}
/* Resource for tCmdLineDriver */
DIALOG dGetStr, 0, 0, NoCallBack
{
EDIT, {0, 8, 15}, "", 0, 251, 34
HEADER, {0, 0, 0}, "Enter expression, ESC to exit", PDB_OK, PDB_CANCEL
XFLAGS, {0, 0, 0}, XF_ALLOW_VARLINK | XF_VARLINK_SELECT_ONLY, 0, 0, 0
}
In the CmdLine example above, the SET_SIDE_EFFECTS_FORBIDDEN and
SET_SIDE_EFFECTS_PERMITTED macros can be removed in order to run
TI-BASIC commands. This will cause no problems for an app if the user enters
define or store commands. Or if the app itself issues the commands, it can know