Jump to content



Photo
- - - - -

How To Create Buttons Within Programs?


  • Please log in to reply
5 replies to this topic

#1 Alfie Stoppani

Alfie Stoppani

    Newbie

  • Members
  • Pip
  • 13 posts
  • Gender:Male

  • Calculators:
    Fx-9750Gii (with OS 2.00.0200 updated and installed)

Posted 02 March 2012 - 05:41 PM

Hi,

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 <span class=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 <span class=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.

Alf <:3D~

#2 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 02 March 2012 - 05:49 PM

Ok.

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 ;)

#3 Alfie Stoppani

Alfie Stoppani

    Newbie

  • Members
  • Pip
  • 13 posts
  • Gender:Male

  • Calculators:
    Fx-9750Gii (with OS 2.00.0200 updated and installed)

Posted 03 March 2012 - 06:20 PM

I can't get your code to work, it just shows the things in labels 1 & 2 simultaneously, and seems to bypass the getkey looping bit.

I tried this code: [codebox]Goto 3
Lbl 1
"I Just Pressed F1"
Goto 0
Lbl 2
"I Just Pressed F2"
Goto 0
Lbl 3
While Not Getkey
Getkey -> G
WhileEnd

If G=79
Then Goto 1
If End

If G=69
Then Goto 2
If End

Lbl 0[/codebox]

And it doesn't work, just says 'Done'. What am I doing wrong with this modification to the previous code?

Alf.

#4 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 26 March 2012 - 06:39 PM

Oh wait, try this:

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


#5 somebody1234

somebody1234

    Casio Addict

  • Members
  • PipPipPip
  • 51 posts

  • Calculators:
    Casio fxcg10
    Casio fx-9860GII
    Casio Classpad 400

Posted 08 February 2014 - 01:49 AM

Maybe you can use Do LpWhile to loop unless f1 or f2 is pressed:
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


#6 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 09 February 2014 - 03:36 AM

That works.

Also, Lbl's and 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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users