Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding an array objects to a form at runtime
Message
 
 
To
22/06/2000 04:36:37
Geert Van Snik
Zorgned Automatisering Bv
Wageningen, Netherlands
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00382600
Message ID:
00383222
Views:
14
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.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform