REALbasic University Resources:

RBU: Glossary Defines common REALbasic programming terms
  Archives Previously published columns
Translations: Dutch Courtesy of Floris van Sandwijk
  Japanese Courtesy of Kazuo Ishizuka
  Chinese Courtesy of Dong Li
  RBU Translation Guide Information on Translating RBU into other languages
Books: Matt's Book (2nd Edition!) Ideal for experienced programmers
  Erick's Book Best for beginning programmers
Websites: Mother Ship The publisher of REALbasic
  RB Webring Links to hundreds of REALbasic websites
  RESExcellence Another REALbasic programming column
  REALbasic Developer Magazine The premiere source for REALbasic instruction.

REALbasic University is Sponsored by

Make your Mac do what YOU want it to. Create games, utilities, cool Mac OS X tricks. Download REALbasic now and create your own software.


Print This Article

REALbasic University: Column 067

Review: REALbasic 4.5 (Part 1)

Surely by now you've heard the news: at Macworld Expo in July, REAL Software released a new version of REALbasic, version 4.5.

For a while now, REALbasic's been on a six month upgrade cycle (new versions at every Macworld), which may seem too frequent if you're not an active REALbasic user, but is great if you're a fan of the product. Every release adds significant new features, fixes problems, and improves the user experience.

This new release is no exception: 4.5 revises a number of existing features (such as modifications to better support Mac OS X), fixes a number of existing bugs, and adds some very cool completely new features (like QuickTime movie editing and the virtual file system). With the upgrade costing a mere $29.95 for the standard version ($89.95 for the professional version), it's definitely worth the upgrade fee.

Don't expect my report on 4.5 to be a comprehensive review: this is just a brief glimpse of some of the new features. It's based on the things I've noticed. I'm sure every one of us would pick a different feature as our favorite. (If you'd like a comprehensive list of new stuff, look here.)

Now I'd originally planned to just take one column to explore RB 4.5, but as I began writing this, it just got longer and longer! There's a lot to explore here, and yet I feel I'm just touching the surface. This is an impressive upgrade. I don't want to neglect features, and I want to do more than just give you a list of new items -- I want to explain and demonstrate how these things work.

So I'm going to break my 4.5 "review" into a series of columns. While we won't be building actual programs, I will give you some demo code to try out some of the new features. Eventually I'd like to do some projects using the new features.

Subtle Enhancements

Often with an upgrade, people focus on the fancy new whizbang features and ignore the smaller ways a program improves. Yet those small changes usually affect you the most since they involve aspects of the application you use all the time. I'm going to begin by covering some of the smaller, often overlooked improvements, and then we'll look at the major new features.

New Icons

While I liked most of the way the old REALbasic IDE worked, I was suprised to discover when I opened a project in RB 4 how quickly I'd grown used to the 4.5 changes. REALbasic 4.5 has new icons within the project window:

As well as within the Code Editor:

While these icons are nicely done, you might be tempted to think of them as just eye-candy. That is definitely not the case -- I'm finding they make it much easier for me to see what I'm doing. For instance, when you've got a project with a lot of parts, or a window with a lot of controls, it's easy to click on the wrong one. But the new icons are more distinctive and I find I rarely click on the wrong one any more. They're also helpful: for instance, windows in the project window now have different icons depending on the type of window (dialog or document). Since the default new window is a document type, I occasionally forget to change it when I'm creating a dialog. But with the new icons I'm finding I notice this in the project window before running the program and discovering my dialogs are funky.

There are also useful "badges" employed. For example, when you make a property or method private (meaning that only the current window can access it), RB adds a "no entry" icon (red circle with a bar through it) as a reminder.

Notes

One of the simplest new features of 4.5 is the addition of the Notes category within Code Editing windows. Notes are simply that: notes, or comments. They're extremely useful as you don't have to worry about commenting the whole text, and because you don't have to comment each line, it's easier to write longer, more detailed descriptions. You can even include code snippets: whatever's in a note field will be ignored by the compiler so you won't get annoying "can't compile" messages if you're using unfinished code.

In the old days, people who shared classes or modules, often included a "dummy" method which contained no code, only comments, and explained how the class or module worked. The Note feature does the same thing, better, and I highly recommend you get in the habit of making notes for yourself.

REALbasic University Quick Tip

If you drag a text selection from the editing area to the left panel while holding down the Option key, REALbasic will add the dropped text as a new note field. That's a great way to back up code snippets and make quick notes.

The note is added with the name of the first line of text you drop.

Inline Auto-Complete

REALbasic's Auto-Complete feature is one of its best and most impressive features. (First-time users of REALbasic are often amazed to see how quickly you can type in code using Auto-Complete.)

REAL Software has been making Auto-Complete better and better the last couple of upgrades, but this time they've added a feature I've been drooling for. The key limitation with the old Auto-Complete was that it only worked at the end of a line. Often, when coding, I ran into situations where I needed to insert new code in the middle of a line. It was frustrating to have to remember the exact name of a long variable or method and type it in accurately. I used to break a line with a carriage return, insert the new code, then remove the return to bring the line back together. It was easier than typing the code by hand, sometimes, but it was hassle and prone to create other errors.

In REALbasic 4.5, however, that workaround is gone: now you can type a couple letters of a variable or method or object, press the tab key, and up comes an Auto-Complete list of items that match what you're typing. Just select the correct one (you can move through the list with the up/down arrow keys) and press return.

Here I typed "list" in the middle the line and pressed tab:

Isn't that cool? In terms of time saved, that's worth the upgrade fee right there!

New Build Settings

I never had any big complaints about the Build Settings dialog -- it seemed to work well enough. But I must admit, after seeing the redesign for 4.5, I like the new version better. It's a little bit more work to use since there are now multiple panels, but there are too many options for a single window now. Besides, if you're not creating a Windows program, you can ignore the Windows panel.

Note that there's a place here to put your app's Creator Code: this is mapped to the same setting in the Project Settings dialog (Edit menu). But here there's a handy "Register" button which takes you to Apple's website where you can register your program's unique Creator so others won't use it. Very handy.

There's also a very welcome new Icon dialog:

It won't help you draw your icon, but at least it supports all the new Mac OS X icon types.

Code Splitter

Have you ever been working on an extra long routine and found yourself continually switching between two portions of the code? Or maybe you've wanted to be able to look at two sections of code at the same time?

REALbasic 4.5 makes that possible with the new Code Splitter feature. At the top of all Code Editor editing panels is a horizontal drag widget which lets you split the editing pane into multiple sections. Each section can display a different portion of the same code, or a completely different method or note.

To set what code is displayed in an editing section, simply put your cursor in that section, then click on the code you want from the left panel.

Perhaps not earthshattering, but it's a nice feature, and when you get in a situation where you need it, you'll wonder how you lived without it.

Math on Properties Window

Amen -- how can I thank you, REAL Software? This is a feature I have been begging for -- and now it's here.

Have you ever wanted to make a control slightly bigger or smaller or move it a precise amount? Sure, you can grab the handle and drag it to a new size, but that isn't precise and sometimes you only want to change one dimension. The solution, of course, is to use the properties menu and change the number directly: but that involves doing mental math.

"The control is 117 pixels wide now and I need it to be twice that size... that's, er, 224, no 234. Yeah, gotta carry that one. Gee that was fun. Now what was I doing again?"

A better solution, the one I suggested to REAL Software, is do like the top page layout programs do: they allow you to use math formulas right on the object properties window! After all, computers are better at math than me. This is extremely useful for moving objects precise amounts or making them specific sizes.

REAL Software has added this feature and done it well: you can enter in complex formulas right in the editing field of the Properties window.

Not only can you use standard +, -, /, and *, you can even use parentheses:

Isn't that cool? Granted, most of the time I just use a simple "+5" or something, but I've been using this feature every day since I started using RB 4.5 regularly, and it's my personal favorite improvement. (I hate busy work and tedious elementary math.)

Duplicate Methods

Another feature I asked REAL Software for was a way to duplicate methods. Especially when I'm experimenting, I'll often create two, three, four, or more versions of the same method. I might try different algorithms to see which is faster or easier, or I might find one isn't working and need to try something else but I don't want to throw out the first routine in case I need to go back to it.

Sure, it was easy to copy and paste code into a new (duplicate) method, but then you had to manually add the parameter and result code. A real pain, especially when you're in a hurry. For some reason REAL Software still has the "Duplicate" menu item disabled when you have a method selected, but at least with 4.5 there is a quick way to duplicate a method: just Option-drag it on the left panel. (It seems almost like you're dragging it onto itself.)

You can even Option-drag from one window to another (i.e. from a window to a module or vice versa).

The entire method, parameters and return values, are copied. All you need to do is (if appropriate) rename the method slightly (I like appending numbers or the word "old" to mine). Then you're all set to edit the alternate version of the routine.

This is a killer timesaver. I've got one program where I have, literally, over 100 methods in a window. Some are backups or duplicates, but most are required. Sorting through that huge list of methods is a pain: it often takes me minutes just to find what I'm wanting. I've often thought it would be better to move those methods into a series of modules, each module organized by function. For example, put all the routines involving the Find/Replace feature in a single module.

That makes sense, but the methods are complicated, and moving them to modules is a huge amount of work. At least it used to be: now I can duplicate them in seconds! I can't wait to do that. It will make working with my program much easier and cleaner (not to mention making the window work faster: it gets slow with so many methods to display).

REALbasic University Quick Tip

You can delete the selected method, note, property, or menu handler quickly by pressing Command-Delete, just like you do in the Finder to send something to the Trash. Just be careful: you won't get a confirmation dialog or warning. The selected item is just gone. (Undo is supported, however.)

REALbasic Extras

This might seem really trivial, but the new "Extras" menu in RB 4.5 is pretty cool. It contains several handy AppleScripts (for something funny, try the "Lookup in Dictionary" with no word selected), some very handy templates (snippets of code), and cool weblinks to various REALbasic resources (including REALbasic University and REALbasic Developer magazine).

