Author Topic: Help Request - ERROR INVALID TOKEN  (Read 9563 times)

0 Members and 1 Guest are viewing this topic.

Offline Omar Chehab

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +0/-0
    • View Profile
Help Request - ERROR INVALID TOKEN
« on: December 02, 2013, 01:51:23 pm »
I recently started using Axe for my TI programming. I read the manual and the commands files and still could not get an answer. Upon compiling my program, it gives an error saying invalid token.

The error is at ":8*(randInt(1,8)+2)→A" and I am guessing that the line after that too is wrong. In TI basic randInt( generates a number between a range though in axe it is not accepting randInt( as a command. So my question is:

What can I use to replace or fix randInt( as I want to generate a random number in a given range.

* * *

:8*(randInt(1,8)+2)→A
:8*(randInt(1,4)+2)→B→C
« Last Edit: December 02, 2013, 01:51:42 pm by Omar Chehab »

Offline turiqwalrus

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 840
  • Rating: +51/-2
  • Wheeeeeee~!
    • View Profile
Re: Help Request - ERROR INVALID TOKEN
« Reply #1 on: December 02, 2013, 01:55:55 pm »
First of all, I believe you can optimise the randInts a little bit, seeing as you can just change the paramaters.

Besides that, →B→C doesn't work, from what I remember, since storing things isn't nestable.
Changing it so that it might work, though, we'd end up with this:
Code: [Select]
:8*randInt(3,10)→A
:8*randInt(3,6)→B:Ans→C
Of course, my own basic skills being rusty, to say the least, there's probably ways to make this even smaller ;)

Offline Omar Chehab

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +0/-0
    • View Profile
Re: Help Request - ERROR INVALID TOKEN
« Reply #2 on: December 02, 2013, 02:01:33 pm »
Even after fixing what you told me the error still occurs, so I am certain that the error invalid token is caused by the randInt( command.

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Help Request - ERROR INVALID TOKEN
« Reply #3 on: December 02, 2013, 02:02:51 pm »
nesting stores does work in axe, but I don't think the randint does. Instaed of doing randInt(1,8)+2, you can do rand^8+3. rand in axe generates a random 16-bit number, ^ calculates the remainder of a division by 8 which makes in the range of 0-7 (it doesn't mean power in axe!), and the +3 adds 3 to it to give you the correct range.
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline Omar Chehab

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +0/-0
    • View Profile
Re: Help Request - ERROR INVALID TOKEN
« Reply #4 on: December 02, 2013, 02:11:44 pm »
Thank you for the quick reply. Your answer was very informative it fixed my error, though can you please explain what the ^ is if it's not power?

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Help Request - ERROR INVALID TOKEN
« Reply #5 on: December 02, 2013, 02:13:54 pm »
It's the modulus operator. This is basically a divide, but instead of the quitient of the division, it returns the remainder. Usually, programming languages use the per cent sign (%) for this, but as it's quite hard to get on an 83+ line calculator, axe uses the ^ instead.
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Help Request - ERROR INVALID TOKEN
« Reply #6 on: December 02, 2013, 03:57:50 pm »
And by the way very few languages have a power operator (Python has ** but most languages have a pow(number, power) function in the advanced math library).

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Help Request - ERROR INVALID TOKEN
« Reply #7 on: December 02, 2013, 04:49:47 pm »
Don't know why noone said that already : Axe doesn't have a randInt( routine. If you want randInt(X,Y), do rand^(Y-X)+X instead.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Help Request - ERROR INVALID TOKEN
« Reply #8 on: December 02, 2013, 05:09:32 pm »
You are missing a +1 in the Y-X, otherwise, randInt(0,1) would be rand^1+0 which always returns 0 ;)
Also, while yours gives the general solution, the particular solution was given in ben_g's first post.
« Last Edit: December 02, 2013, 05:10:19 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 ClrDraw

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 627
  • Rating: +61/-2
    • View Profile
    • GitHub
Re: Help Request - ERROR INVALID TOKEN
« Reply #9 on: December 02, 2013, 10:33:35 pm »
It can be annoying getting used to the little things Axe does funny but stay with it and it will get way easier. The only thing that still bugs the crap out of me is the lack of negative numbers...  :w00t:
Visit my GitHub for all my TI programs as well as other projects.
Also check out my website.

Offline Omar Chehab

  • LV2 Member (Next: 40)
  • **
  • Posts: 30
  • Rating: +0/-0
    • View Profile
Re: Help Request - ERROR INVALID TOKEN
« Reply #10 on: December 02, 2013, 10:35:36 pm »
Thank you, all!

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Re: Help Request - ERROR INVALID TOKEN
« Reply #11 on: December 03, 2013, 04:56:05 am »
It can be annoying getting used to the little things Axe does funny but stay with it and it will get way easier. The only thing that still bugs the crap out of me is the lack of negative numbers...  :w00t:

err.. negative number in axe does exist, they just a little different that we expect. As we work with 2 bytes number, negative number start from the highest value possible, and then progressively decrease (well, idk if I am very clear) : some code :

Code: [Select]
-1->B   //this is a correct syntax

//now B=65535
Disp B>Dec,i
//and you can do :
B*8->B
Disp B>Dec,i
//B still negative !
//B=65528   (-8)
B*-1->B    //we now get a positive number
Disp B>Dec,i     //B=8

in fact on two bytes we can code  number from -32767 to 32768 using this method (who is implement in axe)
You may find that if the multiplication is signed, the division (/) is not. However it exist a signed division (it's the // symbol)
AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline ClrDraw

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 627
  • Rating: +61/-2
    • View Profile
    • GitHub
Re: Help Request - ERROR INVALID TOKEN
« Reply #12 on: December 03, 2013, 08:37:28 am »
True I should have cleared up. I meant how confusing it can be using negative numbers. Especially how with regular variables, -1 is 65535 but with variables in L1 its 255... I had to mess with all that in my game blox.
But thank you I didn't know the division thing  :)
« Last Edit: December 03, 2013, 08:38:30 am by ClrDraw »
Visit my GitHub for all my TI programs as well as other projects.
Also check out my website.

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Re: Help Request - ERROR INVALID TOKEN
« Reply #13 on: December 03, 2013, 11:17:40 am »
it's pretty strange then  :o  cause if you use variable in L1 you have exactly the same thing than with  a normal var (it's just a memory location in all case). Can I see some problematic code please ?
AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Help Request - ERROR INVALID TOKEN
« Reply #14 on: December 03, 2013, 01:16:17 pm »
With one byte values in memory you have to use signed{} to convert 8 bit and 16 bit signed numbers. Actually the way signed numbers work in Axe and ASM is called two's complement which is a particular way to code negative numbers and have them usable exactly like positive ones with the same operations (due to the way modular math works). I hope I make sense. If not, look it up on Wikipedia. ;)
« Last Edit: December 03, 2013, 01:17:02 pm by Streetwalker »