1242
Appendix B: Global Variables — Graphing
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
gr_flags
(continued)
Assumptions:
Access_AMS_Global_Variables is defined.
Side Effects:
None
Availability:
On AMS 2.00 and higher.
TI
-
89 / TI
-
92 Plus
Differences:
None
See Also:
None
Example:
The function below is an example of a TI-BASIC extension function. See
section
7.3.2 TI-BASIC Extensions
for more information on extensions.
void graphsin( void )
/* Return on the estack a list of all the values of sin that would be graphed
with the current Window variables in function mode, or if called during graphing,
return only the value of sin for the input.
*/
{
Access_AMS_Global_Variables;
BCD16 val, num;
USHORT ctr;
EStackIndex k, old_top = top_estack;
if( gr_flags.gr_in_progress == TRUE )
{ /* graph in progress - return only one value to plot */
push_approx( top_estack ); /* simplify the input to the function */
if( ESTACK(top_estack) != FLOAT_TAG )
ER_throw( ER_DOMAIN );
val = sin( estack_to_float( top_estack ) );
top_estack = old_top; /* remove simplified input */
push_Float( val ); /* leave result on estack */
return;
}
/* Not graphing, ignore any input on estack, return list of sin values
that would be graphed */
if( gr_active->graph_mode != GR_FUNC )
ER_throw( ER_GRAPH_MODE ); /* must be function mode to access xres */
push_quantum( END_TAG );
for( ctr=0; ctr <= gr_active->xmaxpix; ctr +=
(USHORT)((gr_active->rngp)[GR_XRES] ))
{
num = (gr_active->rngp)[GR_XMIN] + ((gr_active->rngp)[GR_DELTAX] ) *
ctr; /* next input */
val = sin( num ); /* next result */
push_Float( val ); /* build list on estack */
}
k = top_estack; /* point to last sin value */
push_reversed_tail (k); /* reverse the order */
delete_between (old_top, k); /* delete the old copy */
push_quantum (LIST_TAG); /* make it a list */
}