realbasic-nug
[Top] [All Lists]

Re: NilObjection in console application

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: NilObjection in console application
From: Aaron Ballman <aaron at realsoftware dot com>
Date: Tue, 31 Aug 2004 09:39:18 -0500
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <20040831143645 dot 6030 dot qmail at web90003 dot mail dot scd dot yahoo dot com>

On Aug 31, 2004, at 9:36 AM, Hammuf Sabateh wrote:

Hey, I am getting a NilObjection on "This Line!!!",
it's being run as a console application...

web_ServerSocket_Class.AddSocket:
Function AddSocket() As TCPSocket
  dim i as integer
  for i=0 to ubound(my_web_S)
    if my_web_S(i).self_isdone then
      return my_web_S(i)
    end if
  next

  dim s as web_Socket_Class
  s = new web_Socket_Class
  my_web_S.append s
End Function

The problem is somewhere in here. The AddSocket event will fire a NilObjectException if you return a nil socket from it. The reason it shows up in the while loop is because time isn't given back to RB to fire the events until the DoEvents call happens. Once DoEvents is called, then the AddSocket event is called, and at some point, this returns nil (basically, you're forgetting to return s at the end of the function).

HTH!

~Aaron
--
Microsoft is not the Borg collective. The Borg collective has proper networking.

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

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

<Prev in Thread] Current Thread [Next in Thread>