gettingstarted
[Top] [All Lists]

Re: wrap and array

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: wrap and array
From: Phil M <phil at mobleybros dot com>
Date: Tue, 24 May 2005 11:05:20 +0200
Delivered-to: gettingstarted at lists dot realsoftware dot com
References: <1a5 dot 37f7c8f5 dot 2fc41675 at aol dot com>
On May 24, 2005, at 7:32 AM, GAmoore at aol dot com wrote:

Sub Append(theEmployee as EmployeeClass)
   //you can append a nil EmployeeClass object, but do you want to?
   me.pList.Append theEmployee
End Sub


Does your comment mean that you should have something like this:
if  theEmployee <>   nil then me.pList.Append theEmployee

Yes, but I would extend the function even further to not allow duplicate copies of the same employee.

Sub Append(theEmployee as EmployeeClass)
  If theEmployee Is Nil Then Return
  Dim k As Integer
  For k = 0 To UBound(pList)
    If theEmployee Is pList(k) Then Return
  Next
  // If you get this far, add it to the list
  pList.Append(theEmployee)
End Sub

The "Is" keyword means "is exactly" which will look at the Object reference to see if the variables point to exactly the same object. This will catch something like this:

   employee01 = employee04

But it will not catch theEmployee instantances which have the same values for the properties such as two objects both named Fred Flitstone.
_______________________________________________
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>

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