Jim answered your question. You need to use typecasting. The compiler is expecting any subclass of TCPSocket. Your array could contain any number of different subclasses. So it can only return the most common class: the TCPSocket. You need to manually tell the compiler that variable x contains a reference to an object of your subclass.

dim sockets(),s as myTCPSocket.
dim i as integer
sockets = myServerSocket.ActiveConnections
for i = 0 to ubound(sockets)
  if sockets(i) isa myTCPSocket then
s = myTCPSocket(sockets(i)) // this is called typecasting, very important feature
    s.customProperty = true
  end
next

It's a good idea to check the class of the object before attempting to typecast it. That's why I added the if block. It's not mandatory, but a good practice to get into.

--
Thom McGrath, <http://www.thezaz.com/>
"You don't need eyes to see, you need vision" - Maxi Jazz in "Reverence" by Faithless


On May 3, 2006, at 10:27 PM, Jeff Edwards wrote:

Being a newbie to RB I am wondering how to use properties I have defined in a subclass of TCPSocket, when they are created from a ServerSocket.

It appears from the manual that the only way I can get information about the subclassed TCPSockets that the ServerSocket creates, is to get an array of the active connections (an array of TCPSockets). But these TCPSockets do not contain my user defined properties, even though if I look in the debugger they do. It's just that when I try to use or assign the user defined properties, I get a type mismatch error, or property does not exist error. Just to reiterate, the tcpsocket in the debugger IS my subclass of it and has the properties I defined.

How can I use my user defined properties?

I appreciate your help.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to