I didn't know that ASELOBJ() could give a form reference unless an object on the form was first selected. But from this thread and the example code you listed below, it looks like I can do what I wanted to using ASELOBJ().
Although old habits are hard to break, I agree with both you and Craig. It's time to convert my templates to classes.
Thanks to everyone for the input and suggestions.
>David,
>
>I'm not sure I understand your aversion to using aselobj(). It really was designed to accomplish the task you are wanting to do. Frankly I think your use of the forms collection to access the designer is kind of an obtuse way of doing it.
>
>If you have a template form, (although I strongly agree with Craig about using some form classes is the best alternative) you can use this simple code fragment to replicate the template
>
>use Template1.scx alias TheForm
>select TheForm
>copy to (myform)
>use
>modify form (myform) nowait
>aselobj( laTheForm, 1 )
>DoYourBuilder( laTheForm[1] )
>
>
>>I have several template SCX files for the different types of forms I use. My current form builders copy and rename a template file then use the following commands to open the new form file in design mode, create a reference to it and then add objects and set properties:
>>
>>
MODI FILE (newfile) NOWAIT
>>
>>FOR ln = 1 TO _SCREEN.FormCount
>> IF _SCREEN.Forms(ln).Name = "frmTemplate"
>> lo = _SCREEN.Forms(ln)
>> EXIT
>> ENDIF
>>ENDFOR
>>
>>lo.Caption = "My New Caption"
>>...
>>
>>If I am using the code:
>>
>>
CREATE FORM (myform) AS myForm FROM myForms NOWAIT
>>
>>don't I first have to convert my template SCX files into a VCX class file?