empty is zero

11 messages Options
Embed this post
Permalink
Scott Morrow

empty is zero

Reply Threaded More More options
Print post
Permalink
I'm having trouble with a script where an empty parameter is evaluated  
as being zero.  I've only been using rev 3.5 a short while so maybe  
I've missed a setting or new feature?
In the message box all works as expected:

    put empty into tVariable
    put charToNum(tVariable) --> (empty)
    put isNumber(tVariable) --> false
    put tVariable is zero --> false


but in my script, when the parameter is empty I get:

on tHandler tParam -- where tParam is empty
    put charToNum(tParam) --> (empty)
    put isNumber(tParam) --> false
    put tParam is zero --> true
end tHandler

if I explicitly  < put empty into tParam >   inside the script then  
all works as expected

I've not had a lot of sleep but hoped coffee and a maple bar might  
compensate.

Scott Morrow

Elementary Software
(Now with 20% less chalk dust!)
web       http://elementarysoftware.com/
email     [hidden email]
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Mark Schonewille-3

Re: empty is zero

Reply Threaded More More options
Print post
Permalink
Hi Scott,

If you check empty = 0, you'll get false, but if empty*1 = 0 will  
return true. AFAIK it has always been like this. I assume that tParam  
gets parsed when it is passed to a function or command handler. You  
can change the offending line of your script into: "put tParam is zero  
and tParam is not empty"

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
Snapper Screen Recorder 2.1 http://snapper.economy-x-talk.com

If you sent me an e-mail before 21 June and haven't got a reply yet,  
please send me a reminder.






On 9 jul 2009, at 22:18, Scott Morrow wrote:

> I'm having trouble with a script where an empty parameter is  
> evaluated as being zero.  I've only been using rev 3.5 a short while  
> so maybe I've missed a setting or new feature?
> In the message box all works as expected:
>
>   put empty into tVariable
>   put charToNum(tVariable) --> (empty)
>   put isNumber(tVariable) --> false
>   put tVariable is zero --> false
>
>
> but in my script, when the parameter is empty I get:
>
> on tHandler tParam -- where tParam is empty
>   put charToNum(tParam) --> (empty)
>   put isNumber(tParam) --> false
>   put tParam is zero --> true
> end tHandler
>
> if I explicitly  < put empty into tParam >   inside the script then  
> all works as expected
>
> I've not had a lot of sleep but hoped coffee and a maple bar might  
> compensate.
>
> Scott Morrow

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Scott Morrow

Re: empty is zero

Reply Threaded More More options
Print post
Permalink
Hello Mark,

> If you check empty = 0, you'll get false

I DO get false in the message box  but in a handler where there is  
nothing being passed in the parameter I get the following (note that  
expressly putting empty into the parameter variable does give the  
expected result.)



if I call "MyHandler" with this inside a stack script:

on MyHandler tParam  --> where I didn't pass anything in tParam

           put isNumber(tParam) into tParamIsNumber
           put tParam = 0 into  tParamIsZero
           put (tParam is empty) into tParamIsEmpty

end MyHandler



it results in BOTH tParamIsZero = true   AND   tParamIsEmpty = true    
(it is empty and zero?)

also,  tParamIsNumber = false  AND    tParamIsZero  =  true    (it is  
not a number but it is zero?)


If I add the line:    put empty into tParam

on MyHandler tParam

           put empty into tParam
           put isNumber(tParam) into tParamIsNumber
           put tParam = 0 into  tParamIsZero
           put (tParam is empty) into tParamIsEmpty

end MyHandler

then ParamIsZero = false



Thanks for your help.

Scott Morrow
Elementary Software
(Now with 20% less chalk dust!)
web       http://elementarysoftware.com/

On Jul 9, 2009, at 1:56 PM, Mark Schonewille wrote:

> Hi Scott,
>
> If you check empty = 0, you'll get false, but if empty*1 = 0 will  
> return true. AFAIK it has always been like this. I assume that  
> tParam gets parsed when it is passed to a function or command  
> handler. You can change the offending line of your script into: "put  
> tParam is zero and tParam is not empty"
>
> --
> Best regards,
>
> Mark Schonewille

