Integrated Development Environment


A number of new features in REALbasic 2005 are worth touching on, and there are a few features I have yet to discuss. Because this chapter makes such heavy use of the IDE, I do want to spend a moment and touch on a few points of interest.

IDE MenuItems

First off, I'd like to familiarize you with a few of the more important features of REALbasic that are accessible through various MenuItems or toolbars. The IDE has changed considerably and has added a few new features that you will find very helpful. Although some people who are familiar with the old way of using REALbasic may begrudge some of the changes, I find it hard to understand why because the user interface of REALbasic 2005 is, in the vast majority of instances, exceedingly better than previous versions, especially if you are a Windows developer.

File, New Project

At the top of the list is New Project. Every program you write in REALbasic is called a project. A project will be saved on the file system as a single file (with a few exceptions) and will contain all the code, graphics, and so on required by your application to compile and run. By now, this is nothing new to you.

However, one of the best new features is that you can now open more than one project at a time. Prior to REALbasic2005, you couldn't do this, and there are lots of times when it is convenient to look at code in one application while you're writing code in another. Now you can even cut and paste code from one application to the next.

File, New Window

The New Window MenuItem duplicates the current Window, so you can now have two Windows open for the same project. Again, this is a simple, but greatly appreciated, new feature in the latest IDE.

File, Import/Export

You can import and export specific classes and modules so that you can share them among applications. Normally when you export a class, you are exporting a copy of it, so that when another application of yours imports the class and modifies it, the original is not modified. This may be exactly what you want to do, so that you can avoid breaking other programs that already work. The downside to this is that you can easily end up with lots of different versions of classes and modules that are difficult to keep track of.

External items are a solution to this. When you important a class or module into your application, the easiest way to do so is to drag it into REALbasic from the desktop. If you hold down the Command+Option (or Control+Alt for Windows) keys while doing so, you will import them as External items, which means that they are stored outside of the REALbasic project file.

When you export an item, you have the same options that you have when saving a project file: you can export it as a native REALbasic file, or you can export it in XML format. My recommendation is to use REALbasic's XML format whenever possible, for the following reasons.

When using external items, you need to be cautious because when you change code in one project, you are changing code in all the other projects that share this code, which means you can easily break something. If you export REALbasic items in the XML format, you can more easily manage those files using version control software such as CVS or Subversion. Because version control software lets you track the changes that have been made to a file, you can use it to review which changes have been made to the code in your application that have caused it to stop working. You can either fix the problem or roll back the file to the previous version.

If you choose not to use external items, one potential solution is to assign a version number to each class. You can establish a constant called Version, or a method that returns the version of this class. When you import it into your next project, be sure to increment the number if you make any changes to it. (Note that this will change the version number in all projects that use the class if you are using external items. That's okay, but you may want to have your application test for the class number first. If it's not a recognized version, you can be notified that it has been changed in a different application.)

Project Menu

Under the Project menu, you also have the option of encrypting the selected class. This is for those who want to distribute classes or groups of classes, but not reveal the source code.

Following the Encrypt item are several selections for managing the placement of controls on pages. Controls are layered onto a Window, so the Arrange MenuItem lets you manage which layers individual controls are on. Align helps you align your controls so that they line up properly. The Find MenuItem is your entry into REALbasic's powerful Find and Replace features, which I discuss separately.

View, Editor Only

Under the View menu are most of the new features (with respect to the IDE). The first selection says Editor Only. If you select this, the main toolbar and the bookmark toolbar will disappear and you will be left with the tabs for your project. This gets some of the clutter out of the way and lets you focus more on what you are doing.

One important design feature of REALbasic's IDE is the use of Toolbarsthere are several of them within the application, and they are all customizable. Here's a list of what's available for each toolbar.

Main Toolbar

By default, the Main Toolbar contains the following items: Back, Forward, Run, Build, Add Bookmark, Location, Search.

In addition, you have the option of adding the following items: New Project, Open, Save, Save As, Print, Home, Build Settings, Stop, Cut, Copy, Paste, Delete, Undo, Redo, and Language Reference.

The Editor Toolbar

The Editor Toolbar varies according to which tab you have selected. For example, if the Project tab is selected, you will have the Project Toolbar. These context-sensitive Toolbars are as follows.

  • Project Toolbar

    • Default: Add Window, Add Class, Add Module, Add Folder

    • Optional: Encrypt

  • Code Editor Toolbar (when editing a class)

    • Default: Edit Mode, Add Method, Add Property, Add Menu Handler, Add Constant, Add Event Definition, Add Note, Comment

  • Menubar Toolbar

    • Default: View Mode, Add Menu, Add Menu Item, Add Separator, Add Submenu, Convert To Menu

    • Window Toolbar (Edit Code Mode)

    • Default: Edit Mode, Add Method, Add Property, Add Menu Handler, Add Constant, Add Event Definition, Add Note, Comment

  • Window Toolbar (Edit Layout Mode)

    • Default: Edit Mode, Show Control Order, Forward, Front, Backward, Back, and Align

    • Option: Add Bind and List Binds

History

REALbasic now tracks your History. This works just like the history does on your web browser and helps you to go back to recently modified items. There is nothing exceptional here.

Bookmarks

This is a convenience added that allows you to bookmark sections of your project that you will return to often. This is helpful when you have multiple windows open, and so on.

Help

