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 (12-06-01)
3D Photo Gallery Part 1 (11-29-01)

Audio
iPod Tricks (Part 3)
iPod Tricks (Part 2)
iPod Tricks (Part 1)
Laugh Track Machine
Audio Player with Reverb
Shepard Melody(11-08-01)
RB Phone Home (10-25-01)
Build a Drum Machine (10-04-01)

General RB
JPEG in PDF
Hey! You got your Checkbox in my Listbox!
Background Applications (5-02-03)
Listbox Auto-Find
iTunes-style Listboxes
Virtual Volumes
Time Tracker
Software Distribution Part 4
Software Distribution Part 3
Software Distribution Part 2
Software Distribution Part 1
Exceptions
Custom Controls (8-2-01)
Living on the Edge (6-21-01)
Tips and Tricks (6-14-01)
Review of REALbasic 3.0 (2-19-01)
Text Clippings Made Easy (5-10-01)

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 (11-15-01)
RB Magnifying Lens (10-11-01)
Screen Capture (8-9-01)
Color Picker Tutorial (6-7-01)

Hacks
Ghost Grab
Speedy Mouse Extension(11-01-01)
iTunes Plugins (8-23-01)
iTunes Skinner (7-26-01)

Internet
HTML IMG Tags
Version Tracking
Even Smarter Instant Messaging
Web Tiler
JavaScript and REALbasic (10-02-01)
Stock Ticker - Part II (9-06-01)
Stock Ticker - Part I (8-30-01)
AIM Mate (8-16-01)

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 (12-13-01)
Animate Your Dock (5-17-01)
RB and the Command Line (5-3-01)

Novelty
Guessing Game
Calendar Trivia
Tile Mixer
Zip Code Finder
Happy Valentine's Day
Merlin Simulator Part 3 (01-24-02)
Merlin Simulator Part 2 (01-17-02)
Merlin Simulator Part 1 (01-10-02)
Buzzword Machine (10-18-01)
AppleSoft BASIC (9-20-01)

Printing
Print to PDF

Resources
Picture Extractor 2 (5-31-01)
Picture Extractor 1 (5-24-01)

Serial
Caller ID Part 3 (7-12-01)
Caller ID Part 2 (7-5-01)
Caller ID Part 1 (6-28-01)

Speech
Speech Recognition (9-13-01)
Video
Big Brother Video Capture

Newest Dev Tools!

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

Made with REALbasic!

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

3-28-02

Errors and Exceptions by Erick Tejkowski

Today's tutorial doesn't contain any flashing lights, it won't make your Mac run faster, nor will it make you rich and famous. But, it will make your software work better and reduce crashes. We will discuss how to make use of REALbasic's exception handlers to improve the overall integrity of your code. Your users will thank you!

Introduction

Computers are marvelous tools. They can do all sorts of complicated computations very rapidly, giving you the ability to perform many kinds of tasks with different kinds of media: audio, video, graphics, text processing, databases, video games, 3D, and the list goes on. The problem with all this power is that its controlled by humans and as well all know, humans make mistakes. The speediest and sleekest of machines can come crashing down with just one bad line of code.

Errors

Source code errors come in a variety of forms. Some errors are grammatical in nature and cause your program to not run at all. These are called syntax errors and are caught by REALbasic whenever you attempt to Debug->Run your project.

Some errors result in incorrect functionality. The program runs and may even work well, but the error has caused something to not work quite right. They make your program misbehave, but they don't have any serious side effects (e.g. crashing). Why is the square blue instead of green? Why has the final character in my filename been removed? How come I only see 50 invitations, there should be 100! These are examples of this type of error.

Other more sinister errors are not so forgiving. They can jump out at you unexpectedly and force your application to come to a screeching halt. If you are still programming for the Classic Mac OS, these types of errors can even cause your entire machine to become so unstable as to require a reboot. These errors are to be avoided at all costs! The name of this type of error is exception. When your code encounters one of these errors, the computer is said have "thrown an exception". If you see this jargon, it just means that an error has occurred.

Here's a quick rundown of the various exceptions REALbasic might "throw" your way.

  • StackOverflowException
  • IllegalCastException
  • OutOfBoundsException
  • TypeMismatchException
  • NilObjectException

What to do?

So, what's a REALbasic user to do about these exceptions when they occur? Follow these three steps to make your code less prone to crashes:

1. Add error checking! - The best medicine in bug elimination is not to produce any bugs in the first place. For example, if you are going to use an object, make sure it exists before you try to use it:

	dim f as folderitem
f=SelectFolder
if f<>nil then
MsgBox "We have a folderitem"
else
MsgBox "We don't have a folderitem"
end if

In this example, if we hadn't checked for a nil folderitem, this code would cause an exception when the user clicks the "Cancel" button during the "select a folder" process.

2. Trap your Exceptions! - Catch those errors when they do occur. If you don't your computer doesn't know what to do with them and that's when things turn nasty. Open the Code Editor to a method or event and scroll down to the very bottom of that method's code. Add the following code:

  //ERROR HANDLING 
