Multiple Conditionals on if statement?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6919
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Multiple Conditionals on if statement?

Post by dunbarx » Wed Feb 12, 2020 10:57 pm

This harkens all the way back to HC, which vacillated between considering it a feature that an unquoted literal, would, eventually, as Klaus mentioned, be resolved into a, er, literal, or, a mild no-no.

It is a terrible idea. I like to see my literals as literals, so I do not confuse them with variables. Quotes do that trick so nicely. Even I can manage that level of discipline.

Craig
Last edited by dunbarx on Thu Feb 13, 2020 9:11 pm, edited 1 time in total.

bogs
Posts: 4790
Joined: Sat Feb 25, 2017 10:45 pm

Re: Multiple Conditionals on if statement?

Post by bogs » Wed Feb 12, 2020 11:28 pm

Hee hee, that sounds like you are being so darned literal :mrgreen:

(I owe you a steak for that one, I think I hit a new low in the cornpone that should go nicely with steak) :D
Image

SparkOut
Posts: 2289
Joined: Sun Sep 23, 2007 4:58 pm

Re: Multiple Conditionals on if statement?

Post by SparkOut » Thu Feb 13, 2020 8:18 pm

I agree, everyone should always quote literals properly. It's not just sloppy code otherwise, it is prone to failure (as it should be).

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6919
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Multiple Conditionals on if statement?

Post by dunbarx » Thu Feb 13, 2020 8:26 pm

What Sparkout said.

Way, way back, because I thought it more compact for some reason, I used both quoted literals and also the same string for control names. These were usually related. There was a small benefit for me, keeping similar stuff in much the same place in a handler.

Don't.

Craig

bogs
Posts: 4790
Joined: Sat Feb 25, 2017 10:45 pm

Re: Multiple Conditionals on if statement?

Post by bogs » Thu Feb 13, 2020 9:05 pm

Just so there is no question about it, I am of the same mind despite any bad jokes I might spin about it.

There is still something funny going on in poor JackieBlue1970's case which is not what they think it is.
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6919
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Multiple Conditionals on if statement?

Post by dunbarx » Thu Feb 13, 2020 9:20 pm

JackieBlue1970 says that:
instead of if "Fld1" is empty...
implying that works as he wanted. It cannot work at all.

This is OK:

Code: Select all

if "" is empty then answer "What did you expect?"
but this, nope:

Code: Select all

if "empty" is empty then answer ""Well, what did you expect?"
This last is simpler to grok than the snippet at the top, which is structurally similar. "Fld 1", in quotes, can not and does not reference a field.

That dog don't hunt.

Craig

JackieBlue1970
Posts: 64
Joined: Thu Jan 16, 2020 10:28 pm
Location: Max Meadows, VA USA

Re: Multiple Conditionals on if statement?

Post by JackieBlue1970 » Sat Feb 15, 2020 4:50 pm

bogs wrote:
Wed Feb 12, 2020 9:33 pm
JackieBlue1970 wrote:
Wed Feb 12, 2020 9:21 pm
If field "Fld1" is empty and field "Fld2" is empty then

instead of if "Fld1" is empty...
I don't think that is the issue, JackieBlue1970 :|

Field is indeed a keyword, it identifies the object you are testing, in this case field "fld1" and field "fld2". I modified the stack I posted above to include the wording because that is exactly how you should be referring to controls/objects, and it works here after I named my fields "fld1" and "fld2".

If it wouldn't be asking too much, could you possibly post the code you had before the changes you made? I, and I'm sure many others, would love to take a look at what was going on that was causing the original problem.
aPic_field1-2.png
I tested both ways multiple times. I’ll try to get the code next week. This is just a side project for my business and I only work on it occasionally in the afternoon.

bogs
Posts: 4790
Joined: Sat Feb 25, 2017 10:45 pm

Re: Multiple Conditionals on if statement?

Post by bogs » Sat Feb 15, 2020 5:01 pm

JackieBlue1970 wrote:
Sat Feb 15, 2020 4:50 pm
I’ll try to get the code next week. This is just a side project for my business and I only work on it occasionally in the afternoon.
Sounds good, I'm sure that the problem could be found in short order :D
Image

JackieBlue1970
Posts: 64
Joined: Thu Jan 16, 2020 10:28 pm
Location: Max Meadows, VA USA

Re: Multiple Conditionals on if statement?

Post by JackieBlue1970 » Mon Feb 17, 2020 2:37 am

bogs wrote:
Wed Feb 12, 2020 10:13 pm
All of which are very good reasons to always quote the name, now we need to find out what is happening in poor JackieBlue1970's case :wink:
Well, it is fixed now. I will try to recreate the error when I have time and post here. Thanks again.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”