Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to create an application object?
Message
 
 
To
06/12/2002 17:29:23
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00730510
Message ID:
00730512
Views:
14
This message has been marked as the solution to the initial question of the thread.
>In many threads application objects are discussed as being one way to avoid using public global variables when there is common information needed by several objects. At this time I am not using a framework of any kind and that is the only place I have seen application objects. Is there an example somewhere of what an application object looks like, how to create one, etc.? Or do people use the appplication wizard and application objects from the framework that comes with VFP?

In my MAIN.PRG, I have the following:

private goApp
goApp = newobject('AppManager', 'AppMgr.FXP')

Because its scope is private, it is visible to every form, procedure, etc., that is called because MAIN.PRG is the first program code to fire in the app. In my AppMgr.PRG, I have something like:
DEFINE CLASS AppManager as CUSTOM

   nUserID = 0
   nUserName = []
   * other properties here

   PROTECTED PROCEDURE INIT
      * some init code here
   ENDPROC
   PROCEDURE RELEASE
      RELEASE THIS
   ENDPROC
   PROTECTED PROCEDURE DESTROY
      * set any KNOWN object references stored
      * in proerties of this class to .NULL. here
   ENDPROC
   PROCEDURE App_Error_Handler
      * This is where you can put your global error handler
   ENDPROC

   * Other Procedures You want here

ENDDEF
You can use AddProperty(goApp, 'PropName') anywhere in your app as needed.
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform