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:51:54
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01671293
Message ID:
01671307
Views:
53
>>>>>>>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 
>>>>>>
>>>>>>
>>>>>
>>>>>...
>>>>>RETURN oEmpty
>>>>>
>>>>>Yep and it'll save a lot of headache in the future
>>>>
>>>>I agree, 100%. I can see a lot of potential. The only problem is that now I want to refactor hundreds of the routines where this approach can be applied :) I have to resist the temptation :)
>>>
>>>Btw, it also good for passing parameters when you have too many of them
>>
>>I agree. In fact this particular method receives 9 parameters. And I may just replace them with one object with 9 properties. Thank you.
>
>An extra bonus by using an object as parameter is that your "parameters" will have names, so you don't have to remember their order.

Good point.
"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
Reply
Map
View

Click here to load this message in the networking platform