Exception err As StackOverflowException
LogError "StackOverflowException "

Exception err As IllegalCastException
LogError "IllegalCastException"

Exception err As OutOfBoundsException
LogError "OutOfBoundsException"

Exception err As TypeMismatchException
LogError "TypeMismatchException"

Exception err As NilObjectException
LogError "NilObjectException"

As your code encounters exceptions, it will jump down to this code segment and perform whatever code is assigned to this exception. In this case we are sending a string to a "LogError" function. You could choose to do something else. For example, in the SelectFolder code from earlier, you might catch the nil folderitem in the NilObjectException handler and force the user to select another folder. It's up to you how you want to handle the error, but at least REALbasic gives you a way to do so. Another beneficial side effect of error exceptions is that they are helpful during testing. For example, you might log each of these errors to a text file so you can witness where everything went wrong. This is also handy for beta testers to send you feedback, which leads to our next step.

3. Test, test, and test some more! Again, prevention is key when it comes to bugs. When your program starts to take on any complexity at all, the chances of missing a bug in your code grow exponentially. No one is perfect and bugs do slip through. To avoid the potential bad press, hurt feelings, and crashing computers, make sure to test your code over and over. The best way is to get a few friends to help out. Let them run it on their machine without help from you. This way you can get some real feedback about how someone uses your application. It never fails, you test your application dozens of times and think it works flawlessly, then you give it to your friend who can break it in seconds. Users can and will do things that you don't expect. They will also try to use your software on machines you hadn't considered. The best tool for this kind of debugging is testing.

Conclusion

Well, that's it for today. No flashy project, no gimmicky fun, just boring old error talk. But, if you've been paying attention, your code will work better, break less, and make your users happy. See you next week!


3-26-02

REALbasic News by Erick Tejkowski

Cubie's Contest! REAL Software holds an annual REALbasic contest, called the "Cubies". The contest to recognize the contributions REALbasic users have made to the industry by recognizing the excellence of what they have produced with REALbasic. The contest opens now, and closes April 26, 2002. REAL Software will announce the finalists the following week and the winners in each category during Apple's World Wide Developers Conference.

The contest has the following categories:

  • Advocate of the Year
  • Cross-Platform
  • Developer Tool
  • Game
  • Internet
  • Mac OS X
  • Utility
  • Overall
  • Business

REAL Software will accept nominations from anyone, but no REAL Software employee or member of their family will be eligible. The only other requirement is that the products be Premier partners in the Made with REALbasic program. Winners will receive TWO free upgrades to REALbasic, support in publishing the product (if desired), free publicity, the admiration and envy of their peers, and other prizes to be announced.

The entries will be judged on quality, fitness to the task (fun game? useful utility?), polish, verve, and brio. The categories are as follows:

Mac OS X: The best application for Mac OS X. It need not fall into any particular category, and can also support the classic Mac OS (and heck, Windows too).

Business: The best tool for conducting some sort of commercial activity, whether it is a traditional business application or a tool for creating stuff that makes money for the user.

Game: The best game. We will know it when we see it, can be pure entertainment, action, strategy, educational, you name it, it's all good.

Internet: Best tool for the Internet. This could be anything useful in that rather large arena, from a server tool, to a decoder, player, testing tool. If it uses IP (or its cousins) or some known protocol or format, it's in!

Cross-platform: The best example of an application that embraces both the Mac OS and Windows.

Utility: The best application that does something useful. This too is intentionally broad! All it has to do is crank out the utilities, and we will be all over it.

REALbasic development aid: This includes plug-ins, classes, modules, frameworks, pre- and post-processors, anything that helps some REALbasic developer get the job done.

Overall: The very best REALbasic application we receive. It can be a double winner, or it can be one of those None of the Above fliers that just blows us away.

Advocate of the Year: Finally, there's a special category for the REALbasic advocate of the year, that person who has done the most for the community, and helped make REALbasic known everywhere as the truly great tool that it is.

These are all open for nominations from the community. To nominate someone, or some product, send email to nominations@realsoftware.com. Don't be shy, either! Nominate yourself! It's not a vote, though, so no need to stuff the ballot box!

Check out last year's winners here.

REAL Software's Many Releases The folks at REAL Software have been hard at work in their new office space to bring you many fine new downloads:

REALbasic Developer Magazine - Subscribe Online Now! REALbasic Developer, the exciting new print magazine devoted to REALbasic programming launching this summer, is now accepting subscriptions! Best of all, if you're one of the first 500 subscribers before April 15, 2002, you will qualify as a Charter Member and receive your subscription at half off the standard price! You may subscribe online via secure server, or by mail via check or money order.

Control Focus plugin The Smith has posted a new plugin: Control Focus plugin v1. This plugin gives all Controls, the property "HasFocus as boolean", which does exactly that.


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