commands and brackets.

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: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
MrFollies
Posts: 29
Joined: Tue Jul 15, 2014 8:30 am

commands and brackets.

Post by MrFollies » Sun Feb 15, 2015 3:59 am

I've noticed that when calling commands, if you use brackets then the parameters passed can be combined into the first parameter value.
I'm just wondering under what circumstances you should use brackets and when they should be avoided?

Does this happen with functions as well?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: commands and brackets.

Post by jacque » Sun Feb 15, 2015 6:54 pm

It happens everywhere, including in the body of handlers. Parentheses force evaluation before anything else happens. In the case of function or handler calls, the evaluation occurs before the function/handler being called ever receives the parameters.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: commands and brackets.

Post by dunbarx » Mon Feb 16, 2015 1:35 am

Hi.

Just a note, because this threw me. "Parentheses", or "()", as Jacque assumed and explained, are surely what you were referring to.

"Brackets", or sometimes "Braces", either "{}", or "[]" are entirely different.

Craig Newman

MrFollies
Posts: 29
Joined: Tue Jul 15, 2014 8:30 am

Re: commands and brackets.

Post by MrFollies » Mon Feb 16, 2015 3:59 am

So I guess the default should be to never use them...

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: commands and brackets.

Post by jacque » Mon Feb 16, 2015 5:01 pm

MrFollies wrote:So I guess the default should be to never use them...
Not necessarily as long as you know how they work. And there are times where they are required, like when using URLs as containers or when constructing some types of "if" statements.

I don't usually use them in parameters but you could.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: commands and brackets.

Post by dunbarx » Mon Feb 16, 2015 6:11 pm

I did not mean that at all. It was just that the terms were not quite accurate, at least in the United States. Brackets are not commonly used to mean "()".

Parentheses are not only required (as Jacque said) now and then for the parser to make sense of your code, they are often very useful in simple reading, where code fragments may be isolated by function or by their sense:

put temp into field ("yourField" & y) --required
put temp into field (y + 1) -- merely helpful

Craig

MrFollies
Posts: 29
Joined: Tue Jul 15, 2014 8:30 am

Re: commands and brackets.

Post by MrFollies » Wed Feb 18, 2015 2:04 am

Sorry Craig,

I was replying to Jacque's comment. I understand now that () always means eval(). It's just strange for that to happen also for procedure calls.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: commands and brackets.

Post by FourthWorld » Wed Feb 18, 2015 2:45 am

Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply