Omnimaga

Calculator Community => TI Calculators => Grammer => Topic started by: persalteas on April 25, 2012, 07:59:41 am

Title: Find the error in a beginner's program
Post by: persalteas on April 25, 2012, 07:59:41 am
Hello, first I have a question: who programs with Grammer here ? Just Xeda ?


Then I would these programers to tell we where are my error(s) in this program:

It's a base converter from decimal. (it is supposed to be  ;D )

The display always starts with a value that I didn't ask for, and then the right value.

Code: [Select]
:.0:Return→B
:ClrDraw
:Line(1,5,9,95,6
:Line(0,6,9,95,6
:Text(8,5,"Base Converter
:/Text(18,0,"Base ?
:DispGraph
:expr(Input →G
:/Text(18,0,"Valeur Décimale ?
:DispGraph
:expr(Input →AC'
:/Text(30,0,"= "
:Text('°AC',G
:DispGraph
:Repeat getkey
:End
:If =15
:Goto B
:ClrDraw:DispGraph
:Stop

And then, I have some questions about the Input command:

- is there a mean to forbid other tokens than alphanumeric ? (like pressing a key [stat],[On] etc...)
- When should the "two-points" appear on the screen ? Before or after pressing the first key ?  (ow my syntax...  <_< )
- The text in the Input is displayed like with /Text(  , letter-by-letter. Is that normal ?
Title: Re: Find the error in a beginner's program
Post by: Sorunome on April 25, 2012, 08:11:27 am
Damn, grammer changed quite a lot since I last programmed with it O.o
And if these should be commented lines, they need a double-slash (//)
Title: Re: Find the error in a beginner's program
Post by: jsj795 on April 25, 2012, 08:29:15 am
I believe Yeong also programs in grammer. I don't, so I can't really help you :(
Title: Re: Find the error in a beginner's program
Post by: Sorunome on April 25, 2012, 09:25:06 am
Yeah, Yeong is quite good at grammer :)
Title: Re: Find the error in a beginner's program
Post by: Hayleia on April 25, 2012, 09:32:45 am
I believe Yeong also programs in grammer. I don't, so I can't really help you :(
Yeah, Yeong is quite good at grammer :)
I believe he is also writing a tutorial (but in English), if you need help
(I am talking to persalteas, even if I quoted everyone but him :P)
Title: Re: Find the error in a beginner's program
Post by: persalteas on April 25, 2012, 10:04:11 am
Okay...

*persalteas poke Yeong...  (or Xeda, sure)
Title: Re: Find the error in a beginner's program
Post by: Yeong on April 29, 2012, 07:54:00 pm
I just saw this topic.
I'll have to leave soon, but I'll get you the answer by tomorrow ;)
EDIT: Actually, your code is not wrong, but it's input itself. It somehow stores "14" in A when I tried with number 255.
Title: Re: Find the error in a beginner's program
Post by: persalteas on April 30, 2012, 11:07:11 am
Do you know how to solve the problem ?

storing 0 in A before the Input ?
Title: Re: Find the error in a beginner's program
Post by: Xeda112358 on April 30, 2012, 11:46:34 am
Okay, I believe the problem is just that you have :expr(Input →AC' Input will not normally handle numbers >65535 x.x. I also changed a few things:
Code: [Select]
:.0:             ;This line gets ignored because it starts with "."
:Return→B
:ClrDraw
:Line(1,5,9,95,6
:Line(0,6,9,95,6
:Text(8,5,"Base Converter
:/Text(18,0,"Base ?
:DispGraph
:expr(Input →G
:/Text(18,0,"Valeur Décimale ?
:DispGraph
:expr(Input →A  ;
:/Text(30,0,"= "
:Text('°A,G
:DispGraph
:Repeat         ;Added a space here. Just a single space means it uses the last value
:getkey         ;"Repeat getKey" does not change ans
:End
:If =15
:Goto B
:ClrDraw:DispGraph
:Stop

By the way, it looks nice o.o
Title: Re: Find the error in a beginner's program
Post by: persalteas on April 30, 2012, 12:06:28 pm
OK, Thanks :)

but
Code: [Select]
:Repeat         ;Added a space here. Just a single space means it uses the last value
:getkey         ;"Repeat getKey" does not change ans
:End

Is one byte heavier...
Title: Re: Find the error in a beginner's program
Post by: Xeda112358 on April 30, 2012, 12:07:47 pm
Yeah :/ But otherwise, your next line would not work:
Code: [Select]
If =15
Goto B
Title: Re: Find the error in a beginner's program
Post by: persalteas on April 30, 2012, 12:09:22 pm
euh....

yes, it works... That wasn't a problem, it worked fine...
Title: Re: Find the error in a beginner's program
Post by: Yeong on April 30, 2012, 03:21:46 pm
If Grammer works the way that xeda had not intended it to do, just understand: Grammer has its own AI.
Title: Re: Find the error in a beginner's program
Post by: persalteas on April 30, 2012, 03:23:25 pm
Just try it, you will see... The getkey is stored in Ans, even with my code... It works.

If you press enter, the program restarts, if you press another key, it exits.
Title: Re: Find the error in a beginner's program
Post by: Yeong on April 30, 2012, 03:24:03 pm
I think xeda think it didn't works because the slight hold of the key makes it look like it doesn't work.
Title: Re: Find the error in a beginner's program
Post by: Xeda112358 on April 30, 2012, 03:26:01 pm
@persalteas: If you press Enter, it is executing again from the homescreen, not relooping. Your code is looking for the [Clear] key.
[clear]=15
[enter]=9

If you want, try to put a Pause 20 in there before the Repeat loop and see what happens ;)

@Yeong: I think it doesn't work because I programmed If, Repeat, and While to not affect Ans :P
Title: Re: Find the error in a beginner's program
Post by: persalteas on April 30, 2012, 03:28:28 pm
Quote
@persalteas: If you press Enter, it is executing again from the homescreen, not relooping. Your code is looking for the [Clear] key.
[clear]=15
[enter]=9
/me runs far far away and never comes back...
Title: Re: Find the error in a beginner's program
Post by: Xeda112358 on April 30, 2012, 03:31:00 pm
Hehe :P 'Tis okay, you are using Return properly, which is great (Return is really fast, by the way, especially compared to using labels).
Title: Re: Find the error in a beginner's program
Post by: Yeong on April 30, 2012, 10:59:26 pm
Oh I guess I wasn't reading posts clearly. :\