
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For loop to iterate two fields at the same time
I've a inline table
F1 | F2 |
1 | A |
2 | B |
3 | C |
I would like to loop both columns and assign a variable to them accordingly to be used. example:
For x,y in FieldValueList(F1,F2)
set vX ="x";
set vY ="y";
Trace $(vX) and $(vY) ;
next
The result i get should be:
1 and A
2 and B
3 and C
but the above for loop syntax is wrong. what is the right syntax?
thanks in advance
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, the syntax is wrong and it wouldn't work with multiple fields at the same time - else only for a single field and then the next one and/or nesting multiple loops.
Beside this the above won't work within many scenarios because the field-values are on the field-level independent to each other. To get multiple fields synchronized you need to loop through a table, maybe like this:
for i = 0 to noofrows('MyTable') - 1
let v1 = peek('Field1, $(i), 'MyTable');
let v2 = peek('Field2, $(i), 'MyTable');
trace $(v1) + $(v2);
next


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, the syntax is wrong and it wouldn't work with multiple fields at the same time - else only for a single field and then the next one and/or nesting multiple loops.
Beside this the above won't work within many scenarios because the field-values are on the field-level independent to each other. To get multiple fields synchronized you need to loop through a table, maybe like this:
for i = 0 to noofrows('MyTable') - 1
let v1 = peek('Field1, $(i), 'MyTable');
let v2 = peek('Field2, $(i), 'MyTable');
trace $(v1) + $(v2);
next

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you! @marcus_sommer it is exactly what I needed.
interesting that this: for i = 0 to noofrows('MyTable') - 1 indicates that the index of the table starts at 0
but if I use this instead the index starts at 1 :
For Each i in FieldValueList('F1')
LET idx_i = FieldIndex('F1','$(i)');


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The same index-range and also the same notation-requirements for table/field-names everywhere would be too easy 😉
