Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming a BASIC variable (TI-84) with multiple characters?

I am trying to create a simple BASIC program for my TI-84 that will calculate the midpoint of two given points. This is my current code below, which produces an error upon trying to run the program:

:Prompt XONE,YONE,XTWO,YTWO
:((XONE+YONE)/2)->X
:((XTWO+YTWO)/2)->Y
:Disp X,Y

The reason I suspect it has something to do with my variable naming is because I tried running the same program, except I named the variables A,B,C, and D, instead of what you see above, and that ran fine.

like image 310
user1726923 Avatar asked Aug 30 '13 02:08

user1726923


1 Answers

Some variants of TI BASIC (such as those that ship with the 68000-CPU-based devices) allow for longer variable names but the variant that ships with the TI-84 calculator only allows the variables A through Z and theta. See here for more detail.

Hence, for those, you cannot use variables like XONE as you have done in your code.

In any case, your midpoint calculation is fundamentally wrong. You currently have it averaging XONE and YONE to get the midpoint on the X-axis, whereas you should be averaging XONE and XTWO (that's of course ignoring the limitations already mentioned about allowed variable names).

In other words (assuming the variables were valid for your calculator, which they're not), it would be:

:((XONE+XTWO)/2)->X
:((YONE+YTWO)/2)->Y

With both those changes (fixing the midpoint calculation and only using allowed variable names), that would be something like:

:DISPLAY "X1:"
:PROMPT A

:DISPLAY "Y1:"
:PROMPT B

:DISPLAY "X2:"
:PROMPT C

:DISPLAY "Y2:"
:PROMPT D

:((A+C)/2)->E
:((B+D)/2)->F

:DISP E
:DISP F
like image 92
paxdiablo Avatar answered Sep 30 '22 10:09

paxdiablo