Here is a basic GUI menu I am slowly working on.
Forgot to mention I only have 1 key mapped for testing reasons.
BASIC Code wrote:
:ClrHome
:ClrDraw
:DispGraph
:44→X:‾47→Y
:70→N:‾55→O
:95→P:‾63→Q
:Line(X,Y,P,Y,1
:Line(X,Y,X,Q,1
:Line(X,Q,P,Q,1
:Line(X,O,P,O,1
:Line(P,Q,P,Y,1
:Line(N,Y,N,Q,1
:Text(47,45,"ATTACK
:Text(47,72,"MAGIC
:Text(55,72,"ITEMS
:Text(55,45,"ESCAPE
:45→T:‾48→U
:69→V:‾54→W
:1→Z
:Goto 1
:End
:Lbl 0
:Line(T,U,V,U,0
:Line(T,U,T,W,0
:Line(V,W,V,U,0
:Line(V,W,T,W,0
:Goto 2
:End
:Lbl 1
:Line(T,U,V,U,1
:Line(T,U,T,W,1
:Line(V,W,V,U,1
:Line(V,W,T,W,1
:Goto 2
:End
:Lbl 2
:While 1
:¦ getKey→K
:¦ While K=1
:¦ ¦ getKey→K
:¦ End
:¦ If K=26
:¦ ClrDraw
:¦ Goto 0
:End
:If K=24
:Goto 0
:End
:If K=25
:Goto 1
:End
:If K=34
:End
Generated by SourceCoder, © 2005-2010 Cemetech
Ok, the proper way to utilize a While command:


Code:
1->W
While W=1
getKey->K
If K:Then:Stuff:End
End


Any time you want to exit out of the loop, you merely change the value of W. Or delete it, if you like.

As to your program.. I highly recommend you steer clear of them evil Goto and Lbl commands. Others might disagree, that used correctly they are ok and such, but when dealing with loops and the like, it is best to just not use them if at all possible. The above code rewritten to what I would use:


Code:
:ClrHome
:ClrDraw
:1→A:While A=1
:44→X:‾47→Y
:70→N:‾55→O
:95→P:‾63→Q
:Line(X,Y,P,Y
:Line(X,Y,X,Q
:Line(X,Q,P,Q
:Line(X,O,P,O
:Line(P,Q,P,Y
:Line(N,Y,N,Q
:Text(47,45,"ATTACK
:Text(47,72,"MAGIC
:Text(55,72,"ITEMS
:Text(55,45,"ESCAPE
:45→T:‾48→U
:69→V:‾54→W
:1→Z:2→A
:While A=2
:Line(T,U,V,U
:Line(T,U,T,W
:Line(V,W,V,U
:Line(V,W,T,W
:3→A:While A=3
:getKey→K
:If K:Then
:Line(T,U,V,U,0
:Line(T,U,T,W,0
:Line(V,W,V,U,0
:Line(V,W,T,W,0
:End
If K=##:Then:Movement code here:2→A:End
End
End


I haven't tried this specific code on calc, but it looks like it should work without a hitch.
I'm going to troubleshoot, but it gives a Syntax error, then when I hit go to, it goes to the ClrHome.
Umm.. did you copy/paste this to SAX and then export as an .8xp?
Yes, then I fixed the bits that wouldnt work on the calc.
Ah..

Copying directly from the forum will leave spaces at the end of everything, so you know. Not a good idea to copy from here to paste. Best to just type in what you see so you know those problems won't be there :p
ahh, I started, then decided it was really loooong, and I figured it would be faster, though deleting the spaces would be shorter.
It works, but I will have to find out why the lines go all the way up and off the screen.
Better than:
Code:
1->W
While W=1
getKey->K
If K:Then:Stuff:End
End
is this:
Code:
1->W
Repeat not(W
getKey->K
If Ans:Then:Stuff:End
End
Saves a byte and a few fractions of a sec. Smile
  
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 1
» 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