Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Khalil Shaddad
  Where is Khalil Shaddad?
 Beirut
 Lebanon
 Khalil Shaddad
 To: Jamie Osborn
  Where is Jamie Osborn?
 Melbourne
 Australia
 Jamie Osborn
 Tags
Subject: RE: How to use private and declare a variable i...
Thread ID: 16299 Message ID: 16390 # Views: 1 # Ratings: 0
Version: Unknown Category: General VFP Topics
Date: Friday, October 18, 2002 10:12:05 AM         
   


> > Thanks for the answer, but i don't get it too work.
> >
> > I use the variable m.main for some bottoms-code like:
> >
> > skip in (m.main)
> >
> > or
> >
> > go top in (m.main)
> >
> > Hove to solv this?
> >
> > Thanks
> >
> > > Add property 'main' in the form init event, like
> > > thisform.addproperty("main","customer")
> > >
> > > Then you will be able to call this as variable everywhere in the form, like:
> > > thisfrom.main="customer2"
> > >
> > > Regards
> > >
> > >
> > > > I try to use a variable in all forms named m.main telling what table is the leading table in every form. I try to put this in INIT EVENT of the form:
> > > >
> > > > Private main
> > > > m.main="customer"
> > > >
> > > > But when i try to use m.main in the program i get a error "Variable 'main' is not found."
> > > >
> > > > How do i get the m.main to be accessed i the hole form?
> > > >
> > > > Leri
> >
> >
> > Leri
>
> Yuri's code will work - you just refer to thisform.main
> eg. SKIP IN (thisform.main)
> Better than having a global variable for every form !!!!
>
> If the form is calling code that needs to know the property value then pass an object reference to the form
> eg.
> From the form :
>
> lResult = MyProc(thisform)
> 

> In MyProc.Prg :
>
> LPARAMETERS toForm
> 
> SKIP IN (toForm.main)
> 

>
> Cheers,
> Jamie
> jamie.osborn@foxite.com
Hi,
Jamie is right for one main reason: using public variables will result in conflicts in two different processes within the same process, whereas, using properties you will never have conflicts. i.e. if you run your form more than once in the same process, your public variables will not be consistent and you will face problems, whereas, using user defined properties each ran form will have his own working area.
maybe you do not need to run your form more than once but still reducing public variables is a good practice .
Khalil Shaddad (Lebanon)

ENTIRE THREAD

How to use private and declare a variable in forms Posted by Leif Rickegard @ 10/16/2002 10:42:35 AM
RE: How to use private and declare a variable i... Posted by Yuri Rubinov @ 10/16/2002 2:37:16 PM
RE: How to use private and declare a variable i... Posted by Leif Rickegard @ 10/16/2002 3:37:49 PM
RE: How to use private and declare a variable i... Posted by Yuri Rubinov @ 10/16/2002 3:54:47 PM
RE: How to use private and declare a variable i... Posted by Leif Rickegard @ 10/16/2002 7:57:03 PM
RE: Remember to release the public variable Posted by Vyas Kumar R @ 10/17/2002 6:28:31 AM
RE: How to use private and declare a variable i... Posted by Jamie Osborn @ 10/17/2002 8:31:36 AM
RE: How to use private and declare a variable i... Posted by Khalil Shaddad @ 10/18/2002 10:12:05 AM