Author Topic: Extra Variables - An advanced TI-BASIC trick  (Read 18390 times)

0 Members and 1 Guest are viewing this topic.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Extra Variables - An advanced TI-BASIC trick
« 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.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Extra Variables - An advanced TI-BASIC trick
« Reply #1 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 ^^

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Extra Variables - An advanced TI-BASIC trick
« Reply #2 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.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Extra Variables - An advanced TI-BASIC trick
« Reply #3 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

Offline mapar007

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 550
  • Rating: +28/-5
  • The Great Mata Mata
    • View Profile
Re: Extra Variables - An advanced TI-BASIC trick
« Reply #4 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!

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Extra Variables - An advanced TI-BASIC trick
« Reply #5 on: January 23, 2010, 07:47:53 am »
Nice find!

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: Extra Variables - An advanced TI-BASIC trick
« Reply #6 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. ;)
Hobbing in calculator projects.

Offline mapar007

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 550
  • Rating: +28/-5
  • The Great Mata Mata
    • View Profile
Re: Extra Variables - An advanced TI-BASIC trick
« Reply #7 on: January 23, 2010, 08:43:05 am »
I think it is because they have a fixed location. I'm not quite sure, though.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Extra Variables - An advanced TI-BASIC trick
« Reply #8 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.

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Extra Variables - An advanced TI-BASIC trick
« Reply #9 on: January 23, 2010, 08:35:40 pm »
I love the speed of the Finance Vars.  Plus it gives use to the Finance "App". ;)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Extra Variables - An advanced TI-BASIC trick
« Reply #10 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 :)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Extra Variables - An advanced TI-BASIC trick
« Reply #11 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]

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Extra Variables - An advanced TI-BASIC trick
« Reply #12 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

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Extra Variables - An advanced TI-BASIC trick
« Reply #13 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!
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Extra Variables - An advanced TI-BASIC trick
« Reply #14 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...)