What is the correct ending semicolon syntax in Tinderbox for functions vs if...else statements...vs in nested loops?

I am getting confused when I need to add a semicolon especially after a “}”…

In functions: I believe this is correct (thanks @satikusala
function MyFunction(){
code here
} //no semicolon

if then else: is this correct
if(IfStatement)else{ThisIsMyElseStatement}; //yes semicolon

what about within a nested loop?

Lastly, I am using a semicolon between actions, for example:
$OnAdd= $MyFirstAction; $MySecondAction; $MyThirdAction;

Am I on the right track?
Tom

I believe semicolons are need to end all lines of action code. The only place I’ve not see them used in is the blocking of a function,

1 Like

The variable is need, as the Tinderbox parser will generally figure out intent.

To avoid ambiguity, I use a semicolon after the last } of an if{}else{}, .each(){}, or other operative using a {} delimited code block. The terminating semi-colon may be optional but it more likely unambiguous in stating intent to the parser.

1 Like

what about at the end of a function? I did not notice a “semicolon” of the ending seimicolon in aTBRef syntax for function


function MyFunction(){
code
}

Semicolons separate statements:

$MyNumber=42; $MyString="souflé"

When more than one statement occurs inside a control expression such as if/then or each, the statements are separated with semicolons.

if(..) {$MyNumber=42; $MyString="souflé";}

You do not need a semicolon after the closing } of a control expression, or the closing } of a function definition.

2 Likes

what about nested if statements, like this one…do I need a semicolon

Sorry to be so dense…but I feel this is important.

Tom

The semicolon at which the arrow points — the semicolon following the closing }, is not necessary* but does no harm.

  • I can concoct odd scenarios with complex, nested conditionals where I think the semicolon might have an effect. But you should avoid complex, nested conditionals and such anyway.
2 Likes