global variable in Nspire G&G

441 views
Skip to first unread message

ffo...@drury.edu

unread,
Sep 21, 2009, 6:11:01 AM9/21/09
to tinspire
The Nspire manual states that functions may only use local variables
and thus are destroyed after the function is called. It goes on to
state that a program may possess a global variable but may only be
called in a calculator application. Does anyone know of a back-door
method to store a value in a G &G application that persists throughout
a simulation and be programmatically changed? For example, I would
like to accumulate the angular displacement of a point that is
animated around a circle for several revolutions and do a calculation
on the increment at each animation step regardless of animation speed.
Thanks in advance.

Nelson Sousa

unread,
Sep 21, 2009, 10:21:48 AM9/21/09
to tins...@googlegroups.com
if you have a program editing the variable you can't do it in real
time: it's updated at the end of each program run.

My view abour TI-Nspire's programming is that a program should be
avoided at all times, unless you plan on calling it and getting output
exclusively from a Calculator app.

So, if you have a G&G page, use functions instead of programs. Call
them from a spreadsheet page and store the result on a variable. Then
recall that result back to the G&G page.


Here's the outline:

1. On a G&G page you have a rectangle triangle and both sides AB and
AC are measured and stored in variables;
2. On a L&S page you have cells A1 and A2 defined as A1=bc, A2=ac;
3. A function pythagoras(l1,l2) returns sqrt(l1^2 + l2^2)
4. define cell A3 as "hyp:=pythagoras(a1,a2)" (this calls the function
and stores the result on variable hyp.
5. back to the G&G page write down text expression "var". Calculate it
using variable hyp as parameter var.

And there you have it, the input is created on the G&G page, the
output is also written to the G&G page and everything in between is
done by functions, with L&S acting as a "transport agent".

Check out the tutorial I wrote about connecting G&G with L&S on
http://nelsonsousa.pt/index.php?lang=en&cat=2&subcat=5&article=36
It uses 3 movable circles and a L&S page computes the coordinates of
the center of mass. With more complex calculations you may need to use
explicit functions (and several of them, as functions on L&S can only
return numbers or lists).


Oh, one last piece of advice: be very carefull with error checking!
When a L&S cell is defined as the result of a function, if the
function returns an error you may lose the definition. If error
checking isn't reliable define a column as the result of the function
and have the function return a list instead of a number.


Cheers,
Nelson

ffo...@drury.edu

unread,
Sep 21, 2009, 6:00:41 PM9/21/09
to tinspire
Wow, thanks for the really detailed and prompt reply. I look forward
to working through your tutorial and trying your method on my
construction. I let you know how it turns out. Again, thanks.

On Sep 21, 9:21 am, Nelson Sousa <nso...@gmail.com> wrote:
> if you have a program editing the variable you can't do it in real
> time: it's updated at the end of each program run.
>
> My view abour TI-Nspire's programming is that a program should be
> avoided at all times, unless you plan on calling it and getting output
> exclusively from a Calculator app.
>
> So, if you have a G&G page, use functions instead of programs. Call
> them from a spreadsheet page and store the result on a variable. Then
> recall that result back to the G&G page.
>
> Here's the outline:
>
> 1. On a G&G page you have a rectangle triangle and both sides AB and
> AC are measured and stored in variables;
> 2. On a L&S page you have cells A1 and A2 defined as A1=bc, A2=ac;
> 3. A function pythagoras(l1,l2) returns sqrt(l1^2 + l2^2)
> 4. define cell A3 as "hyp:=pythagoras(a1,a2)" (this calls the function
> and stores the result on variable hyp.
> 5. back to the G&G page write down text expression "var". Calculate it
> using variable hyp as parameter var.
>
> And there you have it, the input is created on the G&G page, the
> output is also written to the G&G page and everything in between is
> done by functions, with L&S acting as a "transport agent".
>
> Check out the tutorial I wrote about connecting G&G with L&S onhttp://nelsonsousa.pt/index.php?lang=en&cat=2&subcat=5&article=36
> It uses 3 movable circles and a L&S page computes the coordinates of
> the center of mass. With more complex calculations you may need to use
> explicit functions (and several of them, as functions on L&S can only
> return numbers or lists).
>
> Oh, one last piece of advice: be very carefull with error checking!
> When a L&S cell is defined as the result of a function, if the
> function returns an error you may lose the definition. If error
> checking isn't reliable define a column as the result of the function
> and have the function return a list instead of a number.
>
> Cheers,
> Nelson
>
>
>
> On Mon, Sep 21, 2009 at 11:11, ffot...@drury.edu <ffot...@drury.edu> wrote:
>
> > The Nspire manual states that functions may only use local variables
> > and thus are destroyed after the function is called.  It goes on to
> > state that a program may possess a global variable but may only be
> > called in a calculator application. Does anyone know of a back-door
> > method to store a value in a G &G application that persists throughout
> > a simulation and be programmatically changed? For example, I would
> > like to accumulate the angular displacement of a point that is
> > animated around a circle for several revolutions and do a calculation
> > on the increment at each animation step regardless of animation speed.
> > Thanks in advance.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages