Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Pass object to method NOT by reference
Message
De
09/07/2016 05:05:40
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
08/07/2016 21:55:12
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:
01638170
Vues:
82
>Hi Albert, you can serialize and pass your object as Json using
>"nfJsonCreate" and "nfJsonRead" ( https://vfpx.codeplex.com/releases/view/620040 ),
>just change 2 lines of code:
>
>loSomeObject=CREATE("empty")
>ADDPROPERTY(loSomeObject,"FileName","C:\temp\test.doc")
>
>** loFileWhizBang.OutputFile(loSomeObject)
>** changes to:
>loFileWhizBang.OutputFile( nfJsonCreate(loSomeObject) )
>
>*** and method Outputfile ***
>
>LPARAMETERS toFileObjectAsJson
>
>**** Json string back to vfp object:
>toFileObject = nfJsonRead( toFileObjectAsJson )
>
>* strip the path off for some use
>toFileObject.FileName = JUSTFNAME(toFileObject.FileName)

That would work for flat objects, i.e. those without member objects... and it's just adding overhead to the cloning process (converting everything to strings, deciding each element's type and applying appropriate conversion, involving some non-trivial decision making about timezones in cases of datetimes). Dumping the long json string into a file is unnecessary and adds even more overhead - it's just a string, c'mon, you can pass that string as a parameter, what's the file for?

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform