### Author Topic: Basic Variables  (Read 4176 times)

0 Members and 1 Guest are viewing this topic.

#### zeldaking

• LV4 Regular (Next: 200)
• Posts: 197
• Rating: +15/-0
##### Basic Variables
« 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:prgmAXEPROGAxe Program:
Code: [Select]
:If N (I don't know the code to use the external var which should equal one):ClrdrawSo basically can you run an axe program from a basic program and use the Ti-OS vars?
Thanks.
« Last Edit: June 24, 2012, 08:36:27 pm by zeldaking »

#### Deep Toaster

• So much to do, so much time, so little motivation
• LV13 Extreme Addict (Next: 9001)
• Posts: 8217
• Rating: +758/-15
##### Re: Basic Variables
« Reply #1 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")→PIf PDisp "The value of N:",i,float{P}>Dec,iElseDisp "Variable N does not exist!",iEnd

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.
« Last Edit: June 24, 2012, 08:55:16 pm by Deep Thought »

#### zeldaking

• LV4 Regular (Next: 200)
• Posts: 197
• Rating: +15/-0
##### Re: Basic Variables
« Reply #2 on: June 24, 2012, 09:55:27 pm »
Sweet thanks. So:
Basic
Code: [Select]
:1->N:prgmAXEPROGAxe:
Code: [Select]
:GetCalc("varN")->P:float{P}->PSo now P is 'usable' and should equal 1, right?

#### blue_bear_94

• Posts: 801
• Rating: +25/-35
• Touhou Enthusiast / Former Troll / 68k Programmer
##### Re: Basic Variables
« Reply #3 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.
Due to dissatisfaction, I will be inactive on Omnimaga until further notice. (?? THP hasn't been much success and there's also the CE. I might possibly be here for a while.)
If you want to implore me to come back, or otherwise contact me, I can be found on GitHub (bluebear94), Twitter (@melranosF_), Reddit (/u/Fluffy8x), or e-mail (if you know my address). As a last resort, send me a PM on Cemetech (bluebear94) or join Touhou Prono (don't be fooled by the name). I've also enabled notifications for PMs on Omnimaga, but I don't advise using that since I might be banned.
Elvyna (Sunrise) 4 5%
TI-84+SE User (2.30 2.55 MP 2.43)
TI-89 Titanium User (3.10)
Casio Prizm User? (1.02)
Bag  東方ぷろの

#### Deep Toaster

• So much to do, so much time, so little motivation
• LV13 Extreme Addict (Next: 9001)
• Posts: 8217
• Rating: +758/-15
##### Re: Basic Variables
« Reply #4 on: June 24, 2012, 10:00:32 pm »
Sweet thanks. So:
Basic
Code: [Select]
:1->N:prgmAXEPROGAxe:
Code: [Select]
:GetCalc("varN")->P:float{P}->PSo 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.

#### zeldaking

• LV4 Regular (Next: 200)
• Posts: 197
• Rating: +15/-0
##### Re: Basic Variables
« Reply #5 on: June 24, 2012, 10:08:13 pm »
Yeah, I figured that out. What if I wanted to use OS strings? substr( equivalent?

#### FinaleTI

• Believe in the pony that believes in you!
• CoT Emeritus
• LV10 31337 u53r (Next: 2000)
• Posts: 1830
• Rating: +121/-2
• Believe in the pony that believes in you!
##### Re: Basic Variables
« Reply #6 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 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.

Spoiler For Projects:

My projects haven't been worked on in a while, so they're all on hiatus for the time being. I do hope to eventually return to them in some form or another...

Spoiler For Pokemon TI:
Axe port of Pokemon Red/Blue to the 83+/84+ family. On hold.

Spoiler For Nostalgia:
My big personal project, an original RPG about dimensional travel and a few heroes tasked with saving the world.
Coding-wise, on hold, but I am re-working the story.

Spoiler For Finale's Super Insane Tunnel Pack of Doom:
I will be combining Blur and Collision Course into a single gamepack. On hold.

Spoiler For Nostalgia Origins: Sky's Story:
Prequel to Nostalgia. On hold, especially while the story is re-worked.

• しらす丼