Parenthesizing boolean expression results in error

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
sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm

Parenthesizing boolean expression results in error

Post by sritcp » Wed Jul 31, 2013 6:32 pm

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.

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

Re: Parenthesizing boolean expression results in error

Post by dunbarx » Wed Jul 31, 2013 6:42 pm

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

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm

Re: Parenthesizing boolean expression results in error

Post by sritcp » Wed Jul 31, 2013 10:42 pm

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.

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

Re: Parenthesizing boolean expression results in error

Post by dunbarx » Wed Jul 31, 2013 11:45 pm

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

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm

Re: Parenthesizing boolean expression results in error

Post by sritcp » Thu Aug 01, 2013 12:23 am

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.

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

Re: Parenthesizing boolean expression results in error

Post by dave_probertGA6e24 » Thu Aug 01, 2013 8:42 am

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
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

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

Re: Parenthesizing boolean expression results in error

Post by dunbarx » Thu Aug 01, 2013 2:50 pm

Dave.

He had mentioned using the multi-line option earlier.

Craig

Post Reply