image ResEx Logo
ResExcellence www : Powered by Google
Cell Phone Themes Icons Mighty Mouse Cursors Software Reviews Widgets & Widgets

Articles
   3D
   Audio
   Custom Controls
   General RB
   Graphics
   Hacks
   Mac OS X
   Menus
   Novelty
   Printing
   REALbasic 2005
   REALbasic 2006
   Registration
   Resources
   Reviews
   Serial
   Speech
   Sockets
   XML
   Video
Resource Links
News
   Current News
   February 2006
   January 2006
   December 2005
   November 2005
   October 2005
   September 2005
   August 2005
   July 2005
   June 2005
   May 2005
   April 2005
   March 2005









REALbasic for Dummies
by Erick Tejkowski


Learning REALbasic through Applications
by Clayton E., Crooks II


REALbasic for Macintosh
by Michael Swaine


REALbasic Cross-Platform Application Development
by Mark S. Choate





Older files are in Stuffit 5 or greater format. Newer files are ".Zip". Download StuffIt Expander
Tell us about a bad link. Thank You!

Build a Caller ID Application Part 3 by Erick Tejkowsi
07-12-01

Printer Version




This week we continue with the third (and final) installment of the ResExcellence Caller ID tutorial. In the past two weeks, we discussed how to:

  • Connect Caller ID hardware to your Macintosh.
  • Read the basics of the Caller ID specification.
  • Write a simple REALbasic project to parse the CID data.

This week, we will look at how "private" and "out-of-area" calls are handled by CID. We will also improve the project by adding new features such as speech notification and database storage.

The Caller ID Specification - Continued

In previous installments, we saw that CID data gets sent as a string of characters through the modem. We focused on CID data in the MDMF format, which has a sequence like this:

DATA: About:
MESG = Begins the CID data stream
$80 Denotes MDMF data
$xx Msg length
$01 Parameter - Time
$08 length of time data
2 bytes Month
2 bytes Day
2 bytes Hour
2 bytes Minute
$07 Parameter - Name
$xx Name length
xxxx The name data
$02 Parameter - Phone #
10 digits The phone #

In case you are wondering what all of those dollar signs are about, they tell you that the number is in hex format. It's never a bad idea to have a hex converter on hand when programming. In the above table $xx denotes a hex number that will be different for each call. xxxx represents a string of characters that will differ for each call.

The above table demonstrates how CID data arrives on my particular CID. Your data may differ. For example, you may find that order of the name and phone number data are switched. This is due to the fact that the spec does not necessarily specify an order for parameters. Since each segment of the message is preceded by a parameter type code number (i.e. date, name, or phone #), your software could accept the data in any order based on that parameter code number. We won't go into how to do that here. Just be aware that it is a real possibility depending on how the data is sent to your home. If you live in another country, none of this code may work at all. Check around on the web to see if you can discover what format is in use for your particular country.

Until now, we have always assumed that CID data (the name and phone number) would be sent to our application. But, sometimes this is not exactly the case. For example, if the caller presses *67 before calling you, the phone call will be classified as "Private" and the letter "P" will be sent in place of the caller's name and phone number. In other instances, the caller may live too far away for the data to make it all the way to your phone. When this happens, the call is designated "Out of Area" and the letter "O" is sent in place of the name and phone number.

Fortunately, Private and Out-of-Area calls don't change the CID data stream much. The following table lists the order of CID data when the name and phone number are missing. Differences from the previous table appear in italics.

DATA: About:
MESG = Begins the CID data stream
$80 Denotes MDMF data
$xx Msg length
$01 Parameter - Time
$08 length of time data
2 bytes Month
2 bytes Day
2 bytes Hour
2 bytes Minute
$08 Parameter - Name
$01 Name length
P The name data ("P" or "O")
$04 Parameter - Phone #
$01 Phone # length
P The phone # ("P" or "O")

To help you visualize this better, a screenshot of CID data from a *67 phone call:

07-12_privatecall.jpg (22k)

The Code

If all of these specifications are making you crazy, you'll be happy to know that you won't need to change any code from last week to implement the Private and Out-of-Area phone calls. Still, it is good for you to know how the Caller ID data stream is organized, should you want to modify the code yourself later.

Instead of adding boring CID parsing code, we will focus on improvements to the Caller ID project. When you receive a call and parse the incoming data, you are free to do anything you want with it. Once you see a few of these ideas, you will begin to understand why a Mac-based Caller ID is much more svelte than a traditional CID box.

For starters, speech is a handy function that is easy to add to your Caller ID project. Imagine having your application speak the caller's number, or better yet, an interesting phrase, depending on who the caller is. I'm sure you can come up with many fun ideas for this feature.

To add speech, open the CallerID window and create a new Method. Name the method SpeakText, and enter thetext as string in the Parameters field. In this new method, add the following code:

dim i as integer

Declare Function SpeakString lib "SpeechLib" (SpeakString as pstring) as Integer
i=SpeakString(thetext)

As you might imagine, this code will speak any text you pass to it. To incorporate it into your Caller ID, add the following code to end of the ParseIncoming method:

SpeakText(labelphone.text)

Another benefit of using your computer is the fact that you can store your Caller ID history for days, weeks, months, and years at a time. Most hardware CID boxes permit storage of no more than a few dozen names. I have added a low-tech database to the Caller ID project, which can you download at the end of this tutorial. In the example, any new calls are added to a Listbox. That data can then be saved to a text file. Of course, you could choose a more high-tech approach. You might consider storing your CID info in a database. With REALbasic, there are many choices.

  • REAL Database
  • FileMaker database
  • AppleWorks
There are many other databases you could use, but these are some of the most likely choices for home users.

Hopefully some of these ideas have sparked your imagination. There are many interesting uses for this project. For instance, it would not be difficult to add the ability to:

  • Display a photo of your friends when they call
  • Play a particular sound when your mother-in-law calls
  • Email you a notice whenever someone calls
  • Predict what time of day telemarketers call
As you can see, the possibilities are limitless. And you thougt that old Mac was useless?

Download

As usual, you can

Next week, I will be writing to you from the MacWorld Expo in New York. I will be signing books at the REALSoftware booth, so stop by and say "Hi" if you are in the neighborhood. See you then!




Cell Phone Themes Icons Mighty Mouse Cursors Software Reviews Widgets & Widgets

Maintained by the Staff of ResExcellence. This entire site ©1997-2006 ResExcellence
Privacy Statement? Sure we gotta Privacy Statement. [an error occurred while processing this directive]