Author Topic: Help with variable limit  (Read 7096 times)

0 Members and 1 Guest are viewing this topic.

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Help with variable limit
« on: December 18, 2012, 03:19:34 am »
I have hit a variable limit and was wondering if there was anything to get around that. I know in Ti-BASIC you can just create a list and store things to that, but I do not know how to to such things while using axe parser.
Can I get some help please? Thanks.

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: Help with variable limit
« Reply #1 on: December 18, 2012, 03:31:54 am »
There are variable limits in Axe? O.O Did you get any error stating so? I was sure that Axe could let you use as many vars as your RAM do

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Re: Help with variable limit
« Reply #2 on: December 18, 2012, 03:35:13 am »
I am refering to A-Z and ø. Now what do I use...

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Help with variable limit
« Reply #3 on: December 18, 2012, 10:59:26 am »
You can use any free ram space, or if you're using a program you can even make your own spaces!

A-Z and theta are just locations in memory that have predefined names. L1 (768 bytes), L2 (531 bytes, but actually bigger), L4 (256 bytes), and L5 (128 bytes) are pointers to other areas of memory that are usually free to use.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Help with variable limit
« Reply #4 on: December 18, 2012, 12:36:55 pm »
What squidgetx said. Look at the Commands.html, find a RAM area that none of your lines of code will corrupt (for example, don't use L5 if you use ClrHomes in your code), then create new variables like this:
  L5→°Var1
  L5+2→°Var2
  L5+4→°TheGame

Now, Var1, Var2 and TheGame are legit variables, like A, B and so on, you can do 1→Var1, etc.
(note that TheGame has a name length above 5 so it will only work on 1.2.0 and higher).
« Last Edit: December 18, 2012, 12:37:12 pm by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Re: Help with variable limit
« Reply #5 on: December 20, 2012, 06:44:46 pm »
Im afraid i don't fully understand...

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Help with variable limit
« Reply #6 on: December 21, 2012, 03:57:14 pm »
Im afraid i don't fully understand...
??? What didn't you understand ?
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: Help with variable limit
« Reply #7 on: December 21, 2012, 04:00:48 pm »
* Eiyeron lost, darn you, Evil Absol!

Offline Derf321

  • LV3 Member (Next: 100)
  • ***
  • Posts: 59
  • Rating: +0/-0
    • View Profile
Re: Help with variable limit
« Reply #8 on: December 21, 2012, 09:26:46 pm »
If you only need 6 more variables, you can press VARS, go right to Y-VARS, Polar..., and then you can use R1 through R6 just like you would any other variable.
If you need more, this tutorial is what I used to understand how to use Arrays to store variables (it's pretty much like a list). It's best explained by this link, but it'll be confusing at first (was for me at first): http://ourl.ca/9288
Also, if you want to run it in MirageOS or any other OS, make sure to only use L1, not L2 or others or it will not work.

Offline adrusi

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +4/-0
    • View Profile
    • Adrusi
Re: Help with variable limit
« Reply #9 on: May 22, 2013, 07:07:17 pm »
This is interesting. I didn't realize that you could have variables other than the prenamed ones. I've never run out of the variables, but it would be nice to have meaningful names.

However I can't get it to work. I have this code:

Code: [Select]
PROGRAM:ΘTEST
.TEST
L₅→°FOO
L₅+1→°BAR
5→FOO
6→BAR
Disp FOO+BAR▸Dec

Which should display 11, but instead it displays 1547 (YMMV)

Am I missing something? Are you sure this is valid (it compiles, but maybe it means something else, though I can't think of what)?

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Help with variable limit
« Reply #10 on: May 22, 2013, 07:52:03 pm »
Variables in Axe are two bytes large, and you only allocated FOO and BAR to be one byte apart. The second byte of FOO overlaps the first byte of BAR. :P

Two solutions:
  • Allocate your custom variables two bytes apart instead of one. The standard solution.
  • If you know your variables will fit in one byte each, you can keep them allocated one byte apart. All uses of the variables only allocated one byte should then be followed with a superscript r, like FOOr.

Offline adrusi

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +4/-0
    • View Profile
    • Adrusi
Re: Help with variable limit
« Reply #11 on: May 22, 2013, 07:59:31 pm »
Ah yes, forgot that addresses point to bytes and not words, been toying with the dcpu16 architecture recently

Offline adrusi

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +4/-0
    • View Profile
    • Adrusi
Re: Help with variable limit
« Reply #12 on: May 22, 2013, 08:39:31 pm »
How does this compile? It looks like you are defining labels at runtime, even though labels are usually resolved to constants at compile time.