Page 1 of 1

SpinGadget Word Branching

Posted: Sat Dec 15, 2012 10:41 am
by electrochrisso
Use the SpinGadget and words to branch off, by using the state of the spin gadget in a Case statement.

Code: Select all

NewList Fruit.s()
AddElement(Fruit()) : Fruit() = "Apple"
AddElement(Fruit()) : Fruit() = "Banana"
AddElement(Fruit()) : Fruit() = "Orange"
AddElement(Fruit()) : Fruit() = "Peach"
AddElement(Fruit()) : Fruit() = "Pear"

If OpenWindow(0, 0, 0, 140, 70, "SpinGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  SpinGadget(0, 20, 20, 100, 20, 1, 5)
  SelectElement(Fruit(), 0)
  SetGadgetState(0, 0) : SetGadgetText(0, Fruit())
  ButtonGadget(1, 20, 45, 100, 20, "Debug")
  Repeat
    Event = WaitWindowEvent()
    If Event = #PB_Event_Gadget
      If EventGadget() = 0
        SelectElement(Fruit(), GetGadgetState(0) -1)
        SetGadgetText(0, Fruit())
      ElseIf EventGadget() = 1
        Select GetGadgetState(0) -1
            Case 0
              Debug "Nice and crunchy"
            Case 1
              Debug "Full of goodness"
            Case 2
              Debug "Nice and juicy"
            Case 3
              Debug "Great with cream"
            Case 4
              Debug "Hmm, not bad"
        EndSelect
      EndIf
    EndIf
  Until Event = #PB_Event_CloseWindow
EndIf

Re: SpinGadget Word Branching

Posted: Sat Dec 15, 2012 9:34 pm
by VB6_to_PBx
electrochrisso,
thank you for great example

Re: SpinGadget Word Branching

Posted: Sat Dec 15, 2012 10:32 pm
by electrochrisso
VB6_to_PBx wrote:electrochrisso,
thank you for great example
Glad you like it. :)