Program is:

- Code: Select all
`lov={1,2,3,4,5}`

For Local i=0 To ListItems(lov)-1

DebugPrint("lov[" .. i .. "]=" .. lov[i])

Next

DebugPrint("-------------")

ForEachI(lov,Function(p_index,p_value) DebugPrint("lov[" .. p_index .. "]=" .. p_value) EndFunction)

DebugPrint("-------------")

ForEach(lov,Function(p_index,p_value) DebugPrint("lov[" .. p_index .. "]=" .. p_value) EndFunction)

output is:

- Code: Select all
`lov[0]=1`

lov[1]=2

lov[2]=3

lov[3]=4

lov[4]=5

-------------

lov[0]=1

lov[1]=2

lov[2]=3

lov[3]=4

lov[4]=5

-------------

lov[1]=2

lov[2]=3

lov[3]=4

lov[4]=5

lov[0]=1

While For and ForEachI start with first element in table and stop with last one, ForEach however starts with second element, traverses to last one, and then as last action performs user function on the first element of the table.

Thus one cannot use ForEach if the order of execution is important !