Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Discussion -Name Expression, Evaluate, Macro Substitution
Message
De
19/02/2007 11:03:26
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
Discussion -Name Expression, Evaluate, Macro Substitution
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01197046
Message ID:
01197046
Vues:
67
Maybe I am just slow this Monday morning. If I want to create an object reference on the fly and set the values of its properties (Object will be public not local):

For example:

* Table with values to use for object's properties
* Mytable.cname && cName will become part of object's name
* Mytable.ctype && cType will become part of object's name
* Mytable.cserver && cServer will be the object's pServerName value
* Scan through the table 'mytable' and create an object from each record
lcConn = "'o'+mytable.cname+'_'+mytable.ctype       && e.g. lcConn now equals 'oDSN_Data'
PUBLIC &lcConn
&lcConn = CREATEOBJECT('ConnClass.ConnObj')         && Create an object named (lcConn)
lcConnServer = lcConn + '.pServerName'              && Set the connection object servername prop
&lcConnServer = TRIM(mytable.cserver)               && Slowest oDSN_Data.pServerName now = mytable.cserver value

or

&lcConnServer..pServerName = TRIM(mytable.cserver)  && oDSN_Data.pServerName now = mytable.cserver value

or

loControl = EVAL(lcConn)                            && Should be 2nd fastest to process
loControl.pServerName = TRIM(mytable.cserver)       && oDSN_Data.pServerName now = mytable.cserver value

or

STORE TRIM(mytable.cserver) TO (lcConn+'.pcServer') && Should be fastest

Or is there a better way?
Which will be fastest if I have to create 10 similar objects with 10 properties each sequentially? Which will be easiest to maintain (by other developers)?
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform