Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pass param by reference or private variable?
Message
From
02/10/2019 00:16:22
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01671293
Message ID:
01671311
Views:
61
>>>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?
>>
>>Return an object based on empty with properties storing return values. This way you can return as many strings or not strings as you want
>
>I just did a little test. And it appears that creating an empty object is fairly simple
>
>oEmpty = CREATEOBJECT("empty")
>ADDPROPERTY( oEmpty, "return_success",.T.)
>ADDPROPERTY( oEmpty, "string1","abc")
>ADDPROPERTY( oEmpty, "string2","123")
>oEmpty.return_success = .F.
>RETURN 
>
>
>Thank you.

Because this is a really common functionality, I created a class with 10 standard properties (Value1 - Value10) and a property for Success. I use it everywhere:

LOCAL loInfo AS Info OF Utils.vcx
loInfo = NEWOBJECT("Info", "Utils.vcx")
loInfo.Value1 = 123
loInfo.Value2 = "Test"

THIS.CalculateEtc(m.loInfo)

IF loInfo.Success
Messagebox(loInfo.Value2)
ENDIF
Christian Isberner
Software Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform