Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

for

for( 
s_loopVar
x_initialValue
x_finalValue
g_expr1
[ g_expr2 ... ]
)
=> t

Description

Evaluates the sequence g_expr1, g_expr2 ... for each loop variable value, beginning with x_initialValue and ending with x_finalValue. This is a syntax form.

First evaluates the initial and final values, which set the initial value and final limit for the local loop variable named s_loopVar. Both x_initialValue and x_finalValue must be integer expressions. During each iteration, the sequence of expressions g_expr1, g_expr2 ... is evaluated and the loop variable is then incremented by one. If the loop variable is still less than or equal to the final limit, another iteration is performed. The loop terminates when the loop variable reaches a value greater than the limit. The maximum value for the loop variable is INT_MAX-1. The loop variable must not be changed inside the loop. It is local to the for loop and would not retain any meaningful value upon exit from the for loop.

Arguments

s_loopVar

Name of the local loop variable that must not be changed inside the loop.

x_initialValue

Integer expression setting the initial value for the local loop variable.

x_finalValue

Integer expression giving final limit value for the loop.

g_expr1

Expression to evaluate inside loop.

g_expr2

Additional expression(s) to evaluate inside loop.

Value Returned

t

This construct always returns t.

Examples

The following example prints 10 numbers and returns t.

sum = 0
for( i 1 10
    sum = sum + i
    printf("%d\n" sum))
=> t                          

Related Topics

Flow Control Functions

foreach


Return to top
 ⠀
X