Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
From Public & Set Proc to Form Properties & Class?
Message
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00520666
Message ID:
00520683
Views:
13
To get you started, create a global application object that will be visible to all forms, classes, reports. This takes the place of all your public variables by adding a property to this goApp object for each public variable.

I also have custom methods in this goApp object. The purpose of the goApp object is to handle anything needed by the entire application session. For example, I have a DoForm method that I pass a form filename to. The second parameter I pass to this method is the name of the form stored in the Name property of the form. If the form is already open, I just Show that form instead of opening multiple instances of the same form.

I also have a ReleaseForm method where I pass the caption name of the form to close. I can also pass "ALL" to this method from the AppShutDown method when the user quits the app. All forms are then released.

I will leave it to others to put forth other ideas.

>When I converted some of my applications from FP2.6 to VFP5.0b about 3 years back, I apparently did it the un-cool incorrect way. Although the applications work fine today, they each have a bunch PUBLIC variables it the load event of the main form. (And I know this makes you guys shudder.) They also each have a SET PROCEDURE TO myprocs.prg.
>
>I now want to attempt to “convert” my applications to something close to what you guys would think would be at least semi-cool or ok. But I need some very basic straight forward tips, because this is new territory to me again. (I have used & created classes for objects before, but never just for code.)
>
>My applications all have a main form, with a pageframe & lots of pages, which is the heart of the app. The form is always private-data-session. I use the form’s data-environment to link all my tables visually. It all works fine. They all have a set procedure to myprocs.prg (for my procedures & functions)
>
>What is the best way forward?
>
>From what I can gather from searching through some older threads, I think I need to do the following:
>
>1. Replace most of the public memory variables with form properties. (Add a new property to the form, for each variable name that I had before) These new properties will be visible to the entire form, and any reports run from it, and any classes on the form (from what I gather)
>
>2. Replace the Procedure myprocs.prg with a class that I drop onto the form.
>3. To create the class, I select create as CUSTOM?
>4. I am not sure if I then add a new property to the class for each procedure (approx 5) that I had in the myprocs.prg file, and put the code in there, but without the Procedure word. (Or could I use the existing class methods?)
>5. I am not sure if I then add a new method to the class for each function (approx 10) that I had, (but leave out the Function word).
>6. Once added, how do I tell, by looking at the properties dialog, if the new item is a property or a method? They look the same to me.
>7. Could I just dump the entire myprocs.prg code (of procedures & functions) somewhere in a method of the class)?
>8. I have the scatter memvar memo command on one of my form’s pages. Do I need to change it to something else?
>9. Once the class is on the form, can I reference it anywhere by issuing myclass.totval() to give me the result of the property/method called totval for example.
>
>Any help on any of the above points will be appreciated to help get me going in the right direction. I just want to establish If I am on the right track before I put in lots of time and effort.
>
>Regards
Mark McCasland
Midlothian, TX USA
Previous
Reply
Map
View

Click here to load this message in the networking platform