Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello All,
while looping over an inline table I experienced something that i do not understand. The following script creates the output shown as "Reality Output", but i would expect the output to be like "Expected Output". Can someone explain give advice how i can load the data so i get the desired output?
[Table]:
Load * inline
[
Column1, Column2
Test,Value 1
Test,Value 2
Test1, Value 3
];
LET NumRows=NoOfRows('Table');
FOR i=1 to $(NumRows)
LET vColumn1=FieldValue('Column1',$(i));
LET vColumn2=FieldValue('Column2',$(i));
Trace 'DEBUG: ' $(vColumn1) ',' $(vColumn2);
NEXT;
/*Expection Output:
'DEBUG: ' Test ',' Value 1
'DEBUG: ' Test ',' Value 2
'DEBUG: ' Test 1 ',' Value 3
Reality Output:
'DEBUG: ' Test ',' Value 1
'DEBUG: ' Test1 ',' Value 2
'DEBUG: ' ',' Value 3
*/
Try like:
LET NumRows=NoOfRows('Table');
FOR i=0 to $(NumRows)-1
LET vColumn1=Peek('Column1',$(i));
LET vColumn2=Peek('Column2',$(i));
Trace 'DEBUG: ' $(vColumn1) ',' $(vColumn2);
NEXT;
FieldValue() doesn't work on record count, but on distinct count of field values. In your field Column1, there are two values and they would be indexed as :
Field Value Index
Column1 Test 1
Column1 Test 1
Column1 Test1 2
Now you can interpret, I guess.
thank you for the reply - i understand. Is there any other way to get the data out of the inline table in the way that i need it to?
Try like:
LET NumRows=NoOfRows('Table');
FOR i=0 to $(NumRows)-1
LET vColumn1=Peek('Column1',$(i));
LET vColumn2=Peek('Column2',$(i));
Trace 'DEBUG: ' $(vColumn1) ',' $(vColumn2);
NEXT;