72
Chapter 8: Integrating a Flash Application
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
if (hCommand = HeapAlloc(80)) {
strcpy(pCommand = HeapDeref(hCommand), ProgName );
strcat(pCommand, "()" );
if (hResult = TIBASIC_run(hCommand, &errCode))
HeapFree(hResult);
HeapFree(hCommand);
if (errCode) {
ERD_dialog( errCode, FALSE );
return(FALSE);
}
}
return TRUE;
}
void DelVar( char *varName )
{
BYTE nameBuf[MAX_SYM_LEN];
TRY
if (FS_OK == TokenizeName( varName, nameBuf ))
cmd_delvar( TokNameRight(nameBuf) );
ONERR
ENDTRY
}
static void AP_app(pFrame self, PEvent e)
{
HANDLE hVal;
switch (e->command) {
case CM_ACTIVATE:
if (!runningBASIC) {
push_quantum( END_TAG );
EV_defaultHandler(e);
if (StoProg( "prog1", prog1Data ))
RunProg( "prog1" );
DelVar( "prog1" );
EV_quit();
}
break;
case CM_QUIT:
break;
default:
EV_defaultHandler(e);
break;
}
}
The previous example showed how to run a TI-BASIC program from an
application. If an application just needs to execute a function or expression to
return some value then the following example will do that. The function
tCmdLineDriver below inputs a string from the user using a dialog box. It then
calls the function CmdLine to execute that string and return a value. The return
value is stored to a global variable, E1. If there is an error then an error dialog is
displayed. The CmdLine function will evaluate the string and return a value on
the estack. It will not evaluate anything that has side effects — that is the