Page 1 of 1
Parenthesizing boolean expression results in error
Posted: Wed Jul 31, 2013 6:32 pm
by sritcp
Hi,
Here's a simplified example of the error I stumbled into:
Say, the field "Input" contains the string
ONE,TWO,THREE
Now, the statement
put field "Input" into tData; put item 1 of tData into tThis; put tThis = "ONE"
results in "true"
But, if I parenthesize the boolean equality, as in
put field "Input" into tData; put item 1 of tData into tThis; put (tThis = "ONE")
it results in "false".
Can you check this out and confirm it?
Thanks,
Sri.
Re: Parenthesizing boolean expression results in error
Posted: Wed Jul 31, 2013 6:42 pm
by dunbarx
I get "true" in both cases, as I would expect.
Odd if you do not. There certainly can be nothing insinuating itself into such a small and private script.
In future, separate your lines:
Code: Select all
on mouseup
put field "Input" into tData
put item 1 of tData into tThis
answer (tThis = "ONE")
end mouseup
Craig Newman
Re: Parenthesizing boolean expression results in error
Posted: Wed Jul 31, 2013 10:42 pm
by sritcp
Ok, here's what's happening!
I get "true" in both cases, as you do, when I
a) employ a handler/method, such as "mouseUp", and
b) when I use the multi-line message box.
But, when I use a single-line mode message box,
put field "Input" into tData; put item 1 of tData into tThis; put tThis = "ONE"
returns "true", while
put field "Input" into tData; put item 1 of tData into tThis; put (tThis = "ONE")
returns "false"!
Since I have a habit of trying out every key step in the message box before incorporating it in a method, I hit a snag here!
Thanks,
Sri.
Re: Parenthesizing boolean expression results in error
Posted: Wed Jul 31, 2013 11:45 pm
by dunbarx
I wasn't even aware you could compose in the msg box this way. I would have thought it would choke.
Am I the only one? Was I out that day?
Anyway:
put field "Input" into tData; put item 1 of tData into tThis; put tThis = "ONE" -- gives "false"
put field "Input" into tData; put item 1 of tData into tThis; put (tThis = "ONE") -- gives "one","two","three" (original contents of the field)
No idea what the second one could mean.
Craig Newman
Re: Parenthesizing boolean expression results in error
Posted: Thu Aug 01, 2013 12:23 am
by sritcp
If you make sure that the card with the said field is current when you type the command into the message box (and the field has the string in it with "ONE" as item 1),
put field "Input" into tData; put item 1 of tData into tThis; put tThis = "ONE"
should return "true" (at least it does for me; I use this semi-colon separated chain of commands in the single-line message box routinely. It is there in the user manual somewhere).
The last command evaluates the boolean tThis = "ONE" as true and places the result in the message box.
But put (tThis = "ONE") returns false.
This was my issue. But, until someone duplicates this occurrence, it will have to wait.
Thanks,
Sri.
Re: Parenthesizing boolean expression results in error
Posted: Thu Aug 01, 2013 8:42 am
by dave_probertGA6e24
BTW, there is a second message box option - the Multi-Line Message Box !!!!
It allows you to run a bunch of script lines without needing to bunch them up into a mess. Way more useful.
Hint: it's the bit in the message box under the icon that shows "multi-line" in the tooltip)
Cheers,
Dave
Re: Parenthesizing boolean expression results in error
Posted: Thu Aug 01, 2013 2:50 pm
by dunbarx
Dave.
He had mentioned using the multi-line option earlier.
Craig