>I am trying to write a simple builder that will add a label and text box to a form. The label and text box are in custom classes in .VCX files. I have written a number of tool programs to help me in the layout and cleanup of forms but they all work with objects that were already on the form. I tried using addobject() but it will only add objects based on the FoxPro base classes and it also does not return a reference to the newly created object (although I could do a new aselobj() and find the new name if I had to).
>
>I'm sure there is a fuction to do all this but I can't seem to find it. Any help would be greatly appreciated.
You should be able to addobject() as soon as you've Set Classlib To whatever class library you need. Or you could NewObject() with specifying the class library name.
As to the reference, you can create one on the fly:
=aselobj(aa, 1)
with aa[1]
.addobject('oThing','Things','Things.vcx')
loThing=eval('.oThing')
endwith
Now loThing should be a reference to the new object in the form you're editing, and you can pretty much do with it whatever you like.
I haven't tested this, though, but I figure a three-liner can't be too hard. I'm not writing registrable builders anymore, I simply call them from the command window while editing something. It's just easier and faster that way - most of these 'builders' are just few lines long, and would easily clutter the tiny listbox you get when you select the Builder from the shortcut menu. Besides, just making reasonable names for them is too much of a hassle, and registering them would be too much :)