Was the old I Cant Figure Out Whats Happening thread new Question at bottom. Ill will post new question when they come around and post fixed on the question or the last post on that question. The Error question is resolved but I have a new one at the bottom of this thread. Thanks for reading.


It gives me a syntax error every time I run a menu option except for the menu options of 5.1 and Exit. Here is the code:
Code:
:ClrHome
:Lbl 0
:Menu("        Programs           ","5.1",A,"5.2",B,"5.3",C,"5.4",D,"5.5",E,"5.6",F,"Exit",Z
:Lbl Z
:ClrHome
:DelVar ADelVar B
:DelVar CDelVar DDelVar E
:DelVar FDelVar G
:Stop
:Lbl A
:ClrHome
:Output(1,1,"Welcome 5.1
:Pause
:Goto 0
:Lbl B
:ClrHome
:Output(1,1,"Welcome 5.2
:Output(2,1,"< LessTHAN > GreatOR
:Pause
:Goto 0
:Lbl C
:ClrHome
:Output(1,1,"Welcome 5.3
:Pause
:Goto 0
:Lbl D
:ClrHome
:Output(1,1,"Welcome 5.4
:Pause
:Goto 0
:Lbl E
:ClrHome
:Output(1,1,"Welcome 5.5
:Pause
:Goto 0
:Lbl F
:ClrHome
:Output(1,1,"Welcome 5.6
:Pause
:Goto 0
What is the exact line that the code errors?
When I run Options 5.2 - 5.6 they give me a syntax error it seem to work fine on 5.1 when I run that
FrozenFire49 wrote:
What is the exact line that the code errors?


When you receive the error, please chose [Goto] and let us know which line it puts you on. That way we can have an idea what line of the program is having trouble.
I would like to im just not given that option when it happens
I have doors CS 8 for TI-84 Plus C CE
Ok got it now it says its the Pause
There are spaces everywhere, dude...I errored in the beginning of the run(which was after "Lbl 0")
Removed spaces, try it.


Code:
:ClrHome
:Lbl 0
:Menu("        Programs           ","5.1",A,"5.2",B,"5.3",C,"5.4",D,"5.5",E,"5.6",F,"Exit",Z
:Lbl Z
:ClrHome
:DelVar ADelVar B
:DelVar CDelVar DDelVar E
:DelVar FDelVar G
:Stop
:Lbl A
:ClrHome
:Output(1,1,"Welcome 5.1
:Pause
:Goto 0
:Lbl B
:ClrHome
:Output(1,1,"Welcome 5.2
:Output(2,1,"< LessTHAN > GreatOR
:Pause
:Goto 0
:Lbl C
:ClrHome
:Output(1,1,"Welcome 5.3
:Pause
:Goto 0
:Lbl D
:ClrHome
:Output(1,1,"Welcome 5.4
:Pause
:Goto 0
:Lbl E
:ClrHome
:Output(1,1,"Welcome 5.5
:Pause
:Goto 0
:Lbl F
:ClrHome
:Output(1,1,"Welcome 5.6
:Pause
:Goto 0
Fixed but another question is at the bottom.
Please don't double-post, and please don't create two different topics for the same problem. Also, proper spelling and grammar is very important to us (including punctuation).
nitrohawk80 wrote:
Fixed


How did you fix it? Did you remove the spaces?
It was because there was no space after the Pause.
I have another question for a different menu here is the code:
Code:
:ClrHome
:Lbl 0
:Menu("GameControls","Test Menu 1",A,"Test Menu 2",B,"Exit",99
:Lbl 99
:ClrHome
:Stop
:Lbl A
:ClrHome
:Output(1,1,"Controls For Game
:Pause
:If MODE Is Pressed Goto G1 <--- This is the line I was hoping would work
:Goto 0
:Lbl B
:ClrHome
:Output(1,1,"Controls For Game 2
:Pause
:Goto 0
:Lbl G1
:prgmTESTONE

I want to get it where if you push a certain button on the calculator it will bring the user to the Goto _ command and be able to run what ever is put in the Lbl _ area. So Basically you Push MODE for ex and it will bring you to Lbl G1 which will run a program but I want it to be able to happen when text is displayed, then hit mode or what other button with the text up other wise it will bring you back to the main menu when you hit enter.
Are you saying you want arbitrary Gotos? That's possible only with clever manipulation using Hybrid BASIC. However, if you're asking about specific keys, you'll need to use the getKey command. getKey returns 0 if nothing is pressed, or a number indicating what key is pressed if a key is being pressed. Y= is 11, WINDOW is 12, ..., GRAPH is 15; 2nd is 21, MODE is 22, ...; ALPHA is 31; down to ENTER = 105. ON has no key code. The arrow keys are left=24, up=25, right=26, and down=34. For more information, you could always check out a certain book, which gives some demos and has a nice diagram of those key codes. Wink
Thanks for the help Kerm ill have to check out your book as soon as I can. Wink Im still having some problems with my code Here it is: When I hit Enter once It turns the spinner yellow then I can input the MODE key or the Enter key again. But when I hit either the MODE key or the Enter key it just closes the program but I what I want it to run the prgmPROJECT when MODE is hit and when Enter is hit that second time it brings the user back to the Menu. I'm just at a blank on how to pull that off. Ive tried rewriting in different ways but still at a loss.
Code:
ClrHome
Lbl 0
Menu("GameControls","Test Menu 1",A,"Test Menu 2",B,"Exit",99
Lbl 99
ClrHome
DelVar D
Stop
Lbl A
ClrHome
Output(1,1,"Controls For Game
Pause
getKey->D
If D=22:Then
Goto G1
If D=0:Then
Goto 0
Lbl B
ClrHome
Output(1,1,"Controls For Game 2
Pause
Goto 0
Lbl G1
prgmPROJECT
You need to put the getKey in a tight loop. getKey will return 0 immediately if no key is pressed; it will not "pause" until a key is pressed, then return that code. We normally use something like:
Code:
Repeat K
getKey->K
End
Ok Kerm heres the revised code but I cant seem to get it to work heres code new problem text displays for only a split second and in that time you can hit mode to go to the prgmPROJECT but if you dont hit MODE it just brings you back to the Menu. Thanks for the help i'm just tying to understand this code language still.
Code:
ClrHome
Lbl 0
Menu("GameControls","Test Menu 1",A,"Test Menu 2",B,"Exit",99
Lbl 99
ClrHome
DelVar D
Stop
Lbl A
ClrHome
Output(1,1,"Controls For Game
Repeat D
getKey->D
If D=22:Then
prgmPROJECT
End
If D=0:Then
Goto 0
Lbl B
ClrHome
Output(1,1,"Controls For Game 2
Pause
Goto 0

Code:
:Lbl A
:ClrHome
:Output(1,1,"Controls For Game"
:Repeat D         //Beginning of Repeat loop
:getKey->D
:If D=22:Then
:prgmPROJECT
:End          //End of If...Then block
:If D=0:Then
:Goto 0
:Lbl B
:ClrHome
:Output(1,1,"Controls For Game 2"
:Pause 
:Goto 0


This code is lacking the ":End" command for the Repeat loop. The ":If D=0:Then:Goto 0" is the problem. Because the "Then" is present, if a key isn't pressed (making getKey 0) it goes back to the main menu (Lbl 0) without looping. The program sees the :End as the end of that If...Then block, not as the end of the Repeat loop. Because it doesn't find the end of the loop, it continues through the program and won't loop at all.

If commands that only run for a single line when true don't use a Then command in addition to not using the :End command. Here's what the code snippet becomes when the fix is applied:

Code:
:Lbl A
:ClrHome
:Output(1,1,"Controls For Game"
:Repeat D         //Beginning of Repeat loop
:getKey->D
:If D=22
:prgmPROJECT
:End          //End of Repeat loop
:If D=0
:Goto 0
:Lbl B
:ClrHome
:Output(1,1,"Controls For Game 2"
:Pause 
:Goto 0


The ":If D=0" block will never run, as the Repeat loop only exits when D≠0.
Thank you for your help CVSoft. Program is working great and no errors Thanks again for the help. Also this question has been resolved.
Another important point: You should never use a Goto inside If:Then:...:End or similar constructs, because it will cause what is called a memory leak. Until the program ends or errors out, the calculator will keep looking for that End, gradually slowing down your program until eventually you'll get an ERR:MEMORY. If you want to make a Goto conditional, always use If <condition>:Goto with no Then/End.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement