Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Discussion -Name Expression, Evaluate, Macro Substitutio
Message
De
19/02/2007 12:07:35
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
19/02/2007 12:06:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
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:
01197071
Vues:
19
Yes it might. I used 'Line' object as a sample which have methods already.
Cetin

>I'll look at it. Each object will have methods that will be called as well.
>
>
>
>>Tracy,
>>Then you could simply create the object with store followed by assignment.
>>You'd have multiple objects and it might be OK for you. I'd however use a single collection. ie:
>>
>>
>>CREATE CURSOR myServers (cServer c(10), type c(3), name c(10))
>>INSERT INTO myServers VALUES (SYS(2015), 'DSN', 'Data' )
>>INSERT INTO myServers VALUES (SYS(2015), 'DSN', 'Form' )
>>INSERT INTO myServers VALUES (SYS(2015), 'DSN', 'Menu' )
>>INSERT INTO myServers VALUES (SYS(2015), 'FTP', 'Data' )
>>INSERT INTO myServers VALUES (SYS(2015), 'FTP', 'Form' )
>>INSERT INTO myServers VALUES (SYS(2015), 'FTP', 'Menu' )
>>
>>loApp = CREATEOBJECT('Custom')
>>
>>loApp.AddProperty( 'myServers', NEWOBJECT('Collection') )
>>
>>SCAN
>>  lcKey = TRIM(type)+'_'+TRIM(name)
>>  loApp.myServers.Add( CREATEOBJECT('Line'), m.lcKey)
>>  loApp.myServers.Item( m.lcKey ).Name = cServer
>>ENDSCAN
>>
>>BROWSE nowait
>>? loApp.myServers[ 'DSN_Form' ].Name
>>? loApp.myServers[ 'FTP_Form' ].Name
>>
>>You have around 10 objects where speed wouldn't be a concern (whatever way you create and populate I mean). It's more important to keep them at a known place and access easily with a key. Collection looked ideal to me in your case.
>>Cetin
>>
>>
>>>Hi Cetin,
>>>
>>>There will be 1-10 objects (1 object created from each record). The name of the object will be determined by the values in 2 of the table's fields:
>>>
>>>1st Record Example:
>>>mytable.field1 = 'DATA'
>>>mytable.field2 = 'QCC'
>>>
>>>The created object's name will be oDATA_QCC for the first record.
>>>
>>>The servername property of oDATA_QCC will be 'myservername' e.g. :
>>>
>>>IF mytable.field3 = 'myservername':
>>>
>>>oDATA_QCC.servername = TRIM(mytable.field3)
>>>
>>>So the object can be referenced later based on the two fields in the table (in order to know which object to use)
>>>
>>>
>>>>>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)?
>>>>
>>>>Tracy,
>>>>I'm not sure I follow it right, anyway:
>>>>
>>>>
>>>>select cServer as pServername from myTable into cursor myServers nofilter
>>>>oApp.AddProperty( "loConn["+ltrim(str(reccount()))+"]" )
>>>>scan
>>>> oApp.loConn[ recno() ] = CREATEOBJECT('ConnClass.ConnObj') && Create an object
>>>> oApp.loConn[ recno() ].pservername = trim(pServername)
>>>>endscan
>>>>
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform