Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

for each loop on a field

Hello,

Would it be possible to use "for each" loop on a field of a table?

Like:

Let vfileList = Some_Kind_of_Function('fieldName'); //fieldName is a field of a table

for each vfile in $vfileList

  Do something....

next

Thanks,

Josh

5 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Use this code pattern:

For i = 0 To NoOfRows('tableName') - 1

     Let vVal = Peek('fieldName', i, 'tableName');

     // do something ....

Next

Edit - added the '-1'

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Kushal_Chawda

Can you please explain the scenario?

Data:

Load  Field1,

         Field 2

From Table

let vFieldValueCount = FieldValueCount ('Field1');

For i=1 to $(vFieldValueCount)

let vFieldValue = FieldValue('Field1',$(i));

...

...

Next i

Anonymous
Not applicable
Author

Hello,

Thanks for answer.

Sorry I forgot the mention he point.

I want to drop the table as soon as the field is set to a list variable.

Thanks,

Josh

jonathandienst
Partner - Champion III
Partner - Champion III

OK, so add the line

Drop Table tablename;


What precisely do you mean by "list variable"?

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Kushal_Chawda

Data:

Load  Field1,

         Field 2

From Table

let vFieldValueCount = FieldValueCount ('Field1');

For i=1 to $(vFieldValueCount)

let vFieldValue = FieldValue('Field1',$(i));

...

...

Next i

drop table Data;