I am not certain that it is accurate to say that REALbasic has an improved help system. It is probably more accurate to say that at this time, REALbasic has laid the foundation for an improved help system. There are some new items under the Help menu to be aware of. First, if you add any plug-ins to your project, you will be able to access their documentation under this menu. There is also a new language reference which, at the time of this writing, was in the process of being rewritten. Although it has its fair share of problems, the new language reference is written in HTML, is searchable, and has the promise of being much improved. One word of warning, however: parts of it are outdated and other parts are just plain wrong. Hopefully, this book will help offset that issue, and there are also a lot of online resources that you can refer to, including a REALbasic documentation Wiki. Rather than putting URLs that might change at some point in the future into this book, I have included links to them at the following site: http://realbasicbook.com/.

Preferences

The new IDE also offers more control in the way of preferences. When you select Preferences from the preference menu (or Options), a Window will be displayed that looks more or less like a typical preferences window. On the left is a column of icons that represent the preferences you can change. Select one and the right side of the Window displays the specific values that can be updated.

Code Editor

If you select Code Editor (which is selected by default), you'll have the opportunity to change the default font REALbasic uses in the code editor, as well as how large the font should be displayed. There's even a handy alphabet listing below so that you can see what it will look that.

Below that is the second option that allows you to control syntax highlighting. You can adjust them to suit your own personal fancy.

You also have the option of having REALbasic apply the standard case when using Autocomplete. Autocomplete is a tool available in the code editor that tries to detect what you are typing; when it thinks it knows, an ellipsis appears (three little dots...). When that shows up, you can press the Tab key and a menu will pop up with all the options. This comes in handy when you are referring to REALbasic classes or functions and you're not sure what the name of the property or method is that you want to call. By using Autocomplete, you're provided a list from which you can choose the rest of the statement.

That's a long explanation, but the point of it was to explain what it means to apply standard case to Autocomplete. Generally speaking, REALbasic doesn't care about case. You can refer to objects in uppercase or lowercase and REALbasic will accept it regardless. What this feature does is make sure that the code is in the "Standard" case if you use Autocomplete.

REALbasic capitalizes the first letter in most classes, modules, and methods. If the name is the combination of two words, like ListBox or EditField, the first character of each word is capitalized. Names of classes have to be one word, but they often make more sense if you are more descriptive. By joining a few words together and capitalizing the first letter of each word, you make your code much more legible.

Window Editor

You can set font attributes for the Window Editor as well. Controls are the user-interface elements you see on any application, such as PushButtons, EditFields, and so on. All I will say at this point is that controls can contain other controls, and this preference item lets you decide whether to highlight the parent control and what color you'd like that highlight to be. I'd recommend keeping highlighting of the parent control on because it can sometimes be difficult to tell whether one control is embedded in another, or just overlapping it, and this can provide you with immediate feedback and save you a lot of time.

Build Process

After you have built (compiled) your application, you have the option of being shown the location of the built applications on your hard drive. The Macintosh version of the IDE refers to this as the Finder, which is equivalent to Windows Explorer on the PC.

A second option is to show multiple compile errors.

Debugger

The debugger is the tool that helps you track down errors with your application. You will need to get intimately involved with the debugger eventually. REALbasic has an excellent debuggerit is extremely easy to use. Because REALbasic allows you to compile applications for three platforms, there are times when you will want to be able to debug the Windows version of your application, even though you are writing the code on your Macintosh, or perhaps the other way around. The Professional Edition of REALbasic allows you to compile applications for all platforms, but the IDE runs only on the platform you purchased it for.

You can set up the information you need to be able to debug apps running on other computers here. See the section titled "Debugger" later in this chapter for more information.

Printing

Printing is...well...let's just say that there's not a lot you can do with the printing features of REALbasic. About the only thing you can do is decide which font to use when printing your source code.

Find and Replace

The new find and replace Window provides a much better way of searching through your code than in the previous edition of REALbasic.

In the default layout, a search box appears on the Main Toolbar. Click the magnifying glass icon to narrow your search to the entire project, the item, or the method. Item means the currently active class or module.

A more powerful interface can be found under the Edit menu. Go to Edit, Find, Find and select. A dialog box appears, with an EditField to enter your search criteria and, if applicable, a field to enter the replace value.

Two new features of note are that the search saves recent searches, which are accessible by clicking the BevelButton decorated with a stop watch icon. Next to that is the Favorites BevelButton, signified with a heart icon.

You can search for the whole word, match case, or use regular expressions. When matching the whole word, REALbasic will match only when a complete word matches what is searched for. In other words, if you search for the word "for," it will match only "for" and not "ford." Matching cases means that REALbasic will pay attention to uppercase or lowercase when matching words, and will treat "mark" as distinct from "Mark."

After the search term is entered, you have the option of finding the first occurrence, or of finding all occurrences. The results of the Find All search will appear in a Search tab and will be listed along with information about the type of match, the fully qualified name of the member in which the match occurred, and the match itself. At the bottom of this list is a Replace field, which allows you to do a search and replace against the selected matched items.

If the Search Results tab is already up and you search in the search field in the Main Toolbar, the search will default to a Find All search.

Suppose you have a single method that is called from several places in your code and you decide that instead of one method, you want two methods. You can search for the method name, finding all occurrences of its use, and then you can select the ones you want to change and replace the old name with the new name. In earlier versions, you had to either replace all occurrences of a phrase with the new phrase or manually cycle through each match to decide whether to perform the replace. This is particularly useful when refactoring code.




REALbasic Cross-Platform Application Development
REALbasic Cross-Platform Application Development
ISBN: 0672328135
EAN: 2147483647
Year: 2004
Pages: 149

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net