For / end for – BrightSign BrightScript 3.0 Reference Manual User Manual

Page 43

Advertising
background image

38

POS(x)
This statement returns an integer that indicates the current cursor position from 0 to the maximum width of the window.
This statement requires a dummy argument in the form of any numeric expression.

Example:
print tab(40) pos(0) 'prints 40 at position 40

print "these" tab(pos(0)+5)"words" tab(pos(0)+5)"are";
print tab(pos(0)+5)"evenly" tab(pos(0)+5)"spaced"

FOR / END FOR

FOR counter_variable = initial_value TO final_value STEP increment / END FOR

The

FOR statement creates an iterative loop that allows a sequence of program statements to be executed a specified

number of times.

The

initial_value, final_value, and increment can be any expression. The first time the FOR statement is

executed, these three variables are evaluated and their values are saved; changing the variables during the loop will have
no affect on the operation of the loop. However, the

counter_variable must not be changed, or the loop will not

operate normally. The first time the

FOR statement is executed, the counter is set to both the value and type of the

initial_value.

At the beginning of each loop, the value of the

counter_variable is compared with the final_value. If the value of

the

counter_variable is greater than the final_value, the loop will complete and execution will continue with the

statement following the

END FOR statement. If, on the other hand, the counter has not yet exceeded the final_value,

control passes to the first statement after the

FOR statement. If increment is a negative number, the loop will complete

when the value of the

counter_variable is less than the final_value.

Advertising