How To Create Buttons Within Programs?
Posted 02 March 2012 - 06:41 PM
I would like to write a program using buttons. So, for example, when the program is first launched, a screen appears with a number of options. Let's say if F1' /> the program is told to Goto 1, and the code under Lbl 1 would come on screen, and if the program was executed again and F2' /> was pressed, then Goto 2 would be shown for example.
I assume this uses loops but I'm quite new to programming and don't know how to use loops to make buttons.
Hope you can help. Thanks.
Posted 02 March 2012 - 06:49 PM
Here is a simple way to do it:
While not Getkey //loop while no button is pressed Getkey -> G WhileEnd G=79 => Goto 1 //If F1 is pressed, goto 1 (79 is the code for F1) G=29 => Goto 2 Lbl 1 Stuff to do if f1 is pressed Lbl 2 stuff to do if f2 is pressed
Hope that helps
Posted 03 March 2012 - 07:20 PM
I tried this code: [codebox]Goto 3
"I Just Pressed F1"
"I Just Pressed F2"
While Not Getkey
Getkey -> G
Then Goto 1
Then Goto 2
And it doesn't work, just says 'Done'. What am I doing wrong with this modification to the previous code?
Posted 26 March 2012 - 07:39 PM
While Getkey=0 or Getkey =21 //loop while no button is pressed Getkey -> G WhileEnd G=79 => Goto 1 //If F1 is pressed, goto 1 (79 is the code for F1) G=29 => Goto 2 Lbl 1 Stuff to do if f1 is pressed Lbl 2 stuff to do if f2 is pressed
Posted 08 February 2014 - 02:49 AM
Do Getkey->G LpWhile G≠79 And G≠29 G=79 => Goto 1 G=29 => Goto 2 Lbl 1 Stuff to do if f1 is pressed Lbl 2 stuff to do if f2 is pressed
Posted 09 February 2014 - 04:36 AM
goto's are not the best coding practices. Maybe this code would be faster (slightly)?
Do Getkey->G LpWhile G≠79 And G≠29 If G=79 Then 'Stuff to do if f1 is pressed If G=29 Then 'stuff to do if f2 is pressed
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users