Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Question about Print is a method that writes a new row of text into a multiline

1 view
Skip to first unread message

JimK2

unread,
Nov 6, 2009, 7:42:40 PM11/6/09
to
//Print is a method that writes a new row of text into a multiline
//EditField
Print "Beginning syncrhonous connection..."


The example for TCPSocket has the above code which errors

What am I missing about Print and EditField and why does
the example below error at the "Print" statememt

Thanks


This example uses a TCPSocket to establish an internet connection.


Dim start, stop as Integer
Dim TCPSocket1 as TCPSocket

//create a TCPSocket
TCPSocket1 = New TCPSocket

//set its port and address
//EditField1 contains a valid url, such as "www.realsoftware.com"
TCPSocket1.Address = EditField1.Text
TCPSocket1.Port = 80

//Print is a method that writes a new row of text into a multiline
EditField
Print "Beginning syncrhonous connection..."

//connect the socket
TCPSocket1.Connect

start = Ticks
//while the socket isn't connected
While Not TCPSocket1.IsConnected

//check to see if the socket got an error
If TCPSocket1.LastErrorCode <> 0 then
Print "Socket Error: " + str(TCPSocket1.LastErrorCode)
Exit
End If
//poll the socket to let it do its thing
TCPSocket1.Poll
Wend
stop = Ticks

//if we broke the loop because we're connected
If TCPSocket1.IsConnected then
Print "Socket Connected in " + Str(stop - start) + " ticks"

//here would be a great place to do a synchronous read operation...
Else
//The socket broke out of the loop due to an error
Print "Socket failed to connect. It took " + Str(stop - start) + _
" ticks to figure that out"
End If

//close the socket
TCPSocket1.Close
Print "Socket closed"


Steve Garman

unread,
Nov 7, 2009, 2:44:23 AM11/7/09
to
JimK2 wrote:
> //Print is a method that writes a new row of text into a multiline
> //EditField
> Print "Beginning syncrhonous connection..."
>
>
> The example for TCPSocket has the above code which errors
>
> What am I missing about Print and EditField and why does
> the example below error at the "Print" statememt

The comment is trying (not very clearly) to explain that the example
code relies on the assumption that you have created a method "Print"
that writes the row of text.

It could be something as simple as:

Sub Print(strng As String)
If EditField1.Text <> "" Then
EditField1.AppendText EndOfLine
End If
EditField1.AppendText strng
End Sub

JimK2

unread,
Nov 7, 2009, 3:31:12 PM11/7/09
to
On Sat, 07 Nov 2009 07:44:23 +0000, Steve Garman <ne...@sgarman.net>
wrote:

Now it makes sense.
Thanks

0 new messages