Author Topic: Basic Variables  (Read 4270 times)

0 Members and 1 Guest are viewing this topic.

Offline zeldaking

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 197
  • Rating: +15/-0
    • View Profile
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
: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.
« Last Edit: June 24, 2012, 08:36:27 pm by zeldaking »

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
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")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.
« Last Edit: June 24, 2012, 08:55:16 pm by Deep Thought »




Offline zeldaking

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 197
  • Rating: +15/-0
    • View Profile
Re: Basic Variables
« Reply #2 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?

Offline blue_bear_94

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 801
  • Rating: +25/-35
  • Touhou Enthusiast / Former Troll / 68k Programmer
    • View Profile
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  東方ぷろの

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Basic Variables
« Reply #4 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.




Offline zeldaking

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 197
  • Rating: +15/-0
    • View Profile
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?

Offline 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!
    • View Profile
    • dmuckerman.tumblr.com
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.

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Basic Variables
« Reply #7 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>)