Page 1 of 1

commands and brackets.

Posted: Sun Feb 15, 2015 3:59 am
by MrFollies
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?

Re: commands and brackets.

Posted: Sun Feb 15, 2015 6:54 pm
by jacque
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.

Re: commands and brackets.

Posted: Mon Feb 16, 2015 1:35 am
by dunbarx
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

Re: commands and brackets.

Posted: Mon Feb 16, 2015 3:59 am
by MrFollies
So I guess the default should be to never use them...

Re: commands and brackets.

Posted: Mon Feb 16, 2015 5:01 pm
by jacque
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.

Re: commands and brackets.

Posted: Mon Feb 16, 2015 6:11 pm
by dunbarx
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

Re: commands and brackets.

Posted: Wed Feb 18, 2015 2:04 am
by MrFollies
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.

Re: commands and brackets.

Posted: Wed Feb 18, 2015 2:45 am
by FourthWorld