gettingstarted
[Top] [All Lists]

Re: Handling OutOfBoundsException

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: Handling OutOfBoundsException
From: Paul Young <youngpr at myactv dot net>
Date: Fri, 25 Feb 2005 10:45:33 -0500
Delivered-to: gettingstarted at lists dot realsoftware dot com
References: <611bf761c0e33bb715850f15b1942ed8 at myactv dot net> <a0620070dbe44efe3e9cd at [10 dot 10 dot 13 dot 4]>
This is the code in the button/Action:

  Dim i as integer
  Dim s as string
  Dim D as AddressBookData
  ListBox1.DeleteAllRows
  AddressBook
  For i=0 to N-1
    s=Contacts(i).FirstName + " " + Contacts(i).LastName
    ListBox1.AddRow s
    ListBox1.refresh

    s=Contacts(i).EmailAddresses
    ListBox1.Cell(ListBox1.LastIndex,1)=s
    ListBox1.refresh

    s=Contacts(i).PhoneNumbers
    ListBox1.Cell(ListBox1.LastIndex,2) = s
    ListBox1.refresh
  next
Exception err
  If err isA OutofBoundsException then
    MsgBox "No data available."
  End if

AddressBook (Method) has the following:
  book=System.AddressBook
  Contacts()=book.Contacts()
  N=Ubound(Contacts())

The debugger is showing the error in the line:
    s=Contacts(i).PhoneNumbers
because there is no data found. I do not see the MsgBox message. Is this because the code is in the button/action, not a method?

Paul


On Feb 25, 2005, at 10:09 AM, Joseph J. Strout wrote:

At 9:47 AM -0500 2/25/05, Paul Young wrote:

I'm writing a simple utility to fill a ListBox with data from an AddressBook: Name, email address and telephone number. Some contacts do not include the telephone number data and I get an "OutOfBoundsException" error even though I use the following code at the end of the Method:

Are you sure that this method is where the unhandled exception is being raised? When you run it under the debugger, where does it stop to show you the error? (And remember, the debugger WILL stop even when you have an exception handler; it's just that you should be able to continue, dropping down into the Exception or Catch block).

Best,
- Joe

--
REAL World 2005 - The REALbasic User Conference
March 23-25, 2005, Austin, Texas
<http://www.realsoftware.com/realworld>
_______________________________________________
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>


_______________________________________________
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>