Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Local vs private
Message
De
10/08/2005 11:29:02
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
10/08/2005 11:21:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01039725
Message ID:
01039880
Vues:
20
Don,
"report form" is a command, not a procedure. That means report sees all the variables/references that are visible to the routine that called "report form" command. ie:
* A form button click
* assume there is thisform.text1 object
local ltStart, ltEnd, lcTitle
ltStart = datetime() - 86400 * 5
ltEnd   = datetime()
lcTitle = "Report of blah blah"
* cursor for report prepared
report form myReport preview
In report you could use m.ltStart, m.ltEnd, m.lcTitle, thisform.text1.value etc.
Cetin



>Thanks Tom -
>I only use public variables in 2 instances. The first is when I want a value to be seen by the entire application such as a security value that is referenced by all the controls on all the forms. The second is when I want to pass a value to a report, such as a variable report title, since I haven't found another way to do that. Any thoughts?
>- Don
>
>>Don;
>>
>>The concept of a Public variable is to allow an entire application to use the contents of the variable. Using VFP I do not use PUBLIC as it is not very object oriented. It is better to use Local variables and Private if necessary. When I was learning OOP the instructor insisted, “Create objects and send messages to those objects. Never use Public variables”!
>>
>>Public variables can be a problem as I have experienced. Eleven years ago we wrote a FoxPro 2.6 application, and Public variables were in use. All was well upon the applications release into production – until… At the end of the month a report was run and crashed the system. Someone had used the same Public variable with a different data type!
>>
>>Tom
>>
>>
>>>Thanks Sergy, that explains a 3 hour puzzle I worked on this AM. But if the PRIVATE variables can be seen by the chain of functions and procedures that follow and initial routine, how does that differ from PUBLIC? Is it that the PUBLIC variable can be seen even if it wasn't identified in the calling program?
>>>
>>>
>>>>The private variables/parameters are visible in the called programs. The LOCAL variables/parameters are only visible in the program where they have been declared.
PRIVATE pcVar1
>>>>LOCAL lcVvar2
>>>>
>>>>pcVar1 = "PRIVATE"
>>>>lcVvar2 = "LOCAL"
>>>>? pcVar1
>>>>? lcVvar2
>>>>
>>>>DO myprg
>>>>
>>>>PROCEDURE myprg
>>>>? pcVar1
>>>>? lcVvar2    && Error
>>>>RETURN
>>>>
Also, as you correctly noted, LOCAL defines variable. The PRIVATE only hides variable if it existed before or does nothing if variable didn't exist. Any variable that get value assigned w/o declaration became PRIVATE in scope.
>>>>
>>>>
>>>>>Can someone give me a simple but clear understanding of the difference between LOCAL and PRIVATE? I've read the docs but they leave me unsatisfied. I understand that LOCAL actually creates a variable whereas PRIVATE does not. So is PRIVATE just a means to convert a public variable into a local one?
>>>>>
>>>>>Also LPARAMETERS vs PARAMETERS? One is LOCAL and the other is PRIVATE? I don't see the difference. Also, aren't variables created as LOCAL or PRIVATE by default without specifying? If so, what's the point?
>>>>>
>>>>>Thanks for any insights in this.
>>>>>
>>>>>- Don
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform