Page 1 of 1

Semicolons -- be cautious if using them

Posted: Fri Feb 19, 2016 1:07 am
by [-hh]
CODE-lines are not TEXT-lines
Yesterday I detected an issue that forces me, who gives 'dangerous' semicolon-examples, to post a warning here.

I like very much to use semicolons ";". Other's don't.
Semincolons are in LC's script lines equivalent to using cr. For example

Code: Select all

 -- The two lines:
    put 1 into vari
    put 2 into varii
-- are equivalent to the one line:
    put 1 into vari ; put 2 into varii
For me, semicolons make the code much better readable and much more faster readable.
And these are my main rules.
  1. 1. Insert semicolons mostly *after* the script is fully working, in order to (visually) compress the code.
    2. Use them also to 'emphasize' the things that remain in single lines.
I posted a lot of scripts that use semicolons extensively here and in (stacks posted to) other subforums . Thus this

WARNING, you have to be aware of the following:
CODE-line numbering may be different from TEXT-line numbering.

For the interpreter a semicolon starts a new "CODE"-line. That is, if an error occurs, as here, in the second part of the script editor line 2,

Code: Select all

1  on mouseUp
2    put 1 into vari; pput 2 into varii
3  end mouseUp
then the offending part is in the dialog said to be in "line 3", that is CODE-line 3.
But it's in line 2 with the numbering of the script editor, of course, that is TEXT-line 2.

Independent of that: The "script" button of the error message jumps always to the correct part of your script in the script editor.