on mouseUp
answer Something() = 0
answer Something() = empty
answer Something(empty) = 0
answer Something(empty) = empty
end mouseUp
function Something pNothing
return pNothing
end Something
This will return
'true'
'true'
'false'
'true'
Is this expected?
Empty paramter eval
Moderator: Klaus
Re: Empty paramter eval
Well, it's expected if you know how the engine "thinks".
answer Something() = 0 -- When using empty with a number (math, or comparisons,) LC will treat empty as zero.
answer Something() = empty -- self-explanatory; empty (no param) is empty (the constant)
answer Something(empty) = 0 -- you'd think this would work as in #1, but here the engine is interpreting the constant as a string.
answer Something(empty) = empty -- these are equivalent when compared as both constants and strings
The third one is something of a puzzle. I believe it's happening because you're running the constant "empty" through a function, and the return value is interpreted by LC as a string rather than a constant.
answer Something() = 0 -- When using empty with a number (math, or comparisons,) LC will treat empty as zero.
answer Something() = empty -- self-explanatory; empty (no param) is empty (the constant)
answer Something(empty) = 0 -- you'd think this would work as in #1, but here the engine is interpreting the constant as a string.
answer Something(empty) = empty -- these are equivalent when compared as both constants and strings
The third one is something of a puzzle. I believe it's happening because you're running the constant "empty" through a function, and the return value is interpreted by LC as a string rather than a constant.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Empty paramter eval
The problem I am facing with it is how it propagates through functions. If I do Something(Something()) then again it will be equal to 0. This can cause unexpected outcomes when you think an empty parameter should equate to empty. Also, this will continue even if you assign it to a variable such as:
put Something() into a
put OtherFunction(a) into b
Now anything in OtherFunction will see a = 0.
Edit: Let me also add that my reasoning is based on the fact that:
answer empty = 0
yields 'false'
put Something() into a
put OtherFunction(a) into b
Now anything in OtherFunction will see a = 0.
Edit: Let me also add that my reasoning is based on the fact that:
answer empty = 0
yields 'false'
Re: Empty paramter eval
You can avoid the translation to zero by altering the function slightly:
This seems to remove the string conversion.
Code: Select all
function Something pNothing
if pNothing = empty then put "" into pNothing
return pNothing
end Something
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Empty paramter eval
shiftLock happens
Re: Empty paramter eval
@jacque: Thanks for the feedback. I'm using a similar workaround, but as you can imagine this lessens the usefulness of empty params if they don't propogate and behave as you would expect 'empty' to.
@-hh: Ha! Seems I'm late to the party. Thanks for the link.
@-hh: Ha! Seems I'm late to the party. Thanks for the link.