TeleFlow BasicScript ForNext

TeleFlow BasicScript ForNext

From TeleFlow

(Difference between revisions)
Jump to: navigation, search

Wikilib (Talk | contribs)
(New page: Executes one or more statements in the FOR … NEXT loop a specified number of times as defined by the range of start and end values as incremented by the optional STEP stepvalue (default ...)
Next diff →

Current revision

Executes one or more statements in the FOR … NEXT loop a specified number of times as defined by the range of start and end values as incremented by the optional STEP stepvalue (default value is 1). The EXIT FOR (optional) keyword in a FOR loop forces a premature exit of the loop and resumes with the remainder of the BasicScript.

Syntax

FOR variable = start TO end [STEP stepvalue]
BasicScript statement(s)
[EXIT FOR]
BasicScript statement(s)
NEXT


variable: variable name to increment on each NEXT keyword. TeleFlow (including BasicScript) variables are always preceded by a '@' character.
start: beginning value (integer) at which the variable starts the FOR loop.
end: final value (integer) at which the variable stops (and exits) the FOR loop.
stepvalue: the increment on each NEXT of variable. An integer value is expected. This value can't be zero. The "STEP stepvalue" can be omitted, in which case the stepvalue is one.


Related Steps

Image:Iv_517.gif BasicScript

Examples

BasicScript code

 

Result

 

PRINT "start"

FOR @VAR = 1 TO 10 STEP 2

PRINT "@VAR"

NEXT

PRINT "end"

Start

1

3

5

7

9

end

PRINT "start"

FOR @VAR = 5 TO 1 STEP -1

PRINT "@VAR"

NEXT

PRINT "end"

Start

5

4

3

2

1

end

PRINT "start"

FOR @VAR = 1 TO 5

PRINT "@VAR"

NEXT

PRINT "end"

start

1

2

3

4

5

end

PRINT "start"

FOR @VAR = 1 TO 100

PRINT "@VAR"

IF @VAR >= 5 THEN

   EXIT FOR

END

NEXT

PRINT "end"

start

1

2

3

4

5

end

 

 

PRINT "start"

VARDDATE = "2005/01/01"

FOR @VAR = 1 TO 5

@TOTVARDDATE = @VARDDATE + @VAR

IF @TOTVARDDATE >= "2005/01/03 THEN

   EXIT FOR

   PRINT "@TOTVARDATE"

END

NEXT

PRINT "end"

start

2005/01/01

2005/01/02

end