>
> On 9 jul 2009, at 22:18, Scott Morrow wrote:
>
>> I'm having trouble with a script where an empty parameter is  
>> evaluated as being zero.  I've only been using rev 3.5 a short  
>> while so maybe I've missed a setting or new feature?
>> In the message box all works as expected:
>>
>>  put empty into tVariable
>>  put charToNum(tVariable) --> (empty)
>>  put isNumber(tVariable) --> false
>>  put tVariable is zero --> false
>>
>>
>> but in my script, when the parameter is empty I get:
>>
>> on tHandler tParam -- where tParam is empty
>>  put charToNum(tParam) --> (empty)
>>  put isNumber(tParam) --> false
>>  put tParam is zero --> true
>> end tHandler
>>
>> if I explicitly  < put empty into tParam >   inside the script then  
>> all works as expected
>>
>> I've not had a lot of sleep but hoped coffee and a maple bar might  
>> compensate.
>>
>> Scott Morrow
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Mark Schonewille-3

Re: empty is zero

Reply Threaded More More options
Print post
Permalink
Scott,

It looks like as soon as you pass a parameter, it gets parsed and  
hence gets a value of 0, similar to when you parse empty*1.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
Snapper Screen Recorder 2.1 http://snapper.economy-x-talk.com

If you sent me an e-mail before 21 June and haven't got a reply yet,  
please send me a reminder.






On 9 jul 2009, at 23:56, Scott Morrow wrote:

> Hello Mark,
>
>> If you check empty = 0, you'll get false
>
> I DO get false in the message box  but in a handler where there is  
> nothing being passed in the parameter I get the following (note that  
> expressly putting empty into the parameter variable does give the  
> expected result.)
>

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
J. Landman Gay

Re: empty is zero

Reply Threaded More More options
Print post
Permalink
In reply to this post by Scott Morrow
Scott Morrow wrote:

> it results in BOTH tParamIsZero = true   AND   tParamIsEmpty = true    
> (it is empty and zero?)

Right. Empty is a variable sort of variable... I believe it only equates
to zero when you do a math calculation on it. Otherwise it isn't a
number. This prevents math from failing when a parameter contains no value.

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Scott Morrow

Re: empty is zero

Reply Threaded More More options
Print post
Permalink
In reply to this post by Mark Schonewille-3
Hello Mark,

But shouldn't the isNumber function show it to be a number at that  
point?  I'm evaluating it as both empty, not a number and zero.

Thanks,

Scott


On Jul 9, 2009, at 3:05 PM, Mark Schonewille wrote:

> Scott,
>
> It looks like as soon as you pass a parameter, it gets parsed and  
> hence gets a value of 0, similar to when you parse empty*1.
>
> --
> Best regards,
>
> Mark Schonewille
>
> Economy-x-Talk Consulting and Software Engineering
> http://economy-x-talk.com
> Snapper Screen Recorder 2.1 http://snapper.economy-x-talk.com
>
> If you sent me an e-mail before 21 June and haven't got a reply yet,  
> please send me a reminder.
>
>
>
>
>
>
> On 9 jul 2009, at 23:56, Scott Morrow wrote:
>
>> Hello Mark,
>>
>>> If you check empty = 0, you'll get false
>>
>> I DO get false in the message box  but in a handler where there is  
>> nothing being passed in the parameter I get the following (note  
>> that expressly putting empty into the parameter variable does give  
>> the expected result.)
>>
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Scott Morrow

Re: empty is zero

Reply Threaded More More options
Print post
Permalink
In reply to this post by J. Landman Gay
Hello Jacque,
> a variable sort of variable
> it only equates to zero when you do a math calculation on it

Uh... I guess I knew that... I just wasn't seeing tVariable is zero  
(x=0) as a math calculation... but obviously it is

Thanks for straightening me out  :  )

Scott


On Jul 9, 2009, at 3:08 PM, J. Landman Gay wrote:

