Hitachi

JP1 Version 12 JP1/IT Desktop Management 2 Distribution Function Administration Guide


18.6.6 for-next

The for-next statement executes the expression repeatedly until the condition becomes false. The optional expression supported in the for-next statement allows you to initialize or change a value during for-next statement execution.

Typically, the number of times a loop is repeated depends on the counter.

Organization of this subsection

(1) Format

for ( [initialization-expression] ; [condition-expression] ; [loop-expression] )
     expression-1;
     expression-2;
next;

(2) Description

  1. When an initialization expression is specified, it is evaluated. It specifies loop initialization. The initialization expression may be any type.

  2. A specified condition expression is evaluated before repetition, with three possible results:

    • If the condition expression is true (not 0), the statement is executed. A specified loop expression is evaluated next. According to the evaluation, execution is repeated.

    • With no condition expression specified, the condition expression is interpreted as true, and executed in the same way as above. With a condition expression not specified by a parameter, the for statement ends when the goto statement (associated with a labeled statement outside the main part of that statement) or the break statement is executed inside that statement.

    • If the condition expression is false (0), the for-next statement ends, and the control moves to the next statement in the same program.

  3. When the system encounters a break statement specified in the main part of that statement, the loop stops.

  4. When the system encounters a continue statement specified in the main part of that statement, the subsequent steps are skipped, with the condition expression evaluated. If the condition is true, the execution is repeated.

You should not nest more than 255 for-next structures.

(3) Example of coding

DEFINE
{
integer WINH,count,length;
float SLEEP_TIME=0.5;
string s1,s2;
integer i,sloop_cnt   = 0;
integer sloop_max = 30;
}
...
...
sloop_cnt=1;
AIT_LogMessage("Searching for Active windows - For");
for(; sloop_cnt < sloop_max ;sloop_cnt = sloop_cnt + 1)
    if (AIT_FocusWindow("Unpacking", "#32770",0.0) > 0)
        if(AIT_FocusWindow("Unpacking Installable Software...", "#32770", 0.0) > 0)
           AIT_LogMessage("Unpacking Installable Software... is opened");
           sloop_cnt= 0;
           AIT_Sleep(SLEEP_TIME);
        endif;
        endif;
   AIT_Sleep(SLEEP_TIME);
next;