Dar Scott dsc at
Wed Jul 10 15:50:01 EDT 2002

On Wednesday, July 10, 2002, at 01:41 PM, Larry Forsgren wrote:

> Correct, server contains "mailsever:110".
> I logged the results to a field but it came up empty.
> The sysError is 0 which I don´t know what it means.
> The actual code as it looks currently is below.
> It does not matter if I change to a different mail server.
> on revPOP_connect
>   # Description..: connects to the mail account
>   # Parameter...: "server, user, losen"
>   set socketTimeoutInterval to 1000
>   put item 1 of param(1) & ":110" into server
>   put item 2 of param(1) into user
>   put item 3 of param(1) into losen
>   open socket server
>   read from socket server until linefeed
>   if offset("+OK",it) is zero then
>      answer the sysError
>      close socket server
>      answer "No connection!"
>    else
>      put "Connected to" && server & return into field id 1004
>      write "USER" && user to socket server
>      read from socket server until linefeed
>      put return & it after field id 1004
>   end if
> end revPOP_connect

The sysError is meaningful in some cases (all sockets) if result is 
not empty.  For this case it will be a Winsock error code.

You may need to step back and do a little more on diagnostics.

Add a multiline field named "log", maybe with a scrollbar.  (I 
would also make a test button on a different card that does the 
bare i/o, but you can do this in your code if you want.)

Add this:

on clearLog
	put empty into field "log"
	-- clear base for long seconds if you add that later
end clearLog

on logIt loggedEvent
	-- add putting long seconds delta into log if you want
	-- add other info if you want
	put loggedEvent & linefeed after field "log"
     -- add openSockets if you want
     -- add something to force scrolling if you want
end logIt

on logResult loggedEvent, resultVal, sysErrVal
	logIt loggedEvent & "  " \
		& "result = " & quote & resultVal & quote & "  " \
		& "sysErro = " & sysErrVal
end logIt

on socketError socketID, errorString
	logIt "socketError " & socketID & "  error = " & quote & 
errorString & quote
end socketError

on socketClosed socketID
	logIt "socketClosed " & socketID
end socketClosed

on socketTimeOut socketID
	logIt "socketTimeOut " & socketID
end socketTimOut

Those are off the top of my head and may have errors.  Put them in 
the path where they will be found for callbacks.  The stack should 

Call clearLog at the top of your handler.  You can call it from a 
button instead; if you do you still might want to set the timer 
offset at the top of your handler.

Call the logResult after EVERY socket command with the appropriate 
parameters, like this:
logResult "open", the result, the sysError

Use logIt to log the results of read, what you write and so on.  If 
you add the timer, use it whenever you need to log the timer value.

Send results to the list.

Dar Scott

More information about the Use-livecode mailing list