for (repeat with counter variable)

Syntax

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

 

Can be single line:

for(counter initvalue finalvalue [step]) statements

 

Parameters

counter - counter variable. Type - int, long, 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.

 

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 statements. After each loop adds step to counter. If step is negative, executes statements while counter > finalvalue.

 

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

 

Tips

If you don't need counter variable, 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