Ok, I apologize Naomi. I should have seen that in help! It works. Thanks so much! :o)
>Check GetKey method of the collection in Help.
>
>>Ok, I now have my collection of connection objects. Each connection object has properties which are used for the connection. Each also has a method which is used to create the connection, one to close the connection, etc. I am adding property to each which stores the current connection number. What is the quickest way to determine if a connection object of a specific name exists? For example, let's say I have the below connection objects:
>>
>>_Screen.myConnections('oProd1_Qcc')
>>_Screen.myConnections('oProd2_Hbb')
>>
>>oProd1_Qcc is a valid connection object (outside of the collection as well)
>>oProd2_Hbb is a valid connection object (outside of the collection as well)
>>
>>e.g. oProd2_Hbb.name returns 'oProd2_Hbb'
>>
>>How do I easily determine if a specific connection object such as 'oProd2_Hbb' exists? Checking TYPE and PEMSTATUS doesn't seem to work...
>>
>>
>>?[*** Does the oProd2_Hbb connection object exist? ]
>>lcSqlConfgConn = 'oProd2_Hbb'
>>? PEMSTATUS(_Screen,'myConnections',5)
>>? TYPE(lcSqlConfgConn) ="O" .and. !ISNULL(lcSqlConfgConn)
>>? TYPE("_Screen.myconnections('oProd2_Hbb').name")
>>? _Screen.myconnections('oProd2_Hbb').name
>>
>>* Yet the below all work:
>>
>>FOR EACH oControl IN _Screen.myConnections FOXOBJECT
>> ? oControl.name
>> ? oControl.pcServer
>> ? oControl.pcDatabase
>> ? oControl.pcPassword
>> ? oControl.pcUser
>> ? oControl.pnEngine
>>ENDFOR
>>
>>
>>>>
>>>>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)>>>>
>>>
>>>I wouldn't make it the variable name that's based on the fields. Instead, put all of the objects into a collection and use the field information as the key into the collection:
>>>
>>>oDataObjects = CREATEOBECT("Collection")
>>>
>>>oObject = CREATEOBJECT("Whatever")
>>>* Populate oObject
>>>
>>>cKey = ALLTRIM(Field1) + "_" + ALLTRIM(Field2)
>>>oDataObjects.Add(m.oObject, m.cKey)
>>>
>>>Now to find a particular object, use:
>>>
>>>oDataObjects(< the key expression >)
>>>
>>>If you need them in a particular order, add that information to the object.
>>>
>>>Tamar
.·*´¨)
.·`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"