Open topic with navigation

TIBCO GridServer® 7.1.0

# The For and Foreach Statement

Explicit looping over an array is not often needed. If you need explicit looping, use the `for` statement:

    for variable in expression
        statements
    end

The expression must evaluate to an array. The variable takes on successive elements of the array on each iteration of the loop. Assignment to the loop variable is legal but has an effect only for the remainder of that iteration. It does not alter the array.

Inside a `for` loop, the variable containing the array returns the value at the current iteration of the loop. This is redundant with the loop variable. For example, in

    for i in $args  log "$i" log "$args" end

the`$i` and `$args` are both equal for each iteration. The loop variable `$i` is there only for convenience.

The `foreach` statement lets you implicitly index an array, without the loop variable:

    foreach expression
        statements
    end

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO GridServer®

Copyright © 2001-2022. TIBCO Software Inc. All Rights Reserved.