for (repeat with counter variable)

Syntax

for counter initvalue finalvalue [step]
(tab)	statement
(tab)	...
...

 

Can be in single line:

for(counter initvalue finalvalue [step]) statement ...

 

Parts

counter - counter variable. Type - int, long, or unsigned int (lpstr or pointer).

initvalue - initial counter value. Type - type of counter.

finalvalue - final counter value. Type - type of counter.

step - value to add to counter after each loop. Type - int. Default: 1.

statements - one or more statements (commands).

 

Remarks

Simple description:

Repeatedly executes statements, after each loop adding 1 (or step) to counter variable.

 

Complete description:

Assigns initvalue to counter, and, while counter < finalvalue, repeatedly executes block of statements. After each loop adds step to counter. If step is negative, executes block while counter > finalvalue.

 

Use break to exit loop. Use continue to skip following statements.

 

for can be in other block (if, for, ...).

 

Tips

If counter variable is unnecessary, use rep.

 

See also: foreach

 

Examples

lpstr s = "abcd.ef"
int i
int j = len(s)
for i 0 j
	out i
	if s[i] = '.'
		break

for(i 0 j) out i; if(s[i] = '.') break