The <bascmd.h> header file


  
This header file is quite incomplete and a bit unconsistent. In the near future it will contain about 100 new functions. I started to develop this header file, but the shortage of my free time forces me to stop developing for a while. I don't want to prolongue releasing of whole TIGCCLIB only because this header file is not complete. Be patient, I will continue developing it as soon as possible...


This header file contains the following functions:
cmd_clrdraw          cmd_clrgraph         cmd_clrhome          cmd_clrio
cmd_clrtable         cmd_custmoff         cmd_custmon          cmd_disp
cmd_dispg            cmd_disphome         cmd_disptbl          cmd_fnoff
cmd_fnon             cmd_graph            cmd_input            cmd_inputstr
cmd_get              cmd_getcalc          cmd_newprob          cmd_output
cmd_pause            cmd_printobj         cmd_prompt           cmd_rclgdb
cmd_send             cmd_sendcalc         cmd_sendchat         cmd_stogdb
cmd_style            push_getkey          push_getmode         push_setgraph
push_setmode         push_settable        push_switch
and the following predefined types:
ESI
NOTE: All functions from this header file get parameters from the expressions stack, so this header file must be use in conjecture with estack.h. You need to learn about usage of the expressions stack before using any function from this header file. All functions defined here (including functions which will be implemented in the near future) execute particular TI-Basic commands or functions. They sometimes may be useful to perform some operations which can not be easily implement in C. But note that if you use functions from this header file too much, you will degrade the performance of your program significantly. In an extreme case, it will in fact reduce to a TI-Basic program! So use functions from this header file only if it is really necessary. Also note that these functions acts exactly like appropriate TI-Basic commands (including throwing errors if something is wrong), so usage of error traping mechanism from error.h header file is highly recommended.

Functions


void cmd_disphome (void);

Executes TI-Basic DispHome command.

cmd_disphome displays the current content of the Home Screen window. More precise, it starts the Home application if it is not already running, and makes sure the Home Screen window is being displayed switching from the Program I/O window if necessary. The OS will deactivate or terminate the current application to activate the Home Screen.

NOTE: If you used any function from this header file which displays various windows which are different than Home Screen window (for example, TI-Basic Program I/O Screen window), use cmd_disphome before returning from your program to activate the Home Screen again!

void cmd_clrhome (void);

Executes TI-Basic ClrHome command.

cmd_clrhome clears all items stored in the Home Screen history area and clears Home Screen window. Also resets all suffixes of any arbitrary constants or integers (like @1, @n2 etc.) to 1.

void cmd_clrio (void);

Executes TI-Basic ClrIO command.

cmd_clrio clears the TI-Basic Program I/O Screen window (without displaying it to the screen), and sets the Program I/O Screen window cursor position to the upper left corner.

void cmd_clrdisp (ESI ExprList);

Executes TI-Basic Disp command.

cmd_disp first displays the current content of the TI-Basic Program I/O Screen window. If ExprList points to the END_TAG, cmd_disp does nothing more. Else, the expression (or string, if ExprList points to the STR_TAG) pointed to by ExprList is displayed on the TI-Basic Program I/O Screen window. This task is repeated for all expressions on the expressions stack below ExprList, until END_TAG is reached. Each expression (or character string) is displayed on a separate line of the TI-Basic Program I/O Screen window. If "Pretty Print" in current calculator mode settings is turned to ON, expressions are displayed in pretty print.

void cmd_inputstr (ESI PromptAndVar);

Executes TI-Basic InputStr command.

If PromptAndVar points to an expression which evaluates to a string (usually at STR_TAG), cmd_inputstr first displays the current content of the TI-Basic Program I/O Screen window, pauses the program, displays the prompt string pointed to by PromptAndVar on the Program I/O Screen, waits for the user to enter a response, and stores the response in a TI-Basic variable which name is given on the expressions stack just below the expression pointed to by PromptAndVar. This is ilustated in the following example, which accepts your name in a TI-Basic variable named "x":
push_quantum (VAR_X_TAG);
push_string ($(Enter your name:));
cmd_inputstr (top_estack);
If PromptAndVar points directly to a variable tag, "?" is displayes as a prompt.

NOTE: cmd_inputstr is not recommended way for inputing data from the keyboard into the program. It is limited to the TI-Basic Program I/O Screen window, and it stores the result in TI-Basic variables, which is not so useful in C programs (i.e. you need to import the value of a TI-Basic variable into the program, which is not so straightforward). See FAQ list for explanation of much better ways to enter data from the keyboard.

void cmd_input (ESI PromptAndVar);

Executes TI-Basic Input command.

If PromptAndVar points to END_TAG, cmd_input pauses the program, performs cmd_dispg, and lets the user update system coordinates xc and yc (also rc and theta_c for polar coordinate mode) by positioning the graph cursor.

If PromptAndVar points to an expression or to a variable tag, cmd_input works exactly like cmd_inputstr, but it treates the user response as an expression instead of a string (cmd_inputstr always stores the response as a string).

void cmd_newprob (void);

Executes TI-Basic NewProb command.

cmd_newprob performs a variety of operations that let you begin a new problem for a cleared state without resetting the memory. It clears all single-character (a-z) TI-Basic variables in the current folder (unless the variables are locked or archived), turns off all functions and stat plots in the current graph mode, clears error flag, and performs cmd_clrdraw, cmd_clrgraph, cmd_clrhome, cmd_clrio and cmd_clrtable.

void cmd_output (ESI Row, ESI Column, ESI Expr);

Executes TI-Basic Output command.

cmd_output first displays the current content of the TI-Basic Program I/O Screen window. Then, the expression (or string, if Expr points to the STR_TAG) pointed to by Expr is displayed on the TI-Basic Program I/O Screen window at the TI-Basic text coordinates determined by expressions (usually numbers) pointed to by Row and Column. If "Pretty Print" in current calculator mode settings is turned to ON, expressions are displayed in pretty print.

void cmd_pause (ESI Expr);

Executes TI-Basic Pause command.

cmd_output suspends program execution (it resumes when you press ENTER). If Expr points to END_TAG, cmd_output does nothing more. But, if Expr points to an expression, it displays the current content of the TI-Basic Program I/O Screen window and displays the expression pointed to by Expr at the current TI-Basic text coordinates. If "Pretty Print" in current calculator mode settings is turned to ON, expressions are displayed in pretty print. If the result of the expression is too big to fit on a single screen, you can use the cursor pad to scroll the display.

void cmd_prompt (ESI VarList);

Executes TI-Basic Prompt command.

cmd_prompt assumes that VarList points to a variable tag. It displays the current content of the TI-Basic Program I/O Screen window, then displays a prompt on the Program I/O Screen for the variable pointed to by VarList, using its own name as the prompt (with question mark appended after the name). Then, it waits for an user response, and stores the entered expression in the corresponding variable. This task is repeated for all entries on the expressions stack below VarList, until END_TAG is reached.

void cmd_clrdraw (void);

Executes TI-Basic ClrDraw command.

cmd_clrdraw clears the Graph Screen window and resets the Smart Graph feature so that the next time the Graph Screen is displayed, the graph will be redrawn.

void cmd_clrgraph (void);

Executes TI-Basic ClrGraph command.

cmd_clrgraph clears any functions or expressions that were graphed with the TI-Basic Graph command (or cmd_graph command from this header file), or were created with the TI-Basic Table command (or cmd_table command from this header file). Any previously selected functions in the "Y= Editor" will be graphed the next time that the graph is displayed.

void cmd_clrtable (void);

Executes TI-Basic ClrTable command.

cmd_clrtable clears all table values. Applies only to the ASK setting on the Table Setup dialog box. See TI-Basic manual for more info.

void cmd_dispg (void);

Executes TI-Basic DispG command.

cmd_dispg displays the current content of the Graph Screen window, and switches the current application to "Graph" (see events.h header file for more info about application switching).

void cmd_disptbl (void);

Executes TI-Basic DispTbl command.

cmd_dispg displays the current content of the Table Screen window, and switches the current application to "Table" (see events.h header file for more info about application switching). Also stops the execution of the program and accepts all keypress events of the "Table" application, until ENTER key is pressed (after this, the program execution will be resumed).

void cmd_fnoff (ESI IntList);

Executes TI-Basic FnOff command.

If IntList points to END_TAG, cmd_fnoff deselects all Y= functions for the current graphing mode (note that in split-screen, two-graph mode, cmd_fnoff only applies to the active graph). If IntList points to an expression which evaluates to an integer in a range from 1 to 99, cmd_fnoff deselects the specified Y= function for the current graph mode, and repeats this task for all expressions on the expressions stack below IntList, until END_TAG is reached.

void cmd_fnon (ESI IntList);

Executes TI-Basic FnOn command.

If IntList points to END_TAG, cmd_fnon selects all Y= functions that are defined for the current graphing mode (note that in split-screen, two-graph mode, cmd_fnon only applies to the active graph). If IntList points to an expression which evaluates to an integer in a range from 1 to 99, cmd_fnon selects the specified Y= function for the current graph mode, and repeats this task for all expressions on the expressions stack below IntList, until END_TAG is reached. In 3D graphing mode, only one function at a time can be selected.

void cmd_graph (ESI ExprEtc);

Executes TI-Basic Graph command.

cmd_graph graphs the requested expressions/functions using the current graph mode. This function uses the Smart Graph feature (see TI-Basic manual). It expects the following layout of the expressions stack before calling (ExprEtc should point to the last item):

Graph modeRequested layout on the expressions stack
Function graphingEND_TAG var_name expression
Parametric graphingEND_TAG var_name y_expression x_expression
Polar graphingEND_TAG var_name expression
3D graphingEND_TAG y_var_name x_var_name expression

Sequence and Diff Equations graphing is not possible using this command. Variable names are optional, i.e. they may be omitted. In such cases, default variable names are used (x for function graphing, t for parametric graphing, theta for polar graphing, and x and y for 3D graphing). For example, to graph function sin(t)+sin(2t) in respect to t (assuming that the current graph mode is set accordingly), you should to do:
push_quantum (VAR_T_TAG);
push_parse_text ("sin(t)+sin(2t)");
cmd_graph (top_estack);
Or, you can avoid push_parse_text by transforming the expression into the RPN manually (which is very easy):

static unsigned char rpn[] = {END_TAG, VAR_T_TAG, VAR_T_TAG, SIN_TAG,
  VAR_T_TAG, 2, 1, POSINT_TAG, MUL_TAG, SIN_TAG, ADD_TAG};
cmd_graph (rpn + sizeof(rpn) - 1);
All expressions entered using cmd_graph are remembered and assigned increasing function numbers starting with 1. The currently selected Y= functions are ignored. Use cmd_clrgraph to clear these functions (they will also be cleared after you go to the Y= Editor to re-enable the system Y= functions).

void cmd_stogdb (ESI Var);

Executes TI-Basic StoGDB command.

cmd_stogdb creates a Graph database (GDB) variable with name pointed to by Var (it should point to the variable tag) that contains the current Graphing mode, Y= functions, Window variables, Graph format settings, 1- or 2-Graph setting (split screen and ratio settings if 2-Graph mode), Angle mode, Real/complex mode, Initial conditions for Sequence and Diff Equations mode, Table flags, tblStart, Delta_tbl and tblInput system variables. These items are saved for both graphs in 2-Graph mode. You can use cmd_rclgdb to restore the graph environment later.

NOTE: As the variable tag is in fact terminating zero byte of the variable name, the result of the macro constructor $ defined in vat.h header file may be passed directly as the argument of this command. See SymFind and other functions from vat.h header file for more info.

void cmd_rclgdb (ESI Var);

Executes TI-Basic RclGDB command.

cmd_rclgdb restores all settings stored in the Graph database variable pointed to by Var (it should point to the variable tag). See cmd_stogdb for more info.

NOTE: As the variable tag is in fact terminating zero byte of the variable name, the result of the macro constructor $ defined in vat.h header file may be passed directly as the argument of this command. See SymFind and other functions from vat.h header file for more info.

void cmd_style (ESI EqnNum, ESI StyleString);

Executes TI-Basic Style command.

cmd_style sets the system graphing function determined by EqnNum in the current graph mode to use the graphing property determined by StyleString. EqnNum must point to an expression which evaluates to an integer in a range from 1 to 99, and the corresponding graph function must already exist. StyleString must point to a string expression which evaluates to one of the following strings: "LINE", "DOT", "THICK", "ANIMATE", "PATH", "ABOVE", "BELOW", "SQUARE". Note that some settings are not valid in various graph modes. The following table shows valid style names for particular graph modes:

Graph modeValid styles
FunctionLINE, DOT, THICK, ANIMATE, PATH, ABOVE, BELOW, SQUARE
Parametric/PolarLINE, DOT, THICK, ANIMATE, PATH, SQUARE
SequenceLINE, DOT, THICK, SQUARE
3Dnone
Diff EquationsLINE, DOT, THICK, ANIMATE, PATH, SQUARE

void cmd_getcalc (ESI Var);

Executes TI-Basic GetCalc command.

