Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Complex objects modeling
Message
 
To
22/11/2018 10:21:03
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:
01663713
Views:
64
So I took a look at the WITH code - can you elaborate what doesn't work? I can do the following with the implementation I posted earlier:
DO wwDynamic
CLEAR

loCust = CREATEOBJECT("TestClass")
loItem = CREATEOBJECT("wwDynamic",loCust)

loItem.Bogus = "This is bogus"
loItem.Entered = DATETIME()

? loItem.Bogus
? loItem.Entered


*loItem.oChild = CREATEOBJECT("wwDynamic")
*loChild = loItem.oChild

WITH loItem.oChild 
  .Bogus2 = "Child Bogus"
  .Entered2 = DATETIME()

   ? .Bogus2
   ? .Entered2
ENDWITH

? loItem.cFirstName
? loItem.cLastName
? loItem.GetFullname()


DEFINE CLASS TestClass as Custom


cFirstName = "Rick"
cLastName = "Strahl"

FUNCTION GetFullName()
RETURN this.cFirstname + " " + this.cLastname

ENDDEFINE
Doesn't look like there's a problem with `WITH loItem.oChild` in this scenario as that would still resolve to the reference.


Just for reference here's the implementation again:
SET PROCEDURE TO wwDynamic ADDITIVE

*************************************************************
DEFINE CLASS wwDynamic AS RELATION
*************************************************************
*: original Author: Marco Plaza, 2018 @vfp2nfox
*:     modified by: Rick Strahl
*************************************************************

__oReference = null

*** Intercept access to unknown properties and create
FUNCTION THIS_Access(lcPropertyOrMethod)

If Lower(lcPropertyOrMethod) ==  "__oreference"
	Return This
Endif

If !Pemstatus(this.__oReference,lcPropertyOrMethod,5)
   AddProperty(this.__oReference,lcPropertyOrMethod,Createobject('wwDynamic'))
ENDIF
	
RETURN this.__oReference
ENDFUNC



************************************************************************
*  Init
****************************************
***  Function:
***    Assume:
***      Pass:
***    Return:
************************************************************************
FUNCTION Init(loBaseType)

IF !VARTYPE(loBaseType) = "O"
   this.__oReference = CREATEOBJECT("Empty")
ELSE 
   this.__oReference = loBaseType
ENDIF   

ENDFUNC
*   Init

ENDDEFINE
*EOC wwDynamic 
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Reply
Map
View

Click here to load this message in the networking platform