Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pass param by reference or private variable?
Message
 
 
To
01/10/2019 16:28:09
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01671293
Message ID:
01671305
Views:
50
>Hi,
>
>>>I need a method of a object to return some strings (actually two). I can declare the variables as Private before calling the method and set the values of the variables inside the method.
>>>Or I can declare the variables Local and pass them by reference (with @). Therefore, when passing by reference the variable value can be set within the method and afterward get the value.
>>>What is better practice?
>
>Not sure about practice - but VFP defaults to "private" when you create a variable and they're intended to be accessible in subroutines. I have very old code that makes full use of this.
>
>Worth noting that if you
>
DO MYproc with m.myvar1,m.myvar2
>
>those variables are passed by reference, meaning you can update them in the proc. That might be clearer.

Thank you. I decided (already re-writing) to go with what Sergey and Tore suggested: create an object with properties and return it.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform