Trouble with 'there is a'
Bob Sneidar
bobs at twft.com
Fri Jan 27 12:13:11 EST 2012
I remember a long time ago in a Revolution conference far, far away, someone gave a class on good coding habits. One of the habits he mentioned was to enclose in parenthesis where you can, partly for this reason, and partly because it makes the code easier to read. I go halfway. If I have any doubt about the precedence of a statement, I use parenthesis.
In fact, an even better habit is to put paths into variables, or just put anything into variables, then work with those. It makes debugging a whole lot easier, and code easier to read.
Bob
On Jan 27, 2012, at 3:37 AM, Graham Samuel wrote:
> 2. The form of my 'if' condition was
>
> if there is not a file myPath &"/" & myfilename
>
> it turns out that the 'there is no' statement doesn't construct the string before the evaluation: you have to ensure the evaluation of the string by putting it in brackets as in
>
> if there is not a file (myPath &"/" & myfilename)
>
> There is an obscure warning about this in the dictionary: "The there is no operator is implemented internally as a function, and therefore has lower precedence than other operators". So it's a precedence issue.
>
> Graham
More information about the use-livecode
mailing list