Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Pass object to method NOT by reference
Message
De
08/07/2016 20:29:36
 
 
À
08/07/2016 17:15:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8.1
Network:
Windows Server 2012 R2
Database:
Visual FoxPro
Application:
Desktop
Virtual environment:
VMWare
Divers
Thread ID:
01638158
Message ID:
01638162
Vues:
67
>Hi all,
>
>This should be fairly "basic" but have never figured it out...I know how to pass a variable or array to a function by reference (by prefacing with @) but in this case I want to pass an object to a method and force it to pass by "value" i.e. make a copy
>
>loSomeObject=CREATE("empty")
>ADDPROPERTY(loSomeObject,"FileName","C:\temp\test.doc")
>
>loFileWhizBang.OutputFile(loSomeObject)
>
>*** and method Outputfile ***
>
>LPARAMETERS toFileObject
>
>* strip the path off for some use
>toFileObject.FileName = JUSTFNAME(toFileObject.FileName)
>
>I *usually* load everything into local vars when doing things like this but trying to "tighten up" some code, I decided to do the alteration on the object property not realizing that it was not a LOCAL copy. So I instead tried to pass the object in a way that forces toFileObject to a local value. Could not figure and help files did not help.
>
>Any way to do it?

Per https://msdn.microsoft.com/en-CA/library/b2fcckcf(v=vs.80).aspx , "...Visual FoxPro always passes objects by reference."

As Thomas points out, working around that may be more trouble than it's worth.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform