Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: zeldaking on June 24, 2012, 08:35:59 pm

Title: Basic Variables
Post by: zeldaking on June 24, 2012, 08:35:59 pm
Hi everyone, I haven't posted here in a long time. But cemetech doesn't really support axe I suppose. So here is my question.
Is it poosible to use external Variables, such as this:
Ti-basic program:
Code: [Select]
:1->N
:prgmAXEPROG
Axe Program:
Code: [Select]
:If N (I don't know the code to use the external var which should equal one)
:Clrdraw
So basically can you run an axe program from a basic program and use the Ti-OS vars?
Thanks.
Title: Re: Basic Variables
Post by: Deep Toaster on June 24, 2012, 08:52:04 pm
To use one of the TI-BASIC variables, you need to first look for it with GetCalc, and then get the data from the pointer it returns.

Here's some code that will display the value of N if it exists, or a message if it doesn't:

Quote from: Axe
GetCalc("varN")→P
If P
Disp "The value of N:",i,float{P}>Dec,i
Else
Disp "Variable N does not exist!",i
End

The var token is 2nd+[u] (the key 7). float{ is somewhere in the MATH menu, don't remember where, but what it does is it takes a nine-byte floating-point variable (the format the real vars are stored in) and converts it to a two-byte integer you can use in Axe.
Title: Re: Basic Variables
Post by: zeldaking on June 24, 2012, 09:55:27 pm
Sweet thanks. So:
Basic
Code: [Select]
:1->N
:prgmAXEPROG
Axe:
Code: [Select]
:GetCalc("varN")->P
:float{P}->P
So now P is 'usable' and should equal 1, right?
Title: Re: Basic Variables
Post by: blue_bear_94 on June 24, 2012, 09:58:21 pm
You need to use Asm(prgmAXEPROG) to run a program written in Axe since it's compiled to assembly.
Title: Re: Basic Variables
Post by: Deep Toaster on June 24, 2012, 10:00:32 pm
Sweet thanks. So:
Basic
Code: [Select]
:1->N
:prgmAXEPROG
Axe:
Code: [Select]
:GetCalc("varN")->P
:float{P}->P
So now P is 'usable' and should equal 1, right?
That's right, except for what blue_bear_94 said. Asm(prgmAXEPROG will always work (just compile your program for noshell or Ion), while prgmAXEPROG will only work if the person using your program has DoorsCS installed and enabled.
Title: Re: Basic Variables
Post by: zeldaking on June 24, 2012, 10:08:13 pm
Yeah, I figured that out. What if I wanted to use OS strings? substr( equivalent?
Title: Re: Basic Variables
Post by: FinaleTI on June 24, 2012, 10:31:27 pm
You can reference strings by getting a pointer the same way as any other external variable:
Code: [Select]
GetCalc("Str0")->P
I personally have never attempted a substring routine, so all I can offer is general advice in token reading:

The tricky part about reading from a string is that you need to read tokens, not ASCII. This means you have to check for whether or not a token is two bytes.
TI-BASIC Dev (http://tibasicdev.wikidot.com/one-byte-tokens) has a reference of all one-byte tokens and the one byte values that signify a two byte token.

So when you check a byte in the string, if it matches any of the two-byte identifiers, then the next byte is also part of the token, and that must be taken into account when reading it.
Also, two byte tokens must be read with {pointer to first byte}rr and not {pointer to first byte}r, because of the way two byte tokens are stored and how Axe reads them.
Title: Re: Basic Variables
Post by: shmibs on June 25, 2012, 11:00:35 am
adding to that, the list of two byte indicators is:
[5C5D5E606162637EAABBEF
so, in order to check if it was one of those values, you'd just need to use
If indata([5C5D5E606162637EAABBEF00],<byte to search for>)