![]() 3D 3D Photo Gallery (Part 1) 3D Photo Gallery (Part 2) Audio Poor Man's MIDI Make A Metronome iPod Tricks (Part 1) iPod Tricks (Part 2) iPod Tricks (Part 3) Laugh Track Machine Audio Player with Reverb Shepard Melody RB Phone Home Build a Drum Machine Custom Controls and Windows Double Click Listbox Draggable Metal Window Double Click Canvas Custom Buttons Custom Buttons Part II iTunes-style Listboxes Custom Controls General RB Scrolling Windows Using Mesage Dialogs Case-Sensitive Word Finder Introduction to Stacks Wiggle Window JPEG in PDF Listbox Checkboxes Background Applications Listbox Auto-Find Virtual Volumes Time Tracker Software Distribution (Part 1) Software Distribution (Part 2) Software Distribution (Part 3) Software Distribution (Part 4) Exceptions Tips and Tricks Text Clippings Made Easy Graphics Drawing a Simple Gradient The SpriteSurface: Space Game Image Spinner Cropping Graphics (Part 1) Cropping Graphics (Part 2) Cropping Graphics (Part 3) Cropping Graphics (Part 4) 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 Mac OS X Global Hot Key Event (Carbon Events) Login Welcomer (Carbon Events) Add/Remove Buttons Resizable Sheets Mac OS X Preferences Window Using Sheets in REALbasic Build a Bundle (Part 1) Build a Bundle (Part 2) Dock Your Passwords Mac OS X Debugging REALbasic Mac OS X Icon Tutorial Animate Your Dock RB and the Command Line Menus Window Menu Templates Menu Listbox Menu Novelty Guessing Game Calendar Trivia Tile Mixer Zip Code Finder Happy Valentine's Day Merlin Simulator (Part 1) Merlin Simulator (Part 2) Merlin Simulator (Part 3) Buzzword Machine AppleSoft BASIC Printing Print to PDF Registration Registration Code Validation Network Registration Codes Resources Picture Extractor (Part 1) Picture Extractor (Part 2) Serial Caller ID (Part 1) Caller ID (Part 2) Caller ID (Part 3) Speech Speech Recognition Socket Communication Easy Peer-to-Peer File Sharing MacPAD Version Checking Display Web Image In Canvas HTML IMG Tags Version Tracking Even Smarter Instant Messaging Web Tiler JavaScript and REALbasic Stock Ticker (Part I) Stock Ticker (Part 2) AIM Mate XML Manipulation Simple XML Introduction Video Big Brother Video Capture Note: All articles without a byline were written by Erick Tejkowski. When cleaning the site I removed them because the code differed from page to page, and I have yet to put them back in.
Tell us about a bad link. |
Debugging in Mac OS X with REALbasic by Erick Tejkowsi This week we'll take a look at a quick and easy hack to help you debug Mac OS X projects that you create with REALbasic. Not a lot of glitz this time, but it is an essential step in your quest for REALbasic "Excellence". (Good tie-in, eh?) Merlin lovers will have to wait another week for the finished project. (I'm still working on it). Build the Interface Interface? We don't need no stinkin' interface! Ok, maybe we need a small one. Launch REALbasic, open Window1 and add a PushButton and an EditField control to the window. You're done! Add the Code Choose File-New Module. A new module appears in your Project window. A module is global in nature, which is just a fancy way to say that all parts of your REALbasic project can use the calls within it. Once we finish this module, you can drag it from your project and use it in other projects too. Open the new module and add a method to it (Edit-New Method). Name the Method something you'll remember. This debugging method is going to send data to the Console application, so name it SendToConsole and add msg as string in the parameters field of the Method definition. Press OK. To this new method add the following code: dim i as integer#if TargetCarbon then Declare Sub DebugStr Lib "CarbonLib" (msg as Pstring) as Integer i = DebugStr(msg) #endif This code gives you access to the Mac API call: "DebugStr". Any text that you give to DebugStr will show up in the Console application. What? You haven't played with the Console yet? Now's the time! It's located here: /Applications/Utilities/Console.app. The Console application is just a GUI front end for the "old-timey" console, where Unix geeks and programmers like to send text for viewing. For RB programmers, it's like adding your own window and editfield without doing a thing. As you test your program, you can follow along with its progression, by littering your code with statements like: // place this in the PushButton's Action event from earlierSendToConsole EditField1.text //put this in an Open event somewhere SendToConsole("Open event occurred") //etc... SendToConsole("Sprite now moving") SendToConsole("Sprite has stopped") SendToConsole("Crash doesn't happen here") SendToConsole("Crash happens here") As you program executes, these various text messages will appear in the Console application. It's low-tech, but it gives you another way to debug your applications. If you want to be really slick and do it like "the pros" do it, add a new Boolean constant to the module by selecting Edit-New Constant. ![]() Then, change the code from earlier to read like this: dim i as integer This way you can sprinkle debugging code all over the place and turn it off by redefining the constant as FALSE. This is fun in OS X, but what about Classic? The DebugStr call works with the Classic Mac OS too, but instead of sending your text to the console (which doesn't exist in OS 9), the string gets sent to the debugger (i.e. Macsbug). Since Macsbug is another topic altogether we'll forego the discussion this time. If I hear of enough interest, I'll gladly talk about it in a future tutorial. It's not terribly scary to use, but it is quite a bit different than the console. Conclusion No glitz this week, but you will have lots of glory if it helps you track down a nasty bug. You can download this week's project and example application, in case you don't want to create the project by hand. Have fun and see you next week when we'll hopefully wrap up our Merlin project. |
|||||
|
Please support ResExcellence by Visiting our Sponsors. One click makes a difference. |
||||||
|
|