> Scott Morrow wrote:
>
>> it results in BOTH tParamIsZero = true   AND   tParamIsEmpty =  
>> true    (it is empty and zero?)
>
> Right. Empty is a variable sort of variable... I believe it only  
> equates to zero when you do a math calculation on it. Otherwise it  
> isn't a number. This prevents math from failing when a parameter  
> contains no value.
>
> --
> Jacqueline Landman Gay         |     [hidden email]
> HyperActive Software           |     http://www.hyperactivesw.com
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Mark Schonewille-3

Re: empty is zero

Reply Threaded More More options
Print post
Permalink
In reply to this post by Scott Morrow
Hi Scott,

No, unless you're doing a calculation, because then it is parsed as a  
number. See Jacque's reply.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
Snapper Screen Recorder 2.1 http://snapper.economy-x-talk.com

If you sent me an e-mail before 21 June and haven't got a reply yet,  
please send me a reminder.






On 10 jul 2009, at 00:11, Scott Morrow wrote:

> Hello Mark,
>
> But shouldn't the isNumber function show it to be a number at that  
> point?  I'm evaluating it as both empty, not a number and zero.
>
> Thanks,
>
> Scott
>

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Scott Morrow

Re: empty is zero

Reply Threaded More More options
Print post
Permalink
Hello Mark and Jacque,

empty + 0 = 0 is true in the message box
empty = 0  is not true in the message box but the <empty?> parameter  
in a script does return true  (tParam = 0)

Rats, I'm obviously not getting something.  Maybe it's more coffee.

-Scott


On Jul 9, 2009, at 3:21 PM, Mark Schonewille wrote:

> Hi Scott,
>
> No, unless you're doing a calculation, because then it is parsed as  
> a number. See Jacque's reply.
>
> --
> Best regards,
>
> Mark Schonewille
>
> Economy-x-Talk Consulting and Software Engineering
> http://economy-x-talk.com
> Snapper Screen Recorder 2.1 http://snapper.economy-x-talk.com
>
> If you sent me an e-mail before 21 June and haven't got a reply yet,  
> please send me a reminder.
>
>
>
>
>
>
> On 10 jul 2009, at 00:11, Scott Morrow wrote:
>
>> Hello Mark,
>>
>> But shouldn't the isNumber function show it to be a number at that  
>> point?  I'm evaluating it as both empty, not a number and zero.
>>
>> Thanks,
>>
>> Scott
>>
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Mark Schonewille-3

Re: empty is zero

Reply Threaded More More options
Print post
Permalink
Scott,

empty = 0 --> empty doesn't get parsed
empty * 1 = 0 --> empty gets parsed

tParam gets *parsed* because it is passed on to a handler. Parsed, hence

tParam = 0 --> true.

Just consider this a fact. It may not be entirely logical, but it  
isn't too difficult to remember and it is easy to work around.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
Snapper Screen Recorder 2.1 http://snapper.economy-x-talk.com

If you sent me an e-mail before 21 June and haven't got a reply yet,  
please send me a reminder.


On 10 jul 2009, at 00:39, Scott Morrow wrote:

> Hello Mark and Jacque,
>
> empty + 0 = 0 is true in the message box
> empty = 0  is not true in the message box but the <empty?> parameter  
> in a script does return true  (tParam = 0)
>
> Rats, I'm obviously not getting something.  Maybe it's more coffee.
>
> -Scott
>
>

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
J. Landman Gay

Re: empty is zero

Reply Threaded More More options
Print post
Permalink
In reply to this post by Scott Morrow
Scott Morrow wrote:
> Hello Mark and Jacque,
>
> empty + 0 = 0 is true in the message box
> empty = 0  is not true in the message box but the <empty?> parameter in
> a script does return true  (tParam = 0)
>
> Rats, I'm obviously not getting something.  Maybe it's more coffee.

I wonder if that has something to do with how the message box has to
manipulate its contents before evaluating a statement. It may be
reporting ascii equivalency there. That's just a guess though.

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution