Page 1 of 1

The slider/thumbPosition problem

Posted: Tue Mar 10, 2009 8:19 pm
by Duncan
Thanks for the previous comments. I am still troubled by the slider's value. A script in a slider like...

Code: Select all

on mousedown
   put "Find 56.2" into the field "fieldTxt"
end mousedown
on mouseup
   put the thumbposition of me into the field "field1"
   put the thumbposition of me + 1 into the field "field2"
   put the thumbposition of me + 1 - 1 into the field "field3"
   if the thumbposition of me = 56.2 then
      put "Pass" into the field "fieldTxt"
   else
      put "Fail" into the field "fieldTxt"
   end if
   end mouseup 


produces this...

Image

Although things appear to be working the right value is never found as the slider is always returning more decimal places than expected. Am I doing something fundamentally wrong? Or have i missed something?

Posted: Tue Mar 10, 2009 10:19 pm
by bn
Hi Duncan,

if you put

Code: Select all

if round (the thumbposition of me,1) =56.2 then
then it passes the test.
this way it matches the display if you restricted the display to 1 decimal in the inspector.

Is that what you want?

As they said in the previous thread, more often than not you will find a way around a limitation.

regards
Bernd

Posted: Wed Mar 11, 2009 9:34 am
by Duncan
Once it was apparent what was going on the Rounding solution was obvious but my question is/are.... Why is it like this? What is the point of setting the Number Format in the Property Inspector if that is only being used in a cosmetic way? How are you supposed to figure out what is going on when the values presented seem to be correct and yet the test fails?

Posted: Wed Mar 11, 2009 11:32 am
by SparkOut
Duncan wrote:What is the point of setting the Number Format in the Property Inspector if that is only being used in a cosmetic way?
I think that is the point of the number format. There are many occasions where the value for processing needs a degree of precision that is just confusing or cluttered to view by the user, so for cosmetic reasons it can be displayed in a shortened form, importantly while preserving the (nearly) precise value for processing. And, as you've discovered, the round() function is there for when the processing does not need to have such a precise value to use.

Posted: Wed Mar 11, 2009 11:55 am
by gyroscope
Hi Duncan, did a small experiment with your script. By putting the required thumbposition into a variable, then adding 1 to the variable seems to work fine.

Strangely though, there seems to be less precision if you get an answer for the variable, i.e

Code: Select all

on mouseup 
  set the thumbposition of me to 56.2
  put the thumbposition of me into field "fieldTxt"
   put the thumbposition of me into tAmount
   answer tAmount
   put tAmount + 1 into field "Field2"
   end mouseup 
answer tAmount will show 56 in this case. Strange!

But if you delete the first line, i.e " set the thumbposition of me to 56.2" and input the actual thumbposition set by the user, there seems to be more precision than can be shown as a number, so that if it's positioned roughly at 56, it is actually 56.3214 or whatever, or 55.9654 etc. So as Bernd and SparkOut wrote, rounding the user-set thumb position before adding or subtracting is the only way to achieve what you are after.

:)

Posted: Wed Mar 11, 2009 1:05 pm
by bn
Hi Duncan,

I think it has to do with positioning the slider pixelwise.
Anyhow you would not want to run the a sophisticated machine from the readings of the slider, still I can see that it is puzzling if you want to use the value.

if you use the following code you adjust the precise numeric value when the slider is moved in adjusting it to 1 decimal and then your test works as well.

Code: Select all

on mousedown
   put "Find 56.2" into the field 1
end mousedown

on scrollbarDrag pScrollValue
    set the thumbposition of me to round (pScrollValue,1)
end scrollbarDrag

on mouseup
    put the thumbposition of me into the field 1
    put the thumbposition of me + 1 into the field 2
    put the thumbposition of me + 1 - 1 into the field 3
    if the thumbposition of me = 56.2 then
        put "Pass" into the field 4
    else
        put "Fail" into the field 4
    end if
end mouseUp
the 'on ScrollbarDrag' reacts to the movement of the slider and sets it to a position to one decimal precisely. That is then the real value of the scrollbar, not a rounded one with hidden decimals.
Apparently Rev internally tries to keep track of the scrollbarposition as precisely as possible. Think of the task for Rev to position the scrollbar. You can choose a wide range of start values (even negative ones) and end values, still Rev has to visually position the slider, the scrollbar can have widely varying sizes, still the scrollbar has to produce a plausible numeric value and a precise position.
To me it is not surprising the Rev uses internally a higher degree of precision then it shows.

That all said (if it makes sense at all) dont let the scrollbar problem be the main point in judging Rev.

regards
Bernd

Posted: Wed Mar 11, 2009 10:07 pm
by Duncan
Thanks for all your thoughts. It is not a deal breaker; indeed I have purchased a copy of Revolution having seen some great things created with it.

I shall keep in mind that tick boxes (as in the slider's inspector) labelled "showValue" should be read as "Show some arbitrary rounded number which is quite close to the actual value you are working with". :?

Posted: Wed Mar 11, 2009 10:33 pm
by gyroscope
Hi Duncan, just had a thought, depending on what your final outcome required for your app is, this might be useful:

Simply put the contents of the field into a variable and add 1 or whatever to that, then set the thumbPosition to the variable.

Don't know if that's any help...

:)