Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Instantiate a class in code
Message
From
21/03/2024 12:11:47
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
01687754
Message ID:
01687757
Views:
41
>>>Hi,
>>>
>>>Typically - in my VFP9 application - business classes are instantiated in the LOAD of the form. I usually drop the class object on the form - at design time - and the class is instantiated automatically in the LOAD of the form.
>>>
>>>Now I need to instantiate an object of a class in code (in a PRG file). So far, the only way I found I could do it is as follows:
>>>
>>>
>>>oObject = NEWOBJECT("class_name","class_name_lib.vcx" )
>>>
>>>
>>>Can you suggest a better way to instantiate the class?
>>
>>There's a way without the code, but it's tricky. I had to use it when I wanted a bizobject added to a container or page. Namely, I'd add a property which would have this value:
>>
=NEWOBJECT("class_name","class_name_lib.vcx" )
>>Don't remember whether I had to put all of it except the equal sign in parentheses. This made the object instantiate before any other code in the container or page.
>>
>>Unless you need this, what you're doing is already the best way.
>
>First, thank you for your message.
>
>I need this class instantiated in the Main.prg. So, as far as I know, there is nothing to add this class to.
>I suppose - unless someone suggest a better than mine approach - I will keep it in code, as I indicated in the initial post.

You always can add a property to _screen and then instantiated that object.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform