In my assignment, I am supposed to "translate a string ‘7 3 6 4 10 5 2 8 1 9’ into a datatable in 10 rows so that each row contains one number. As a tip it is suggested using split+for each+add row.
How should I be able to utilize the splitted string in the add data row activity correctly? I haven’t been able to add any rows in the table.
I couldn’t successfully iterate the output variable of Split Text activity to be an array. Is the type Array of [T]? I am not sure whether it makes a difference since I’m using the activity ‘For Each Row in Datatable’
thank you @ppr, I’ll have a look on this next since even with compatible types of variables, the compilation of activities fails and the following errors arise
You don’t use For Each Row in Data Table. You don’t have a datatable. You have an array.
Use a regular For Each.
Also, you have numbersArray in the For Each’s Item property. This indicates you don’t quite understand the For Each.
Your array is myData - ie an array with the elements 7, 3, 6, 4 etc
When you do a For Each it loops through those items. On the first iteration of the loop the value of the Item is 7. On the second iteration it’s 3. On the third iteration it’s 6. etc.
Switch to a regular For Each, change “numbersArray” to currentNumber and it’ll make more sense. Then you just put {currentNumber} into the ArrayRow property of the Add Data Row.
Also, you don’t need to use the Split Text activity. Store “7 3 6 4…” etc in a string variable. Then in the For Each put yourStringVarName.Split(" "c) which does the same thing as the Split Text activity.