Geert,
Every item inside a container must have a
unique name (the first argument to AddObject is a string containing the name), that's what lcName was used for in my code. Then the eval() will give you an object reference that you can use in the WITH construct. Eval() is better to use than & because it's faster. Eval and name expressions can be used in a lot of places where & macros used to be needed. You could populate your array with object names before hand, but you still need eval() to convert the text name to an object reference. When you dimension an array in FoxPro it is filled with .F. in each element, and that's why your code below failed.
Did you know there is the Controls[] and Objects[] collections that you can use to iterate through contained objects once they exist? For example:
activate window "debug output"
for each oObject in this.Objects
debugout oObject.Name
endfor
>However, it turned out not to be possible to use something like
>
>dimension loproductkop(10)
>for i = 1 to 10
> thisform.AddObject( loproductkop(index), "productkop" )
> with loProductkop(i)
> .Top = ...
> .Visible = .t.
> endwith
>endfor
>
>
>Instead, I now used something like your code example.
>I don't like the eval or & coding, but it seems it is the best option around.