Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Instantiate a class in code
Message
From
21/03/2024 11:58:29
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
01687754
Message ID:
01687755
Views:
55
Likes (1)
>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.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform