Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: George Kelly
  Where is George Kelly?
 Dromore
 United Kingdom
 George Kelly
 To: Don Higgins
  Where is Don Higgins?
 Peoria
 Illinois - United States
 Don Higgins
 Tags
Subject: RE: maximizing my applications main screen
Thread ID: 110937 Message ID: 115493 # Views: 3 # Ratings: 0
Version: Visual FoxPro 9 Category: Forms
Date: Friday, December 08, 2006 11:21:35 AM         
   


> >
> > Another lesson learned! Thanks for the tips, Ken. I shall look at using PRIVATE variables as suggested elsewhere in this thread.
> > I can well imagine the nightmare if public variables were redefined in code.
> >
> > George
>
>
> NO! I used to be the king of public variables until Marcia kicked me really hard and told me to stop it. Private variables are no better. The ONE and ONLY way to properly use your preferences is open your preferences table and extract the information to a form property. I now have 1 public variable which is if my application is in EXE mode or development mode.
>
> For your example:
>
> if used("MyPreferences")
> select MyPrefernces
> thisform.FontControl = addtofont
> else
> use Tables\MyPreferences
> thisform.FontControl = addtofont
> endif
>
>
>
>
> Andy has a better way to open the tables with a class but this code will work for the most part.
>
> YES you will need to change some of your code, takes a few minutes to replace that nasty public variable with a form property but you will thank us in the end. Instead of ADDTOFONT in your code replace it with ThisForm.FontControl or Thisform.AddToFont, your choice what you call it.
>
>
> Don Higgins
>
>
>
>
>
>
>

Thanks for that tip Don
Having used PUBLIC variables for so many years, and never having problems, I'm amazed at the their "lack of popularity" by the experts.

I find it very easy to keep track of my public variables. In fact, I get far more problems when I DONT declare variables public. That DOES cause program errors, if a variable is called and its value hasn't passed through to a sub form.

Going back to old days, early Foxpro, once you initialised a variable in SETUP snippet (an old term) it could be referred to in any code snippet in that screen (oops... form).
Not only that, but if you clicked a button and opened another form, that variable persisted.
I didnt have to declare it at all - e.g. LOCAL or PRIVATE
e.g.
m.varname= 10
was enough. Presumably it defaulted to declaring it as a PRIVATE variable?

I found it quite troublesome when Visual Foxpro came along - the variables did NOT persist. Got-ya's abounded. In a Y2K job, I had one week to upgrade a system from 2.6 to VFP 6 (6?). At that time, I simply declared the variables public in the initial form, and everything worked.

I also use form properties extensively, for variables and arrays, so no problem in changing to that technique.
I'll bow to PUBLIC pressure. I'll go for your solution.
Old dog learning new tricks!

George

ENTIRE THREAD

maximizing my applications main screen Posted by Jahangir Khan @ 10/24/2006 10:41:17 AM
RE: maximizing my applications main screen Posted by Kiran Kumar Singh @ 10/24/2006 10:57:45 AM
RE: maximizing my applications main screen Posted by Saeed Afshari @ 10/24/2006 10:58:31 AM
RE: maximizing my applications main screen Posted by Borislav Borissov @ 10/24/2006 10:58:32 AM
RE: maximizing my applications main screen Posted by Dave Crozier @ 10/24/2006 10:59:29 AM
RE: maximizing my applications main screen Posted by Marcia Akins @ 10/24/2006 12:19:34 PM
RE: maximizing my applications main screen Posted by George Kelly @ 11/15/2006 10:53:09 AM
RE: maximizing my applications main screen Posted by Marcia Akins @ 12/6/2006 11:55:15 PM
RE: maximizing my applications main screen Posted by George Kelly @ 12/7/2006 10:52:23 AM
RE: maximizing my applications main screen Posted by Marcia Akins @ 12/7/2006 12:40:34 PM
RE: maximizing my applications main screen Posted by George Kelly @ 12/7/2006 1:08:03 PM
RE: maximizing my applications main screen Posted by Ken Murphy @ 12/7/2006 1:44:55 PM
RE: maximizing my applications main screen Posted by tushar @ 12/7/2006 3:26:59 PM
RE: maximizing my applications main screen Posted by Ken Murphy @ 12/7/2006 3:31:52 PM
RE: maximizing my applications main screen Posted by George Kelly @ 12/7/2006 4:51:26 PM
RE: maximizing my applications main screen Posted by Ken Murphy @ 12/7/2006 6:07:40 PM
RE: maximizing my applications main screen Posted by George Kelly @ 12/7/2006 9:23:25 PM
RE: maximizing my applications main screen Posted by Don Higgins @ 12/7/2006 11:20:46 PM
RE: maximizing my applications main screen Posted by George Kelly @ 12/8/2006 11:21:35 AM
RE: maximizing my applications main screen Posted by Ken Murphy @ 12/7/2006 3:29:56 PM
RE: maximizing my applications main screen Posted by Don Higgins @ 12/7/2006 11:22:33 PM
RE: maximizing my applications main screen Posted by George Kelly @ 12/6/2006 1:14:45 PM
RE: maximizing my applications main screen Posted by Barbara Peisch @ 10/24/2006 10:16:51 PM
RE: maximizing my applications main screen Posted by Mike Gagnon @ 10/25/2006 11:43:05 AM