Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Quigibo on January 23, 2010, 12:00:09 am

Title: Extra Variables - An advanced TI-BASIC trick
Post by: Quigibo on January 23, 2010, 12:00:09 am
Have you ever wanted to use the lowercase characters as variables?  You can.
I was talking to omnimaga, and even a BASIC expert like him didn't know about it :P So he said I should mention it here since probably very few people know about it.

Here is how:
{0,1->L1
{B,A+B->L2
LinReg(ax+b)


You have now stored the values of uppercase "A" into lowercase "a" and Uppercase "B" into lowercase "b" (You can use anything for the number).  At this point you can do math with them as if they were any other variable.  However, they are read only.  You can only write to them by using the statistics functions.

You can do things like this:
a->C
sin(a)+cos(b)->C
if (a=1)


You just can't write to them.  These won't work:
C->a
For(a,1,5)


These can be useful if you have a variable that is usually read only for most of the program but is used constantly.  Its better than using a list to store extra variables because these letters are 2 byte tokens which is less than the 4 bytes to type L1(9) or 5 bytes for L1(10)

You don't have to use a list to store extra variables:
L1(1)(L1(2)-2->D
Just use this:
a(b-2->D

You can write to the other stat vars as well like c,d,e,r,p,z,t,etc... but you will have to find a statistics operation that will write your value to that variable.
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: DJ Omnimaga on January 23, 2010, 12:15:35 am
I will probably need to experiment with this for a bit to get used to it, but It it will most likely be useful to some people ^^
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: Builderboy on January 23, 2010, 12:44:54 am
That is neat!  Its like final types in Java :) At first i was trying to use the lowercase letters that are accessed with programs like Omnicalc and MirageOS, but eventually I figured out that these vars were located under the Vars/Stats menu.
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: DJ Omnimaga on January 23, 2010, 01:02:27 am
Another set of variables that can be used in BASIC are Xmin/Xmas and the like, as he reminded me via private chat. There's also the italic "n" variable in the CATALOG menu (I think it's related to Window settings tho) and the Finance APP variables, altough the two last ones are linked and cannot be negative
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: mapar007 on January 23, 2010, 05:55:29 am
I used to use asm to copy the RegEQ to ans in order to access a and b from regressions. Beh. Nice find!
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: ztrumpet on January 23, 2010, 07:47:53 am
Nice find!
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: Galandros on January 23, 2010, 08:37:25 am
The finance variables are 2 byte tokens but they are faster! Try to count a keyloop where you store the getkey to the N in finance apps.
I think the speed gain is because there are specific routines in TI-OS to access/store to them and/or they are in a specific location in memory.

Nice trick to save to the a and b. ;)
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: mapar007 on January 23, 2010, 08:43:05 am
I think it is because they have a fixed location. I'm not quite sure, though.
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: DJ Omnimaga on January 23, 2010, 02:54:48 pm
Also what is cool about them is that they won't take any user RAM. Kinda like real variables and matrices on the TI-81

I often use finance vars for position on a huge RPG map and its engine.
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: ztrumpet on January 23, 2010, 08:35:40 pm
I love the speed of the Finance Vars.  Plus it gives use to the Finance "App". ;)
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: Builderboy on January 24, 2010, 12:27:49 am
One thing I don't like about them though is the length of the names XD they make my code look all long and hard to read! :( I usualy just use the N and I% therefore :)
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: DJ Omnimaga on January 24, 2010, 12:44:32 am
It's nothing Builderboy, though. Try using them with some language apps installed :P

[offtopic]On top of that, about language apps, TI was stupid enough to swap int( with ipart( during translating >.>[/offtopic]
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: Builderboy on January 24, 2010, 12:51:30 am
Haha lol, I guess that would be horrible XD would there be a good translation for iPart to other languages though?  I wouldn't know O.O
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: Quigibo on January 24, 2010, 12:57:47 am
You're right, I just tried this.  Reading from 'a' and 'b' really are faster than the standard variables since they are in specific locations, like the finance variables!
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: ztrumpet on January 24, 2010, 10:41:34 am
Wow!  That's great!  Those are two more "constants" that I'll start using.  They can take various values like -1.346, 8, 9001, .345 right?

(Ti needs to be more careful while translating...)
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: Silver Shadow on January 24, 2010, 11:29:44 am
Nice find there, Quigibo!
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: Quigibo on January 24, 2010, 03:56:52 pm
Wow!  That's great!  Those are two more "constants" that I'll start using.  They can take various values like -1.346, 8, 9001, .345 right?
Yes.  They just can't be complex.


Another way to save stat vars (probably better than my first example)

{A,B->L1
1-Var Stats


The smaller of A and B is saved in minX and the larger of the two is in maxX.

Also in case its useful, their sum is in Σx, the average is in Med, and the sum of their squares (maybe in case you're using this constant to compare distances) is in Σx2
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: Galandros on January 24, 2010, 04:24:56 pm
This tricks should be added to http://tibasicdev.wikidot.com/

Never think you know all TI-BASIC tricks. :P
Title: Re: Extra Variables - An advanced TI-BASIC trick
Post by: ztrumpet on January 24, 2010, 06:36:18 pm
Another way to save stat vars (probably better than my first example)

{A,B->L1
1-Var Stats


The smaller of A and B is saved in minX and the larger of the two is in maxX.

Also in case its useful, their sum is in Σx, the average is in Med, and the sum of their squares (maybe in case you're using this constant to compare distances) is in Σx2
Yes!  That's awesome!  I can't wait to find a spot to use these. ;D