Set up a script for processing and sequentially outputting values from an array using the Expression, Condition, and Information blocks.
This example uses an array created in the Expression block containing the following values:
$array = [1, 2, 3, 4, 5]
Set the loop limit:
1.1. Go to the Settings block.
1.2. Set the maximum number of loops to 99.
Initialize the variables. To do this, add an Expression block with the following code:
$array = [1, 2, 3, 4, 5]
$count = $array.count()
$counter = 0
Add the following Expression block to iterate through the array elements:
$data = $array.get($counter)
$output = str.join([$output, $data, “\n”], “”)
$counter = $counter + 1
Set up the condition:
4.1. Create a Condition block:
Add an Information block to output the {output} variable, which contains the final result.
Add error handling BPL.
Save the script.