cmd_getcalc receives a variable (or program) pointed to by Var (it should point to the variable tag) from the link interface. This function does nothing more than calling function getcalc from link.h header file.

NOTE: As the variable tag is in fact terminating zero byte of the variable name, the result of the macro constructor $ defined in vat.h header file may be passed directly as the argument of this command. See SymFind and other functions from vat.h header file for more info.

void cmd_sendcalc (ESI Var);

Executes TI-Basic SendCalc command.

cmd_sendcalc sends a variable (or program) pointed to by Var (it should point to the variable tag) to the link interface, where another unit linked to the link port can receive the variable value. This function calls function sendcalc from link.h header file. If you send a variable from a TI-89 or TI-92 Plus to a TI-92, an error occurs if the TI-92 executes GetCalc command from TI-Basic. In this case, the sending unit must use cmd_sendchat instead.

NOTE: As the variable tag is in fact terminating zero byte of the variable name, the result of the macro constructor $ defined in vat.h header file may be passed directly as the argument of this command. See SymFind and other functions from vat.h header file for more info.

void cmd_sendchat (ESI Var);

Executes TI-Basic SendChat command.

cmd_sendchat is a general alternative to cmd_sendcalc, which is useful if the receiving unit is a TI-92 (or for making a generic "chat" program that allows any device to be used). See cmd_sendcalc for more info. This function calls function sendcalc from link.h header file.

cmd_sendchat sends a variable only if that variable is compatible with the TI-92, which is tipically true in "chat" programs. However, cmd_sendchat will not send an archived variable, a TI-89 graph data base, etc.

void cmd_get (ESI Var);

Executes TI-Basic Get command.

cmd_get receives a CBL (Calculator-Based Laboratory) value from the link port and stores it in a variable pointed to by Var (it should point to the variable tag).

NOTE: As the variable tag is in fact terminating zero byte of the variable name, the result of the macro constructor $ defined in vat.h header file may be passed directly as the argument of this command. See SymFind and other functions from vat.h header file for more info.

void cmd_send (ESI List);

Executes TI-Basic Send command.

cmd_send expects that List points to LIST_TAG. It sends the list pointed to by List to the link port to be accepted from CBL (Calculator-Based Laboratory) device.

void cmd_printobj (ESI Var);

Executes PrintObj command from the text editor.

cmd_printobj sends a variable pointed to by Var (it should point to the variable tag) as a "Print Object" through a link interface. See TI-Basic manual (chapter "Creating a Lab Report") for more info about Print Objects.

NOTE: As the variable tag is in fact terminating zero byte of the variable name, the result of the macro constructor $ defined in vat.h header file may be passed directly as the argument of this command. See SymFind and other functions from vat.h header file for more info.

void cmd_custmon (void);

Executes TI-Basic CustmOn command.

cmd_custmon activates a custom toolbar menu in the current application.

void cmd_custmoff (void);

Executes TI-Basic CustmOff command.

cmd_custmon removes a custom toolbar menu in the current application. Also, a custom toolbar is removed automatically when you change application.

void push_getkey (void);

Executes TI-Basic getKey function.

push_getkey pushes tke key code of the key pressed to the expressions stack. It pushes 0 if no key is pressed. The pushed value is exactly the same as a value returned from Ti-Basic getKey function (it is mainly the same value as returned from ngetchx, but not always: for example, code for arrow keys are different).

void push_setmode (ESI ModeNameStringOrList, ESI SettingString);

Executes TI-Basic setMode function.

push_setmode assumes that ModeNameStringOrList points to the tag of a string expression (usually on STR_TAG), or to the list expression (usually on LIST_TAG). If it points to a string, push_setmode sets appropriate mode to the new string pointed to by SettingString (it should also point to the string tag), and pushes the previous setting string of that mode to the expressions stack. Possible mode strings and settings strings are listed in the table given below:

