How can I execute TI-Basic programs or statements from C?

Previous TI-Basic and C Next

Q: Is there any way to execute a file (i.e. another ASM or TI-Basic program) from a C program?
A: There are a lot of methods for doing this. The most obvious method to do this is usage of a function like this one:
void progrun(const char *name)
{
  char fname[25];
  HANDLE h;
  strcpy (fname, name);
  strcat (fname, "()");
  push_parse_text (fname);
  h = HS_popEStack ();
  TRY
    NG_execute (h, FALSE);
  FINALLY
    HeapFree (h);
  ENDFINAL
}
The usage of it is straightforward, for example:
progrun ("testprog");
Note that the program you call may throw errors. If you understand this function, you can easily expand it to accept arguments, etc. Principally, using NG_execute you can execute any particular sequence of TI-Basic statements.


See also: How can I create a program that is bigger than 24K and works on AMS 2.xx?