Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to store objects?
Message
 
 
To
20/02/1998 23:39:47
Roberto Cota Rivas
Quid Estrategia Esencial de México
Monterrey, Mexico
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00080035
Message ID:
00080266
Views:
23
>This way I think I get the best of both: Properties with meaningful names, and the ability to save/load my objects to a table! The only problem is that I need to test my save/load algorithms, since they would need to be SUPER fast...

The way I actually implement this is a bit more complicated than my previous post. It's like this. Given a set of object properties:
oMyObj.CustID
oMyObj.Phone
oMyOb.City
I do the following:
* Setup...
cPropSpecs="CustID,Phone,City"
cObjRef="oMyObj."
* To Store (see below): StoreData(cObjref,cPropSpecs)
* To Restore: ReStoreData(cObjref,cPropSpecs)

* To store (this is for illustration, not optimized)
Procedure StoreData(cRoot,cSpecs)
cTmpStr=ChrTran(cSpecs, ",", chr(13))
Dim aTmp(MemLine(cTmpStr))
For i=1 to MemLine(cTmpStr)
  Store Eval(cRoot + MLine(cTmpStr,i) ) to  aTmp(i)
EndFor
Save to Memo MyMemo All like aTmp

* To Restore
Procedure ReStoreData(cRoot,cSpecs)
Restore From Memo myMemo Additive   && restores aTmp
NumVars=Alen(aTmp)
For I=1 to NumVars
  cPropStr=cRoot + MLine(cSpecs,I)
  Store aTmp(J) to (cPropStr)
EndFor
Return
This approach guarantees that your object properties will be restored to what you stored them as (as long as you don't corrupt the order of property names in cPropSpecs).
Previous
Reply
Map
View

Click here to load this message in the networking platform