realbasic-nug
[Top] [All Lists]

Re: AddressBook

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: AddressBook
From: Stefan Pantke <seaside dot ki at mac dot com>
Date: Tue, 1 Mar 2005 04:42:45 +0100
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <20050228210133 dot DCDB7769625 at lists dot realsoftware dot com> <b1bb14210eba2a3e4e9f1e7989481456 at elfdata dot com> <e1b332b5736c36a1c15a2c804bcf5413 at elfdata dot com> <42238F0E dot 1020409 at rovosoft dot com> <a06200722be49451502a6 at [10 dot 10 dot 13 dot 4]> <422398A5 dot 6060206 at rovosoft dot com> <b4f8aa50e52e3b004a492685198f1e96 at wabbitwanch dot net>
This isn't strictly related to your sample code, but the current
or the one but last release had an error regarding the Me record.

If it wasn't set in AB, the app silently died, due to an access to a NIL
pointer coded in the RB library.


Am 1. Mrz 2005 um 01:18 schrieb Mel Patrick:

I'm trying to read Apple AddressBook stuff and while it works on my system, on one of my users, I get a NilObject. I don't want to write, just read.

Since I've never actually used Apples AddressBook myself I'm at somewhat of a disadvantage. The code is pieced together from what I read about and guessed at to make work on my own OS X system.

It's also kind of confusing as to which fields in the addressbook's have counts attached to them and which ones don't.

addressData() is a bunch of text fields in the current window, I am filling them with data from the address book.

Suggestions welcome.

  Dim i, j, k, m as Integer
  Dim book as AddressBook
  Dim address As AddressBookAddress
  Dim data As AddressBookData
  Dim Contacts() as AddressBookContact
  '
  book=System.AddressBook
  Contacts=book.Contacts
  '
  For i =0 to Ubound(Contacts)' loop through the whole address book
    addressData(0).Text=Contacts(i).FirstName
    addressData(1).Text=Contacts(i).LastName
    addressData(2).Text=Contacts(i).CompanyName
    '
    data=Contacts(i).Addresses
    address=data.Value(0)'
    addressData(3).Text=address.StreetAddress
    addressData(4).Text=address.City
    addressData(5).Text=address.State
    addressData(6).Text=address.Zip
    addressData(7).Text=address.Country
    '
    j=Contacts(i).PhoneNumbers.Count
    If j>3 Then' I only want the first two
      j=3
    End If
    If j>0 Then
      For k=0 to j-1
        addressData(8+k).Text=Contacts(i).PhoneNumbers.Value(k)
      Next
    End If
    '
    j=Contacts(i).EmailAddresses.Count
    If j>2 Then
      j=2
    End If
    For k=0 to j-1
      addressData(12+k).Text=Contacts(i).EmailAddresses.Value(k)
    Next
    '
    addressData(14).Text=Contacts(i).Homepage
    addressData(15).Text=Contacts(i).Note

  Next
  '

Mel

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


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