Author Topic: Find the error in a beginner's program  (Read 14494 times)

0 Members and 1 Guest are viewing this topic.

Offline persalteas

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 231
  • Rating: +44/-4
  • z80 poweeer
    • View Profile
    • Tout-82
Find the error in a beginner's program
« 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 ?


Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Find the error in a beginner's program
« Reply #1 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 (//)

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline jsj795

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1105
  • Rating: +84/-3
    • View Profile
Re: Find the error in a beginner's program
« Reply #2 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 :(


Spoiler For funny life mathematics:
1. ROMANCE MATHEMATICS
Smart man + smart woman = romance
Smart man + dumb woman = affair
Dumb man + smart woman = marriage
Dumb man + dumb woman = pregnancy
2. OFFICE ARITHMETIC
Smart boss + smart employee = profit
Smart boss + dumb employee = production
Dumb boss + smart employee = promotion
Dumb boss + dumb employee = overtime
3. SHOPPING MATH
A man will pay $2 for a $1 item he needs.
A woman will pay $1 for a $2 item that she doesn't need.
4. GENERAL EQUATIONS & STATISTICS
A woman worries about the future until she gets a husband.
A man never worries about the future until he gets a wife.
A successful man is one who makes more money than his wife can spend.
A successful woman is one who can find such a man.
5. HAPPINESS
To be happy with a man, you must understand him a lot and love him a little.
To be happy with a woman, you must love her a lot and not try to understand her at all.
6. LONGEVITY
Married men live longer than single men do, but married men are a lot more willing to die.
7. PROPENSITY TO CHANGE
A woman marries a man expecting he will change, but he doesn't.
A man marries a woman expecting that she won't change, and she does.
8. DISCUSSION TECHNIQUE
A woman has the last word in any argument.
Anything a man says after that is the beginning of a new argument.

Girls = Time * Money (Girls are a combination of time and money)
Time = Money (Time is money)
Girls = Money squared (So, girls are money squared)
Money = sqrt(Evil) (Money is also the root of all evil)
Girls = sqrt(Evil) squared (So, girls are the root of all evil squared)
Girls = Evil (Thus, girls are evil)
*Girls=Evil credit goes to Compynerd255*

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Find the error in a beginner's program
« Reply #3 on: April 25, 2012, 09:25:06 am »
Yeah, Yeong is quite good at grammer :)

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Find the error in a beginner's program
« Reply #4 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)
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 persalteas

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 231
  • Rating: +44/-4
  • z80 poweeer
    • View Profile
    • Tout-82
Re: Find the error in a beginner's program
« Reply #5 on: April 25, 2012, 10:04:11 am »
Okay...

*persalteas poke Yeong...  (or Xeda, sure)
« Last Edit: April 25, 2012, 10:04:36 am by persalteas »


Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Find the error in a beginner's program
« Reply #6 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.
« Last Edit: April 29, 2012, 08:09:31 pm by TBO_Yeong »
Sig wipe!

Offline persalteas

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 231
  • Rating: +44/-4
  • z80 poweeer
    • View Profile
    • Tout-82
Re: Find the error in a beginner's program
« Reply #7 on: April 30, 2012, 11:07:11 am »
Do you know how to solve the problem ?

storing 0 in A before the Input ?


Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Find the error in a beginner's program
« Reply #8 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

Offline persalteas

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 231
  • Rating: +44/-4
  • z80 poweeer
    • View Profile
    • Tout-82
Re: Find the error in a beginner's program
« Reply #9 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...


Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Find the error in a beginner's program
« Reply #10 on: April 30, 2012, 12:07:47 pm »
Yeah :/ But otherwise, your next line would not work:
Code: [Select]
If =15
Goto B

Offline persalteas

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 231
  • Rating: +44/-4
  • z80 poweeer
    • View Profile
    • Tout-82
Re: Find the error in a beginner's program
« Reply #11 on: April 30, 2012, 12:09:22 pm »
euh....

yes, it works... That wasn't a problem, it worked fine...


Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Find the error in a beginner's program
« Reply #12 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.
Sig wipe!

Offline persalteas

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 231
  • Rating: +44/-4
  • z80 poweeer
    • View Profile
    • Tout-82
Re: Find the error in a beginner's program
« Reply #13 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.


Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Find the error in a beginner's program
« Reply #14 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.
Sig wipe!