Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What's the secret meaning of this piece of code?
Message
De
03/08/1997 13:01:53
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
03/08/1997 12:51:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00042899
Message ID:
00042998
Vues:
37
>>Hey you're talking about only VFP ? What happened to line saying an old program written in 2.6. Should I go to a doctor for my eyes ?
>
>No, Cetin, don't worry about your eyes. It's about a program in FP2.6 for Unix.
>
>>Try it in FP 2.6 and older versions and see how can you release a public var passed as a parameter. Here is the code to try :
>
>In your example, things go like that:
>1. myvar is declared public at the level 1
>2. myvar is declared parameter (and private) at level 2 (in the Main proc)
>3. The Main proc is called with myvar as the first parameter
>
>In this case, myvar is passed by reference. It means that in the main proc, myvar points at the same memory address (it's located in the same place in the memory) as the public myvar declared at level 1. This is the reason for which the myvar variable is released also at level 1. As I already said, the params passing mechanism is responsible and not the fact that params would not be private.
>
>You are somehow right and I would not advise to release params in a proc. Anyway, I don't see any reason to do it. If you passed a param, probably you need it. So, there is no reason to release it. And even if you need to release it, don't do it. There's also kinda bug here. If the param has exactly the same name as the variable passed to, the variable will be released at both levels. If the name is different, the variable is released only at proc level. But all this comes from the passing by reference (for procs) and not from the fact that params are not private.
>
>To see that I'm right, try the following:
>
>public myvar
>myvar = 12
>myvar1 = 20
>do main with myvar1
>
>proc main
>parameters myvar
>myvar = 25 && This will change myvar1 also at previous level
>release myvar && This will NOT release myvar1 at previous level
>
>HTH,
>Vlad
Paul,
This discussion got so long. We all have to write programs to earn. If you are sure in your main program you didn't release a variable declared at a higher level than simply remove the line or rem it. CPU would appreciate it. JP Steffen was so right about how you declared Clipper guilty.
Cetin
Ç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
Répondre
Fil
Voir

Click here to load this message in the networking platform