Kbase P110860: 4GL: Errors (247) and (194) executing or executing a FOR Statement with var = exp1 TO exp2 option.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  16/11/2005 |
|
Status: Unverified
SYMPTOM(s):
Errors (247) and (194) executing a FOR Statement.
** Unable to understand after -- "<string>". (247)
** Unable to understand after -- "FOR ivariable". (247)
** <pgm> Line <num> --Invalid FOR, DO, REPEAT, or EDITING statement. (194)
** Line 3 --Invalid FOR, DO, REPEAT, or EDITING statement. (194)
Compiling or executing code similar to:
DEFINE VARIABLE ivariable AS INTEGER NO-UNDO.
FOR ivariable = 1 TO 3:
/* do something */
END.
CAUSE:
This is a syntax error. The FOR statement is not a loop control statement, but a data retrieval statement. The [ variable = expression1 TO expression2 [ BY k ] ] option of the FOR statement may be used to limit the number of iteration of the FOR statement.
FIX:
The [ variable = expression1 TO expression2 [ BY k ] ] option of the FOR statement may be used to limit the number of records retrieved to a certain number. In the following example, the first three records are retrieved before the FOR each ENDs.
The DEFINE VARIABLE ivariable AS INTEGER NO-UNDO.
FOR EACH customer NO-LOCK ivariable = 1 TO 3:
DISPLAY NAME.
END.
If looping alone is intended, then use the "DO variable = expression1 TO expression2" statement:
The DEFINE VARIABLE ivariable AS INTEGER NO-UNDO.
DEFINE VARIABLE ivariable AS INTEGER NO-UNDO.
DO ivariable = 1 TO 3:
/* Do some processing here */
END.