Google
www ResExcellence

Application Makeovers
Desktop Snapshots
iTunes Skins
Mighty Mouse Cursors
Uploads
Boot Images
Dock Poofs
Links List
Photoshop Goodies
Users Forum
Boot Panels
Download Stats
Log-In Panels
REALbasic
Clocks
GUI Software
Mac OS X Mods
Safari Stuff
Desktop Pictures
Icons
Mac OS X Themes
Splash Screens
Homepage
Download a free demo of REALbasic!
Download a free demo of REALbasic!

Recent Articles...
3D
3D Photo Gallery (Part 2)
3D Photo Gallery (Part 1)

Audio
iPod Tricks (Part 3)
iPod Tricks (Part 2)
iPod Tricks (Part 1)
Laugh Track Machine
Audio Player with Reverb
Shepard Melody
RB Phone Home
Build a Drum Machine

Custom Controls
Custom Buttons
Custom Buttons Part II
iTunes-style Listboxes
Custom Controls

General RB
Wiggle Window
JPEG in PDF
Hey! You got your Checkbox in my Listbox!
Background Applications
Listbox Auto-Find
Virtual Volumes
Time Tracker
Software Distribution (Part 4)
Software Distribution (Part 3)
Software Distribution (Part 2)
Software Distribution (Part 1)
Exceptions
Living on the Edge
Tips and Tricks
Review of REALbasic 3.0
Text Clippings Made Easy

Graphics
Image Spinner
Cropping Graphics (Part 4)
Cropping Graphics (Part 3)
Cropping Graphics (Part 2)
Cropping Graphics (Part 1)
Shimmer Graphics
Lissajous Figures
Simple Screen Capture
Vector Graphics
Kaleidoscope Images
Stegonography
Spirals!
Image Table
RB Magnifying Lens
Screen Capture
Color Picker Tutorial

Hacks
Ghost Grab
Speedy Mouse Extension
iTunes Plugins
iTunes Skinner

Internet
Display Web Image In Canvas
HTML IMG Tags
Version Tracking
Even Smarter Instant Messaging
Web Tiler
JavaScript and REALbasic
Stock Ticker (Part 2)
Stock Ticker (Part I)
AIM Mate

Mac OS X
Using Sheets in REALbasic
Build a Bundle (Part 2)
Build a Bundle (Part 1)
Dock Your Passwords
Mac OS X Debugging
REALbasic Mac OS X Icon Tutorial
Animate Your Dock
RB and the Command Line

Novelty
Guessing Game
Calendar Trivia
Tile Mixer
Zip Code Finder
Happy Valentine's Day
Merlin Simulator (Part 3)
Merlin Simulator (Part 2)
Merlin Simulator (Part 1)
Buzzword Machine
AppleSoft BASIC

Printing
Print to PDF

Registration
Registration Code Validation

Resources
Picture Extractor (Part 2)
Picture Extractor (Part 1)

Serial
Caller ID (Part 3)
Caller ID (Part 2)
Caller ID (Part 1)

Speech
Speech Recognition

Video
Big Brother Video Capture

Newest Dev Tools!

Book Alert !
REALbasic for Dummies
by Erick Tejkowski
$19.99 @ Amazon

Made with REALbasic!

Book Alert !
REALbasic the Definitive Guide
by Matt Neuburg

Problems?
Downloads are in StuffIt 5 format (free download).
Tell me about a bad link (Thanks!).
Submission Policy

7-05-01

Build a Caller ID Application (Part 2) by Erick Tejkowsi

Last week we talked about the hardware requirements for completing a REALbasic Caller ID project. This week, we'll discuss the Caller ID specification, learn about the REALbasic Serial control, and begin building the project. By the end of this lesson, you should have the basic knowledge to begin working on a Caller ID application.

The Caller ID Specification

Before jumping into the code for this tutorial, it would be a good idea if we took a brief look at how Caller ID works. From here on out, I will refer to Caller ID as CID. On enabled telephone systems, CID information is sent to you sometime between the first and second ring of a phone call. The data comes to you as a string of characters. The idea of this project is to receive this string of data and pull out the desired information (the phone number and the caller's name).

The CID string of data begins with the text:

MESG =
(Note that there are spaces before and after the equals sign.)

The next character in the string denotes which type of CID data follows. There are two possible formats for CID data:

  • SDMF - Sends the phone number (only)
  • MDMF - Sends the phone number and other data (usually the name)

To simplify this tutorial, we will only discuss the MDMF format. SDMF works in much the same way as MDMF, but it is more simplistic, so adding this functionality later shouldn't be tough. When the data is in MDMF format, a Chr(128) follows the "MESG = " string discussed earlier. For SDMF, a Chr(4) follows instead.

The next character in the CID string represents the length of the remaining data. Following the length, is the date of the call and the name and phone number of the caller. The date, name, and phone number are each preceded by a data type and length of that data. The possible data types are:

  • 1 = date
  • 7 = name
  • 2 = phone number

For a technical description of the CID specification, see this link.

Okay, enough of these boring specs... Time to code this project!

Building the Project

The REALbasic Serial control (pictured below) permits you to send and receive data through the serial port of your Mac. This is how we will capture the CID data. To use the Serial control, simply drag it from the toolbar and set its properties in the Property window. For now, you can leave the default settings as is.

07-05_serial.jpg (18k)

In addition to the Serial control, add the remaining controls to the interface:

RB ControlName
PushButtonStartButton
PushButtonStopButton
StaticTextlabeltype
StaticTextlabellength
StaticTextlabeldate
StaticTextlabelname
StaticTextlabellabelphone
PopupMenuPopupMenu1

By now, your interface might look something like this:

07-05_interface.jpg (15k)

Next, open the Code Editor and place the following code in the Open event of PopupMenu1.

me.addrow "Modem"
me.addrow "Printer"
me.listindex=0

Proceed to the Action event of StartButton and add this code:

dim connected as boolean

Serial1.port = PopupMenu1.listindex
connected = Serial1.open

if connected then
  Serial1.write "AT#CID=2" + chr(13)
  StopButton.enabled=true
  me.enabled=false
else
  msgBox "There is a problem connecting to the current serial port."
end

This code starts off by assigning a port to the Serial control. Normally, this is either the modem or the printer port. Next, the code opens the serial port. If a connection is made, the code then sends a command to the Serial control. The command is:

AT#CID=2
and it tells the modem to make its Caller ID function active.

Once the Serial control has been started and the modem's CID functions are active, they sit and wait for a call to occur. When a call does come in, the modem will intercept the incoming CID data and send it to the Serial control. This causes the DataAvailable event to fire. To read in the data, use the ReadAll method of the Serial control:

dim incomingtext as string

incomingtext = me.readall
incomingtext = replaceall(incomingtext,chr(10),"")
ParseIncoming(incomingtext)

ParseIncoming is a method that looks through the data and tries to find the appropriate CID information. It performs many string manipulations based on the rules discussed earlier in the CID specification. Create the ParseIncoming method like so:

ParseIncoming(rawdata as string)
and add the following code:
dim i,msglength,messageposition as integer
dim msgtype,strippedmsg,temp as string
dim callername,callernum as string

messageposition=Instr(rawdata,"MESG = ")

if messageposition<>0 then

  //we have caller id info!
  msgtype=mid(rawdata,messageposition+7,1)

  //which type of caller id transmission?
  // for my test, it was the newer "MDMF" type
  if msgtype=chr(128) then//"Ÿ" = $80 = 128
    labeltype.text="MDMF"
  else
    labeltype.text="SDMF"
    return
  end if

  //how long is the message?
  msglength=asc(mid(rawdata,messageposition+8,1))
  //display length of the entire CID msg
  labellength.text=str(msglength)

  //now we know the length, so we can
  //retrieve the message from the string
  strippedmsg=mid(rawdata,messageposition+9,msglength)

  //parse the date information
  temp=left(strippedmsg,10)
  //display the date info
  labeldate.text=ParseMyDate(temp)

  //parse the name information
  temp=mid(strippedmsg,11)
  callername=ParseCallerName(temp)
  //display the caller's name
  labelname.text=callername

  //parse the phone number information
  temp=mid(strippedmsg,11+carryoverlength)
  callernum=ParseCallerNumber(temp)
  //display the phone number
  labelphone.text=callernum
  labelphone.refresh

end if

Note the following methods from the above code:

  • ParseMyDate
  • ParseCallerName
  • ParseCallerNumber
These methods each take a string and parse specific information from it. Rather than list the code for each of these methods for you here, you download the project and view them there.

Finally, to turn off the modem (and Caller ID feature), place this code in the Action event of StopButton:

serial1.write "AT#CID=0" + chr(13)
serial1.close

StartButton.enabled=true
me.enabled=false

What's Next?

That's it for this week. Again, you may download the completed code for this week's tutorial. Next week, we will look at what happens when a caller hides the CID information from you. We'll also take a look at some fun tricks that you can use to make your Caller ID application even more useful. See you then!


7-03-01

REALbasic News by Erick Tejkowsi

Video Capture Plugin. Essence Software has announced the availability of VideoPlug 1.2. In this version:

  • Carbon support for Mac OS X
  • Control over compression, brightness, contrast, and audio gain

Build a Web Browser. Alfred Van Hoek has released the latest Preview 2 version of his HTMLrenderer/URLaccess plugin. This version lets you download a file from the web and render it like a web browser.

Console your Games. Noah Desch has updated his Game Console code to version 1.2. GameConsole is a few classes that let you create a console in your game similar to the QuakeIII console. This version has over a dozen improvements, so don't miss it!

Parlez vous Francais? Alsyd, a leading French Internet and scientific tool republisher, has announced that it will localize and distribute REALbasic 3.5.

New HTML Editor. Nous_Enough has a new version of the Made-with-REALbasic HTML editor Attic PageImp.

Version 1.1 includes:

  • Increased stability
  • "Carbonized" to run natively on Mac OS 10.00 (X)
  • Fresh new interface and icons
  • Much improved stylesheet support
  • 3 different automatic editing modes for HTML, text and stylesheets
  • Better Tag Editor support
  • Recognises and installs some PageSpinner menu extensions, and ButtonMaker graphic plug-ins
  • And more!

Interface problems? Toby Rish has begun a site dedicated to creating great interfaces with REALbasic. If you'd like to offer interface suggestions, please visit his site.

RadioBox Replacement. George Clark has updated his RadioBox control.

New in this version:

  • Built-in support for ContextualMenus
  • Can now force a RadioBox to act with a MouseDown click rather than on MouseUp (useful for certain situations).



Application Makeovers
Desktop Snapshots
iTunes Skins
Mighty Mouse Cursors
Uploads
Boot Images
Dock Poofs
Links List
Photoshop Goodies
Users Forum
Boot Panels
Download Stats
Log-In Panels
REALbasic
Clocks
GUI Software
Mac OS X Mods
Safari Stuff
Desktop Pictures
Icons
Mac OS X Themes
Splash Screens
Homepage

Maintained by the Staff of ResExcellence. This entire site ©1997-2003 ResExcellence
Privacy Statement? Sure we gotta Privacy Statement.

[an error occurred while processing this directive] on the ResEx LinuxPPC Server