Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Complex objects modeling
Message
De
26/10/2018 10:05:36
 
 
À
25/10/2018 23:33:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Divers
Thread ID:
01662805
Message ID:
01662820
Vues:
68
One thought, Marco, I have looked at _(), and see that if you were to mistype a property it would auto-add that mistyped property.

I see you could add a pass-in callback function to your initial existing object setup to allow it to catch unknown properties and specify if it should be returned as an error or added as a new property.

I modify the code below to show the general addition format, an extra parameter on _(), and two new properties added to the empy oMyPc class (added in _(), not shown here):
public oMyPc && check later on your debugger

oMyPc = Createobject('empty')

* _( oMyPc ) will auto-add a .lAdding property, along with a reference to the character string "verify_add" for a callback to issue when something not previously known is found
With _( oMyPc, "verify_add" )  && 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'

	...

	* Indicate we're updating now, not adding
	.lAdding = false
	.modelNmae = .modelName + ' Plus'   && Misspelled here,so it should be a legitimate error

Endwith


* Called to see if it should be added or not
FUNCTION verify_add
LPARAMETERS toObj, tcPropName

	* Are we in adding mode?
	RETURN toObj.lAdding
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform