anmldr wrote: ↑Mon Aug 17, 2020 11:12 pm
However, WHY is there never an error on the "repeat with x = 1 to 10" line?
Isn't "x" a local variable also in the script above? Why does it not need to be declared?
Not exactly. Repeat is a control structure, and the conditions are predefined already by the structure.
Dictionary -
The condition is any expression that evaluates to true or false.
The number, startValue, endValue, and increment are numbers or expressions that evaluate to numbers.
The counter or labelVariable is a legal variable name.
The chunkType is one of character (or char), word, line, item, or token.
The container is any existing container. The array is any existing container that contains an array of values.
The statementList consists of one or more LiveCode statements, and can also include if, switch, try, or repeat control structures.
The with form:
The with counter = startValue to endValue form and the with counter = startValue down to endValue form set the counter to the startValue at the beginning of the loop, and increase (or decrease, if you're using the down to form) the countVariable by 1 each time through the loop. When the counter is greater than or equal to the endValue, (less than or equal to, if you're using the down to form), the loop performs its final iteration and then ends.
in the case of a repeat loop, x is not a variable being declared/initiated by you.