Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Yeong on September 15, 2011, 11:40:58 am
-
How do I write a routine so that if I press the correspond button, do something and if I don't press it, do other thing?
-
The following would work, If I understood well the question (spaces are not needed, just to see better).
Lbl (name)
If getkey(the number)
commands
Else
commands
End
Return
-
I don't code in Axe, but it might be something like this:
If getKey(*key*)
Then
<<code if key is pressed>>
Else
<<code if key isn't pressed>>
End
Again, I don't know if this will work :/
-
I don't code in Axe, but it might be something like this:
If getKey(*key*)
Then
<<code if key is pressed>>
Else
<<code if key isn't pressed>>
End
Again, I don't know if this will work :/
This will not work, as "Then" is not an Axe token, but the idea is here, in my opinion.
-
Cool, thanks! I need to learn Axe sometime XD
-
I forgot to mention timer XP
So, I'll rephrase the question(This happens a lot to me these days)
How do I write a routine so that if I press the correspond button in certain amount of time, do something and if I don't press it, do other thing?
-
Should work
0->A
...
If getkey(key)
A+1->A
Else
0->A
End
If A=(your_timer)
commands...
Else
other commands...
End
-
time→C ;example: 1000→C
!While C*getKey(*key*)
C-1→C
End
If C
<<code if key is pressed>>
Else
<<Code if key isn't pressed>>
End
I think this will work, again, i am not sure XD
-
Thanks, but why do I multiply C with getKey?
can you explain it for me?
-
If C=0, the loop will exit (if the key is still pressed).
-
ok. thanks for the explanation.
-
Oops, I just realised that won't work. Let me rethink this...
-
lol indeed, it should be !If C in the test under the While loop.
-
let me see...
We want to exit the loop if the key is pressed or time reaches 0.
so just do !While C=0+getKey(*key*)
C=0+getKey(*key*) is only 0 if the key isn't pressed and C is not 0
If C is 0 or the key is pressed, the result is 1
We test for C because if it is 0, it means time ran out. So we do use If C
-
It will stay in the loop all the time if he doesn't press the key right ?
-
Not the last one. The loop will exit if he presses the key or time runs out :)
-
!While C=0+getKey(*key*)
So in the beginning C=0 returns 0 and getkey(key) returns 0 and !While continues if the condition is false right ?
EDIT : Er I see what you mean didn't see the C-1->C in the loop.
-
I believe so... Again, I have never used any of this in Axe, so I am not sure. I just remember reading a tutorial for 2.4 or something like that and I am pretty sure that is how the math and While loops work :)
-
Thanks for the help :D
I got the routine working XD
-
Cool! Also, you almost have 1000 posts!
-
I relised XD
*Yeong can't wait to display his custom title under his nickname