Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Complex objects modeling
Message
From
26/10/2018 03:33:05
 
 
To
25/10/2018 23:33:01
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Miscellaneous
Thread ID:
01662805
Message ID:
01662809
Views:
80
Well done Marco,

You confirm that the only limit to a programming language, VFP included, is programmers' creativity.


>Because of the Relational Database Orientation of VFP, and lack for native object serialization support ( xml , json ) complex objects were out of the VFP conversation, even rarely you see "scatter name". Last year I shared nfXmlRead/create & nfJsonRead/Create, today I want to share "_" a very simple, small , but powerful function* that allows you to model / modify complex objects using a cleaner, effortless and readable syntax .
>
>Forget about "addproperty" if you need to add more than 1 property to an object, Just put _.prg in your path and start using it like below: ( attached picture shows result )
>
>Marco Plaza
>@vfp2nfox
>
>
>
>public oMyPc && check later on your debugger
>
>oMyPc = Createobject('empty')
>
>With _( oMyPc )  && simply pass object you want to modify, any referenced property will be added to passed object if does not exist:
>
>	.madeBy = 'Marco Plaza, 2018 - nfTools'
>	.manufacturer = 'custom'
>	.basePrice = 699
>	.caseType  = 'ATX'
>	.modelName = 'Ryzen Performance Plus'
>
>	With _( .cpu )   && cpu will be a new object for oMyPc - check we pass ".cpu"  ( dot cpu ) because it's inside with - endwith 
>		.processorcount = 6
>		.brand = 'AMD'
>		.model = 'Ryzen 7'
>		.clockspeed = 4.3
>		.processorCount = 8
>	Endwith
>
>	With _(.motherboard)
>
>		.manufacturer = 'Asus'
>		.model = 'Prime B350-Plus AMD'
>		.formfactor = 'ATX'
>
>		With _(.slots)
>			.Memory = 4
>			.m2 = 1
>			.pcie = 4
>		Endwith
>
>		With _(.storage,'primaryDisk')  && here we create ".storage" and ".storage.primaryDisk"  in a single pass
>			.manufacturer = 'Samsung'
>			.model = '960 evo Series'
>			.Type = 'internal'
>			.connectivity = 'PCIe NVMe M.2'
>			.capacity = '250gb'
>		Endwith
>
>		With _(.storage,'backupDisk')
>			.manufacturer = 'Seagate'
>			.model = 'Barracuda ST3000DM008'
>			.Type = 'Internal'
>			.formfactor = 3.5
>			.capacity = '3tb'
>			.connectivity = 'Sata 6.0'
>			.rotationspeed = 7200
>		Endwith
>
>	Endwith
>
>Endwith
>
>
Thierry Nivelet
FoxinCloud
Give your VFP application a second life, web-based, in YOUR cloud
http://foxincloud.com/
Never explain, never complain (Queen Elizabeth II)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform