Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OCollection_ASSIGN Problem
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01219959
Message ID:
01285948
Views:
21
I'm not sure there is good generic way to achive that. If you only want to prevent adding items after LoadInvoices than _Assign on lAllowLoad property should do the trick.
DEFINE CLASS Col AS Collection
	lAllowLoad = .T.
	PROCEDURE lAllowLoad_Assign(tlNewVal)
                * Do not allow to turn it on again 
		IF This.lAllowLoad AND NOT tlNewVal
			This.lAllowLoad = tlNewVal
		ENDIF
	ENDPROC
	PROCEDURE Add(eItem, cKey, eBeforere, eAfter)
	IF NOT This.lAllowLoad
		ERROR 1740
	ENDIF
	...
	ENDPROC
ENDDEFINE
>Sorry, I should elaborate more.
>
>I don't want developers using this class to be able to add items to the collection
>from outside LoadInvoices.
>
>Someone could do:
>
>
>
>oCustomer.LoadInvoices()
>oCustomer.oInvoices.lAllowLoad = .T.
>oCustomer.oInvoices.Add(...)
>
>
>See the problem?
>
>
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform