Multiple Sliders

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
calmrr3
Posts: 100
Joined: Mon Oct 28, 2013 2:39 pm

Multiple Sliders

Post by calmrr3 » Tue Oct 29, 2013 4:12 pm

Hi, I am trying to make a card which has 29 sliders and when each slider is at a particular value, it goes to the next card. I can't get it to work, this is the script I have for the card at the moment:

if

the thumbpos of "slider1" = 49 and
the thumbpos of "slider2" = 47 and
the thumbpos of "slider3" = 45 and
the thumbpos of "slider4" = 43 and
the thumbpos of "slider5" = 40 and
the thumbpos of "slider6" = 38 and
the thumbpos of "slider7" = 38 and
the thumbpos of "slider8" = 36 and
the thumbpos of "slider9" = 34 and
the thumbpos of "slider10" = 33 and
the thumbpos of "slider11" = 30 and
the thumbpos of "slider12" = 31 and
the thumbpos of "slider13" = 34 and
the thumbpos of "slider14" = 36 and
the thumbpos of "slider15" = 36 and
the thumbpos of "slider16" = 41 and
the thumbpos of "slider17" = 42 and
the thumbpos of "slider18" = 46 and
the thumbpos of "slider19" = 47 and
the thumbpos of "slider20" = 47 and
the thumbpos of "slider21" = 47 and
the thumbpos of "slider22" = 47 and
the thumbpos of "slider23" = 47 and
the thumbpos of "slider24" = 46 and
the thumbpos of "slider25" = 46 and
the thumbpos of "slider26" = 47 and
the thumbpos of "slider27" = 48 and
the thumbpos of "slider28" = 50 and
the thumbpos of "slider29" = 51

then go to the next card

Thanks!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Multiple Sliders

Post by dunbarx » Tue Oct 29, 2013 5:35 pm

Hi.

Well, I thought I would just whip out one possible correct answer, cleverly putting your handler snippet into the card script, but I decided to check first. So hold that thought, unless someone else chimes in

I have a problem with the following. In a slider script:

Code: Select all

on scrollbarDrag
   put the thumbpos of scrollbar 1 into temp
   if temp = 10  then
      answer "OK"
   end if
end scrollbarDrag

on scrollbarDrag
   put the thumbpos of scrollbar 1 into fld 1
   if fld 1 = 10  then
      answer "OK"
   end if
end scrollbarDrag
The first handler will not work when the thumb hits 10, the second one will. The difference is only the use of a variable as opposed to a field value. The msg box works just fine as well. Thinking there was something dynamic going on with the scrollBarDrag message, I also tried it with "mouseUp". Same issue. No problem, however, if I try for "if temp < 10" as opposed to "temp = 10".

And I know that the thumbPos is often not an integer, however it is displayed. But getting the trunc of that function does not help.

What gives?

Craig Newman

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Multiple Sliders

Post by Simon » Tue Oct 29, 2013 5:49 pm

I did:

Code: Select all

 if the round of thumbpos of sb 1 = 10 and the round of thumbpos of sb 2 = 10 then
That is working.

Found that by:

Code: Select all

put the thumbpos of sb 1 into temp
add 0 to temp
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Multiple Sliders

Post by dunbarx » Tue Oct 29, 2013 6:48 pm

Simon.

OK. Works. Any idea why "round" works when "trunc" does not"?

And Calmrr3, about making your insane slider gizmo gadget (Simon, forgive me). In the card script:

Code: Select all

on scrollbarDrag
   if round(the thumbpos of scrollbar 1) = 49 \
         and round(the thumbpos of scrollbar 2) = 47 \
         and round(the thumbpos of scrollbar 3) = 45 then
      answer "OK"
   end if
end scrollbarDrag
I hope you get the picture.

Craig

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Multiple Sliders

Post by Klaus » Tue Oct 29, 2013 7:07 pm

HI calmrr3
calmrr3 wrote:...
if
the thumbpos of "slider1" = 49 and...
The most obvious error is that you left out the TYPE of the object you are addressing:
the thumbpos of "slider1"
VS.
the thumbpos of SB "slider1"
## SB = abbreviation of SCROLLBAR, lazy moi 8)

Yes, the fact that the scrollbar values are actually floating values,
even if we do NOT set the numberformat of the scrollbar, also catches
me from time to time :D


Best

Klaus

calmrr3
Posts: 100
Joined: Mon Oct 28, 2013 2:39 pm

Re: Multiple Sliders

Post by calmrr3 » Tue Oct 29, 2013 8:25 pm

so i would use the thumbpos of SB "slider1" ?

http: / / 2. bp . blogspot . com /-L-i_KQqbjuQ/Um7m2sZ8sBI/AAAAAAAABZg/QIu2bKiTKJc/s1600/Screen+Shot+2013-10-28+at+19.45.14. png

(remove the spaces in the link, I can't seem to post links)

Basically I want to go to the next card when the thumbpos of all 29 sliders look like the above image.

Thanks

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Multiple Sliders

Post by dunbarx » Tue Oct 29, 2013 11:53 pm

No.

What Klaus really means is that you must go to the dictionary and look up the syntax for "thumbPosition".

Getting the value of any property of an object requires a very strict construction. This is a general rule, and must be learned:

... the propertyOfInterest of object "yourobject" --"object" could be a button, a field, or a scrollbar

Do you see? You had given the name of your slider, but "slider" is not a word in LC. A slider is a scrollbar that has certain properties. So you should have said:

the thumbPos of scrollBar "slider1" --just like "the width of button yourButton"

Don't fret, this takes practice.

Craig

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Multiple Sliders

Post by Simon » Wed Oct 30, 2013 1:37 am

Hi Craig,
Any idea why "round" works when "trunc" does not"?
When I added 0 to temp, temp became 9.9773 (not 10) so trunc rounded down, round rounded up.
And the wheels on the bus did something else.:)
(errr... its a song but might be UK only)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Multiple Sliders

Post by dunbarx » Wed Oct 30, 2013 2:37 am

Simon.

Right. Thanks. I was so focussed on the numbers, that I did not look at what the slider itself was seeing.

Wheels... is US also.

Craig

Post Reply