Hi everyone,
I’m having trouble with a script where I need to loop through an array and display its contents. My goal is to create a list from the array values and set it in a field. However, the field is only displaying the first value of the array, not iterating through the rest.When I run the script, only "Apple" is displayed in the field "fruitList". The other values are not being added to the field.
Is there something wrong with the way I’m using the `repeat for each` loop to iterate through the array?
How can I ensure all values in the array are displayed in the field?
I’m having trouble with a script where I need to loop through an array and display its contents. My goal is to create a list from the array values and set it in a field. However, the field is only displaying the first value of the array, not iterating through the rest.
CODE:
-- Define and populate the arrayput "Apple" into tArray["fruit1"]put "Banana" into tArray["fruit2"]put "Cherry" into tArray["fruit3"]-- Initialize the fieldput "" into fld "fruitList"-- Loop through the array and display valuesrepeat for each key tKey in tArray put tArray[tKey] & cr after fld "fruitList"end repeat
Is there something wrong with the way I’m using the `repeat for each` loop to iterate through the array?
How can I ensure all values in the array are displayed in the field?
Statistics: Posted by elenagilbert — Wed Aug 21, 2024 4:33 am