[Newby] Spingadget and decimal value

Just starting out? Need help? Post your questions and find answers here.
buzzqw
Enthusiast
Enthusiast
Posts: 116
Joined: Sat Aug 27, 2005 10:13 pm
Location: Italy
Contact:

[Newby] Spingadget and decimal value

Post by buzzqw »

Hi all

i have a spingadget that must be increased/decreased by decimal factor

like

0,0.1,0.2,0.3 ... (till 1)
another that go from -1 to +1 (-1,-0.9,-0.8..,0,+0.1,0.2..,1)
and another that go from -100 to +100 (-100,-99,-98,..,0,1,2,..,100)

any tips?

thanks !

BHH
Chris
User
User
Posts: 60
Joined: Wed Jun 11, 2003 4:54 pm
Location: Somewhere... But i can see you!

Post by Chris »

Perhaps one way !

Code: Select all

  If OpenWindow(0,0,0,140,120,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"SpinGadget") And CreateGadgetList(WindowID(0))
    SpinGadget     (0,20,20,100,25,0,10)
    SpinGadget     (1,20,50,100,25,0,20)
    SpinGadget     (2,20,80,100,25,0,200)
    
    SetGadgetState (0,0) : SetGadgetText(0,StrF(GetGadgetState(0),2))   ; set initial value
    SetGadgetState (1,0) : SetGadgetText(1,StrF((GetGadgetState(1)-10)/10,2))   ; set initial value
    SetGadgetState (2,0) : SetGadgetText(2,StrF((GetGadgetState(2)-100)/10,2))   ; set initial value
    
    Repeat
      Event = WaitWindowEvent()
      If EventGadgetID() = 0
        Spin_0.f = GetGadgetState(0)/10
        SetGadgetText(0,StrF(Spin_0,2))
      ElseIf EventGadgetID() = 1
        Spin_1.f = (GetGadgetState(1)-10)/10
        SetGadgetText(1,StrF(Spin_1,2))
      ElseIf EventGadgetID() = 2
        Spin_2.f = (GetGadgetState(2)-100)
        SetGadgetText(2,StrF(Spin_2,2))
        
        WindowEvent()
      EndIf
    Until Event = #PB_Event_CloseWindow
  EndIf
My english is bad !!!... It's normal, i'm french :lol:
My english is not really the English.
It's the FrogLish (Froggy's English) ;)
buzzqw
Enthusiast
Enthusiast
Posts: 116
Joined: Sat Aug 27, 2005 10:13 pm
Location: Italy
Contact:

Post by buzzqw »

Genius !

thanks !!

BHH
Post Reply