Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
jacque
- VIP Livecode Opensource Backer

- Posts: 7393
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Tue Nov 04, 2014 4:40 pm
The example of the "then" you mentioned isn't what Richard meant, I don't think. The OP wrote that correctly. If I'm reading Richard's mind right, this what we mean, and does not occur in this thread:
Code: Select all
if someCondition is true
then
doX
else if otherThing
then
doY
end if
It runs fine without error. But it looks weird.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
[-hh]
- VIP Livecode Opensource Backer

- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
Post
by [-hh] » Tue Nov 04, 2014 5:10 pm
Oh I see. This shows that my statement "semicolon is equivalent to cr in scripts" is wrong! This should read:
Semicolon is equivalent to cr after "complete" statements in scripts. For example a semicolon after "then" is wrong.
Because your example is so short I would write this as
Code: Select all
if someCondition is true then doX; else if otherThing then doY
I'm bad *half* to the bone ...
[Edit. Divided my last statement by two after the answer of jacque to this post.]
Last edited by
[-hh] on Tue Nov 04, 2014 6:17 pm, edited 1 time in total.
shiftLock happens
-
jacque
- VIP Livecode Opensource Backer

- Posts: 7393
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Tue Nov 04, 2014 6:02 pm
You could write that all in one line and it wouldn't error even without the semicolons. Your rule may need revision.
I write one-line if clauses frequently.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10354
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Tue Nov 04, 2014 7:01 pm
All those weird variants were explicitly offered for sale in HC. Readability be damned. They were fraught with peril, though, and only a few were ultimately considered "acceptable". Some would not indent, though they would compile.Some, that really seemed OK, if nested into other if-then constructions, would not compile unless broken out fully:
if soAndSo then
whatever
else
whateverelse
end if
I never understood why, but learned long ago that if I just expanded, the overall handler would compile and work.
Craig
-
jacque
- VIP Livecode Opensource Backer

- Posts: 7393
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Tue Nov 04, 2014 7:28 pm
dunbarx wrote:
I never understood why, but learned long ago that if I just expanded, the overall handler would compile and work.
I had a disagreement with XXX at a conference once about that. He wrote all if/else clauses in standard structure no matter how short they were. I do that mostly too but I also use one-liners sometimes if they're short enough. The other structures aren't reliable for the reasons you mention. Mark Waddingham once explained what the rules were for compilation but I've lost the reference, and so I just remember that the safest thing, as you say, is to write them in fully expanded format.
So we're back to standard structures, and all that.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
[-hh]
- VIP Livecode Opensource Backer

- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
Post
by [-hh] » Tue Nov 04, 2014 8:00 pm
Who is that obscure developer "XXX". Tried to find him with Google. The result was unbelievable. Can't imagine this was part of a conference.
shiftLock happens
-
jacque
- VIP Livecode Opensource Backer

- Posts: 7393
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Tue Nov 04, 2014 8:05 pm
LOL! That's funny. And knowing him quite well, I am very sure that any Google search you did would not include him.

Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10057
- Joined: Sat Apr 08, 2006 7:05 am
-
Contact:
Post
by FourthWorld » Tue Nov 04, 2014 9:17 pm
jacque wrote:The example of the "then" you mentioned isn't what Richard meant, I don't think. The OP wrote that correctly. If I'm reading Richard's mind right, this what we mean, and does not occur in this thread:
Code: Select all
if someCondition is true
then
doX
else if otherThing
then
doY
end if
It runs fine without error. But it looks weird.
Because it
is weird.
We nearly had a food fight at our local LiveCode user group over this issue. It's serious stuff.