Mode namePossible settings
"Graph""FUNCTION", "PARAMETRIC", "POLAR", "SEQUENCE", "3D", "DIFF EQUATIONS"
"Display Digits""FIX 0", "FIX 1", ..., "FIX 12", "FLOAT 1", "FLOAT 2", ..., "FLOAT 12"
"Angle""RADIAN", "DEGREE"
"Exponential Format""NORMAL", "SCIENTIFIC", "ENGINEERING"
"Complex Format""REAL", "RECTANGULAR", "POLAR"
"Vector Format""RECTANGULAR", "CYLINDRICAL", "SPHERICAL"
"Pretty Print""OFF", "ON"
"Split Screen""FULL", "TOP-BOTTOM", "LEFT-RIGHT"
"Split 1 App""Home", "Y= Editor", "Window Editor", "Graph", "Table", "Data/Matrix Editor", "Program Editor", "Text Editor", "Numeric Solver"
"Split 2 App""Home", "Y= Editor", "Window Editor", "Graph", "Table", "Data/Matrix Editor", "Program Editor", "Text Editor", "Numeric Solver"
"Number of Graphs""1", "2"
"Graph2""FUNCTION", "PARAMETRIC", "POLAR", "SEQUENCE", "3D", "DIFF EQUATIONS"
"Exact/Approx""AUTO", "EXACT", "APPROXIMATE"
"Base""DEC", "HEX", "BIN"

If ModeNameStringOrList points to a list, such list is assumed to contain pairs of keyword strings. push_setmode then will set them all at once (SettingString is ignored in this case). This is recommended for multiple-mode changes.

NOTE: push_setmode may cause switching of the current application. See events.h header file for more info.

void push_getmode (ESI ModeNameString);

Executes TI-Basic getMode function.

push_getmode assumes that ModeNameString points to the tag of a string expression (usually on STR_TAG). If it points to a specific mode name string, it pushes a new string containing the current setting for that mode to the expressions stack. See push_setmode for a list of legal mode name strings.

If the mode name string is "ALL", push_getmode pushes a list of string pairs containing the settings of all the modes to the expressions stack. So, you can restore all mode settings later at once using push_setmode.

void push_setgraph (ESI ModeNameString, ESI SettingString);

Executes TI-Basic setGraph function.

push_setgraph assumes that ModeNameString points to the tag of a string expression (usually on STR_TAG). It sets appropriate Graph mode to the new string pointed to by SettingString (it should also point to the string tag), and pushes the previous setting string of that mode to the expressions stack. Possible mode strings and settings strings are listed in the table given below:

Mode namePossible settings
"Coordinates""RECT", "POLAR", "OFF"
"Graph Order""SEQ", "SIMUL" (not available in SEQUENCE, 3D or DIFF EQUATIONS graph mode)
"Grid""OFF", "ON" (not available in 3D graph mode)
"Axes""OFF", "ON" (not 3D graph mode)
"OFF", "AXES", "BOX" (3D graph mode)
"Leading Cursor""OFF", "ON" (not available in 3D graph mode)
"Labels""OFF", "ON"
"Style""WIRE FRAME", "HIDDEN SURFACE", "CONTOUR LEVELS", "WIRE AND CONTOUR", "IMPLICIT PLOT" (applies only to 3D graph mode)
"Seq Axes""TIME", "WEB", "U1-VS-U2" (applies only to SEQUENCE graph mode)
"DE Axes""TIME", "T-VS-Y'", "Y-VS-Y'", "Y1-VS-Y2", "Y1-VS-Y2'", "Y1'-VS-Y2'" (applies only to DIFF EQUATIONS graph mode)
"Solution Method""RK", "EULER" (applies only to DIFF EQUATIONS graph mode)
"Fields""SLPFLD", "DIRFLD", "FLDOFF" (applies only to DIFF EQUATIONS graph mode)

void push_settable (ESI ModeNameString, ESI SettingString);

Executes TI-Basic setTable function.

push_settable assumes that ModeNameString points to the tag of a string expression (usually on STR_TAG). It sets appropriate table parameter to the new string pointed to by SettingString (it should also point to the string tag), and pushes the previous setting string of that parameter to the expressions stack. Possible parameter name strings and settings strings are listed in the table given below:

Parameter namePossible settings
"Graph <-> Table""OFF", "ON"
"Independent""AUTO", "ASK"

void push_switch (ESI WinNum);

Executes TI-Basic switch function.

push_switch expects that WinNum points to an expression which evaluates to an integer. If this integer is 0, push_switch pushes the active window number (1 for left or top window, 2 for right or bottom window) to the expressions stack. If this integer is 1 or 2, push_switch activates window 1 or 2 and pushes the previously active window number to the expressions stack. If WinNum points to END_TAG, push_switch switches windows and pushes the previously active window number to the expressions stack. Of course, window switching is ignored if the calculator is not displaying a split screen.

Predefined types


type ESI

ESI is "expressions stack index" which is, in fact, the pointer to the tag byte on the TIOS expressions stack. It is defined as

typedef char *ESI;

See estack.h header file for more info about the expressions stack.

Return to the main index