Forget the comma thread. Now lose semicolons

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Forget the comma thread. Now lose semicolons

Post by dunbarx » Wed Jun 28, 2017 4:18 pm

In a button script with a field a card.

Code: Select all

on mouseUp
   put random(99) into fld 1  wait 10   answer "whew" put random(99)  into fld 1  put random(99) * 2.4545656467 into fld 1  put fld 1 ^ 3 into fld 1
end mouseUp
No semiColons required to separate what I thought would not compile at all. Apparently, LC needs very little in the way to understand that many separate commands can exist in a single line. Why ever bother with the return char? Has this always been OK? Is this in fact OK?

Craig Newman

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Forget the comma thread. Now lose semicolons

Post by Mikey » Thu Jun 29, 2017 2:44 pm

It is ok, and it's great if you want to debug your compiled app with just an ask dialog, or if you want to use the single-line message box to get the value of some global container

Code: Select all

global foo;put foo

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Forget the comma thread. Now lose semicolons

Post by Klaus » Thu Jun 29, 2017 3:01 pm

I always stick to the "official" syntax etc. and don't pay any attention to things that "somehow work, by chance and inofficially"!
This way my life is much easier and I have a lot more time at hand... :D

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Forget the comma thread. Now lose semicolons

Post by Mikey » Thu Jun 29, 2017 3:03 pm

I'm pretty sure it's official, since I didn't even realize it was available until somebody at LC shared it.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Forget the comma thread. Now lose semicolons

Post by Klaus » Thu Jun 29, 2017 3:14 pm

If it is not documented, I do not consider it official!

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Forget the comma thread. Now lose semicolons

Post by Mikey » Thu Jun 29, 2017 3:38 pm

Then synonyms aren't either...

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Forget the comma thread. Now lose semicolons

Post by Mikey » Thu Jun 29, 2017 3:53 pm

FYI, I spent less than a minute searching for the origin of this, so I'm sure there's something earlier, but
http://www.mactech.com/articles/mactech ... index.html
and
http://lists.runrev.com/pipermail/use-l ... 13918.html

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Forget the comma thread. Now lose semicolons

Post by Mikey » Thu Jun 29, 2017 3:56 pm

It's also documented in the dictionary. I didn't bother to look there, first.

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

Re: Forget the comma thread. Now lose semicolons

Post by dunbarx » Thu Jun 29, 2017 5:01 pm

Mikey.

Two things going on here. One is about the looseness of LC syntax, and an unexpected subthread about synonyms.

Syntax.

I am with Klaus. Never mind the fact that LC seems to have a magical omniscient parser, this phenomenon is not documented, ought not to even work, and so is relegated to astonishing esoterica. Esoterica that I absolutely would not trust at all. Never mind again that, say, the example I posted is nearly impossible to read.

It all derived from the recent thread about not needing commas to pass parameters. You don't even need punctuation to combine lines of code. I refuse to experiment on how far this can be stretched...
global foo;put foo
Not sure what you meant here. You have semicolons.
It is ok, and it's great if you want to debug your compiled app with just an ask dialog,
Intrigued about this. Can you elaborate?

Craig

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Forget the comma thread. Now lose semicolons

Post by Mikey » Thu Jun 29, 2017 5:17 pm

Ah. That is weird. I wonder what is going on, there. I could have sworn I saw sems in the original code.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Forget the comma thread. Now lose semicolons

Post by Klaus » Thu Jun 29, 2017 5:31 pm

Mikey wrote:It's also documented in the dictionary. I didn't bother to look there, first.
Please give me a hint where to look for that in the dictionary, thank you.

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

Re: Forget the comma thread. Now lose semicolons

Post by dunbarx » Thu Jun 29, 2017 6:27 pm

Mikey,

Ah.

So now you see my point? There aint nothing but spaces between those separate commands, and there aint nothing but spaces between the words of those commands.

Craig

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Forget the comma thread. Now lose semicolons

Post by Mikey » Thu Jun 29, 2017 6:56 pm

Klaus,
I misread the posts. I thought you guys were referring to the semicolon, so kindly ignore everything I typed on this thread.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Forget the comma thread. Now lose semicolons

Post by Klaus » Thu Jun 29, 2017 7:00 pm

Mikey wrote:Klaus,
I misread the posts. I thought you guys were referring to the semicolon, so kindly ignore everything I typed on this thread.
Ah, OK. :D

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

Re: Forget the comma thread. Now lose semicolons

Post by dunbarx » Thu Jun 29, 2017 8:23 pm

Well, indirectly, I was. The thread title does mention it, after all.

One may string lines of code on a single physical line if you delimit with semicolons:

Code: Select all

doThis ; doThat; answer the date; put 5 into fld 1
I rarely use this because I just don't see the downstream snippets easily. Though sometimes, with very closely related snippets, the compactness is nice.

This thread discovers that the semicolons are not required. LC seems to be able to parse a string of words into a group of sensible commands.

Code: Select all

doThis  doThat answer the date  put 5 into fld 1
That was amazing to me.

Craig

Post Reply

Return to “Talking LiveCode”