The Extras folder contains these items and you're free to modify it as you like (add or delete items). You don't even have to restart REALbasic for your changes to take effect: when you switch back to RB whatever's in the folder is the new menu. Experiment with this -- I think you'll find it a powerful feature.

Next Week

We take a look at some of RB 4.5's major new features.

Letters

Today we've got a letter from Cameron, who offers a fix for a potential problem (okay, a bug ;-) in FontLister.

Hi, I've just gone through your FontPrinter tutorial. I discovered a problem with the PrintPreview window resizing under Mac OS X. The window resize doesn't take into account the Dock, leaving the print and cancel buttons unclickable because they're obscured by the Dock. I found a solution for this. Replace the Open event for the PrintPreview window with this:

  
dim xDif, yDif, w, h as integer

xDif = me.width - preview.width
yDif = me.height - preview.height

w = p.width + xDif
h = p.height + yDif

if w < screen(0).AvailableWidth and h < screen(0).AvailableHeight-screen(0).AvailableTop then
// small enough to fit on screen
me.width = w
me.height = h
else
// too big for screen -- resize to max
me.height = screen(0).AvailableHeight - screen(0).AvailableTop
me.width = (me.height / h) * w
end if

gPrintOkay = false

Also a good column idea could be "How to be Mac OS X friendly with REALbasic 4.5". Things like how to take into account the dock when resizing, how to make a preference menu that moves to the application menu under x, and sheet windows.

One last question. What's the difference between Show and ShowModal?

Cam

A very good point, Cam! Thanks for the code.

This shows why having others test your app is so important: I never even thought of this being a problem because I keep my Mac OS X Dock on the right side of the screen! With a vertical Print Preview window it never got wide enough to interfere with my Dock, and I completely forgot that many people leave the Dock on the bottom. (Silly people! ;-)

Of course the new .availableHeight and .availableWidth properties are an excellent example of the improved Mac OS X support REALbasic is getting. There still are a few things that need an OS call or plug-in, but RB apps can do almost anything they need under Mac OS X. (I'd love to be able to access the Mac OS X spelling checker in my app... anyone know how to do that?)

Your article suggestion is a good one: I'm still learning all the Mac OS X stuff. It used to be complicated and I avoided it, but now it's getting much easier, and I'll cover it in the future.

As to your question, .show simply displays the window, while .showModal displays the window and halts everything until that window is dismissed. The latter is used for dialogs that require an answer before the user can continue. Note, however, that .showModal won't actually be a modal dialog unless the window type is set to one of the modal types (i.e. the frame property is set to Modal Dialog, Movable Modal, Sheet Window). If you use one of the other types of windows (like Document Window), .show and .showModal act identical.


About the Column
REALbasic University is a weekly instructional column on programming with REALbasic and is brought to you by REALbasic Developer, the magazine for REALbasic programmers.

Each week we answer select reader questions, and we're always open to ideas for future columns. Send your questions to . (Keep your questions simple and specific. General queries like "How do I write my own web browser?" will be neglected.) Your question won't be answered immediately, but will be answered in a future column. (If you don't want your correspondence published, just be sure to indicate that when you write. Otherwise it's fair game.)

About the Author
is an author, philosopher, graphic designer, photographer, film director, soccer fanatic, and programmer (among other things). He writes for MacOpinion, runs his own software company, Stone Table Software, which sells the revolutionary Z-Write word processor, and is Publisher and Editor of REALbasic Developer. He lives in Northern California with his cats, Mischief and Mayhem, and is rapidly running out of free time.

See the REALbasic University Archives


REALbasic University contents ©2001-2004 by Marc Zeedar and REALbasic Developer. All Rights Reserved.

Email This Article - Comment On This Article

.

Reader Specials

Server Racks Online:
Apple Xserve CompatibleServer Racks and Universal Network Racks
42U KVM Switch Solutions:
High-End Mac and Multi-Platform KVM Matrix switching solutions!
Digital Camera Online:
Great prices on Digital Cameras and accessories!
KVM Switches Online:
Great prices on Mac KVM Switches from the leading manufacturers!
LCD Monitors Online:
Great prices on LCD Monitors from the leading manufacturers!
LCD Projectors Online:
Shop online for LCD Projectors from the leading manufacturers!
USB 2.0 Online:
Great prices on USB 2.0 products from the leading manufacturers

Serious Business Software:
Accounting, Sales, Inventory, CRM, Shipping, Payroll & more!

KVM Switch solutions for MACs:
DAXTEN is a KVM switch, KVM extender and monitor splitter specialist for PC, SUN and MAC applications from name brand manufacturers - offices worldwide.

The "Think Different Store: The iPod Accessories Store - iPod cases, iPod mini, iPod photo, speakers, itrip, inMotion, Soundstage and all other iPod accessories

Earn Cash with the ThinkDifferent Store Affiliates Program

Need A Web Site?
Applelinks Web Hosting Starting at 19.95 a Month

iTunes_RGB_9mm

.

iTunes_RGB_9mm

Cool Mac Gear


iPod 1G-2G
iPod 3G
iPod 4G
iPod Mini
PowerBook-iBook
Keyboard Skins
Garageband