AnsweredAssumed Answered

Auto populate TEXT Fields (dynamic) using READ inside BEGINREAD ... ENDREAD

Question asked by Sai_Krishna_10325 on Feb 6, 2018
Latest reply on Feb 11, 2018 by Wolfgang_Brueckler_1288
CODE SNIPPET

:DEFINE &ARRAY_FIELDS#, STRING, 50          /*Define max Array Size to store field names*/

:SET &ARRAY_FIELDS#[1] = "NAME"                 
:SET &ARRAY_FIELDS#[2] = "AGE"
:SET &ARRAY_FIELDS#[3] = "CITY"

:DEFINE &ARRAY_VALUES#, STRING, 50      /*Define max Array Size to store field values from user input */

:SET &INDEX# = 1

:BEGINREAD
WHILE &INDEX# < LENGTH(&ARRAY_FIELDS#[])
:    IF &ARRAY_FIELDS#[&INDEX#] <> ""
:      READ &ARRAY_VALUES#[&INDEX#], "00", "Please enter your &ARRAY_FIELDS#[&INDEX#]"
:    ELSE
:      SET &INDEX# = LENGTH(&ARRAY_FIELDS#[])
:    ENDIF
:    SET &INDEX# = &INDEX# + 1
ENDWHILE
:ENDREAD

Is it possible to loop over READ inside BEGINREAD ... ENDREAD block ? since, we are getting below error, when we tried to loop through as mentioned in the above code.

RESULT
2/6/2018 01:49:24 PM          U00020353 Runtime error in object 'SCRI.NEW.4', line '00019'. An attempt was made to use a READ statement to set variable 'ARRAY_FIELDS#[00002]' twice within a block READ.

Outcomes