Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Beginning REALbasic - From Novice To Professional (2006)

.pdf
Скачиваний:
233
Добавлен:
17.08.2013
Размер:
18.51 Mб
Скачать

16

C H A P T E R 1 A N I N T R O D U C T I O N T O R E A L B A S I C

REALbasic vs. Apple’s XCode

Just as REALbasic competes with Microsoft’s Visual Basic as a tool for application development for Windows software, REALbasic also has plenty of competition in the Apple world. One competitor of particular significance is Apple’s XCode. Like REALbasic, XCode is a tool suite and an IDE for software creation on the Mac OS X.

There is no doubt that XCode provides an effective and powerful software development platform. Programmers with a strong Macintosh background no doubt will want to give it serious consideration. However, unlike REALbasic, XCode’s capabilities are strictly limited to Mac OS X development. Unlike REALbasic, XCode is not designed to support the development of applications on previous versions of the MAC OS.

XCode’s focus is on providing a powerful software development environment that facilitates application development using any of an assortment of programming languages. XCode is also designed to provide programmers with access to the latest Apple technologies. The programming languages supported by XCode include

C

C++

Objective-C

Java

AppleScript

XCode provides a powerful and robust IDE for the development of software designed specifically for the Max OS X. However, it falls short of REALbasic in many ways. For example, while REALbasic is based on a easy to learn, yet powerful, implementation of BASIC, XCode only supports AppleScript, Java, and variations of C and C++.

XCode also falls short in the area of cross-platform development. Programmers who develop an application using XCode and one of its supported version of C or C++ must be prepared to rewrite their applications to port them over to Windows or Linux. While versions of C and C++ exist on both Windows and Linux, the programmer needs to be prepared to deal with differences in the way the languages are implemented on other platforms. In addition, the programmer also must be prepared to learn to work with different IDEs on each platform to which the application will be ported.

C H A P T E R 1 A N I N T R O D U C T I O N T O R E A L B A S I C

17

Online REALbasic Support Services

You can download a copy of REALbasic and acquire a license key from the download pages at the REAL Software website, as you can see in Figure 1-3. Here you can also find plenty of information about REALbasic, including information and links to all kinds of REALbasic resources, such as user groups and sample applications.

Figure 1-3. Downloading the Macintosh Edition of REALBasic 2006

In addition to learning more about REALbasic and visiting the REAL Software online store, you’ll probably find the information presented on the Support page located at www.realsoftware.com/support/ (as Figure 1-4 shows) the most helpful.

18

C H A P T E R 1 A N I N T R O D U C T I O N T O R E A L B A S I C

Figure 1-4. A variety of support services are available for REALbasic.

The Support page at the REAL Software website provides access to critical technical and information resources. The Support page provides access to the following resources.

Technical Support. Free online e-mail-based technical support for North American customers. To use this service, you must supply your e-mail address and your license key. Allow up to 48 hours for a response.

REALbasic Developer Program. Designed for professional software developers and software development companies, this feature enables you to purchase one of several different support options. These options provide for expedited technical support services, and bug fixes, as well as get your name or company listed in REAL Software’s consultant referral program.

Mailing Lists. Lets you sign up for any number of REAL Software sponsored mailing lists and search through archive listings. Lists are available for new users, news, game programming, and plug-ins.

Feedback. Provides the capability to notify REAL Software of problems or bugs found in REALbasic, as well as to request new features and product enhancements.

International Support. Provides access to links that non-North American users can use to find regional sources of information and support for REALbasic.

C H A P T E R 1 A N I N T R O D U C T I O N T O R E A L B A S I C

19

In addition to all the resources just listed, you can also find links to white papers, be able to request assistance in locating a REALbasic consultant, and get help if you have forgotten or lost your REALbasic license key.

Getting Started with Your First REALbasic Application

Now that you have spent some time learning about what REALbasic is, what it can do, and how it stacks up against other software development alternatives, it’s time to see how REALbasic works. You can do this by creating your first REALbasic application. Learning a new programming language can be challenging and, at the same time, it can be a great deal of fun. For some, the idea of creating your first application before you have had a chance to learn all about the language seems intimidating. This is perfectly normal. However, there is no better way to learn than by doing. By creating your first application, you can get a solid understanding of what REALbasic is and what it can to, and you will be better prepared to understand the material in the following chapters.

First-time programmers should follow along carefully in this exercise, making sure to follow every step precisely. For now, focus on the overall process and the order in which things are done. Limit your attention to only the specific steps covered. Don’t get caught up in trying to sort your way through all the different windows, menu options, toolbars, and controls that REALbasic makes available.

Programmers with a Visual Basic background should focus on the overall steps involved and look for similarities between REALbasic and Visual Basic. Programmers with a background involving a different programming language should vary their approach, based on what they bring with them from their particular programming background and its similarities (or lack thereof) to REALbasic. Regardless of your background, the most important fact is to focus on the big picture. Don’t worry about the details for now.

Hello World!

As you will see as you go through the steps required to build the Hello World! application, REALbasic applications are typically created in five steps, as shown in the following outline.

1.Create a new REALbasic project.

2.Build the graphical user interface.

3.Modify window and control properties.

4.Add program code.

5.Test and compile the application.

20

C H A P T E R 1 A N I N T R O D U C T I O N T O R E A L B A S I C

If you have not done so already, go ahead and install REALbasic. Once the install is complete, start REALbasic. Once REALbasic starts, you will see its IDE. As Figures 1-5, 1-6, and 1-7 show, except for a few OS-specific cosmetic differences, the REALbasic IDE looks the same on Macintosh, Windows, and Linux.

As you can see, the REALbasic IDE is made up of a collection of menus, toolbars, tabbed screens, and windows. Through the creation of the Hello World! application, you get a gentle introduction to some of the major features of the REALbasic IDE.

Figure 1-5. The REALbasic IDE, as seen from the Macintosh Edition.

C H A P T E R 1 A N I N T R O D U C T I O N T O R E A L B A S I C

21

Figure 1-6. The REALbasic IDE, as seen from the Windows Edition.

Figure 1-7. The REALbasic IDE, as seen from the Linux Edition.

22

C H A P T E R 1 A N I N T R O D U C T I O N T O R E A L B A S I C

Creating the Graphical User Interface (GUI)

Each time REALbasic starts, it automatically creates a new project for you. A project is a collection of items that, together, make up the building blocks of a REALbasic application. By default, all REALbasic applications start out with three items, as you can see in Figure 1-8.

Figure 1-8. A REALbasic project is made up of multiple items.

These three items are

App. This item contains information about the application.

Windows1. This item contains information about the application default main window (Window1).

MenuBar1. This item contains information about the main window’s default menu bar.

The first step in creating the Hello World! application is to create its GUI. You begin this process by double-clicking the Window1 item on the Projects screen tab. This opens the Windows Editor, as Figure 1-9 shows, enabling you to design your application’s GUI.

C H A P T E R 1 A N I N T R O D U C T I O N T O R E A L B A S I C

23

Figure 1-9. The Window Editor provides you with all the tools you need to build your application’s graphical user interface.

Just to the left of the Window Editor, you can see a window containing a collection of predefined controls. These controls provide you with everything you need to create the Hello World! application.

To build the application’s GUI, you need to add the appropriate controls to Window1. The easiest way to do this is by dragging-and-dropping a copy of the control on to the window. As you do this, the cursor changes to a crosshair. You can then drag the crosshair across the window and draw the size of the control. The first control you need to add is the PushButton control. This control is used to manage the display of a text message the application displays as it runs. Using the slider bar in the Control List window, locate the PushButton control, and then drag-and-drop on top of Window1, as Figure 1-10 shows.

Note A PushButton is a control that looks and acts like a button. Typically, PushButton controls are used to initiate the execution of a particular command or task when the user clicks them.

24

C H A P T E R 1 A N I N T R O D U C T I O N T O R E A L B A S I C

Figure 1-10. Using drag-and-drop, you can quickly build your application’s GUI.

Once you have added a copy or instance of the PushButton control, you move it where you want it, using drag-and-drop. Notice that when the button is selected, resizing handles appear. Using these handles, you can change the size of the control to suit your needs. Place the PushButton control in roughly the same location as Figure 1-10 shows.

Next, you need to add an EditField control to the window, and resize and center it just above the PushButton. The EditField control is used to display the text message the user sees when the application runs. Note, as you move and resize the EditField control, the Window Editor assists you by displaying alignment indicators, as you can see in Figure 1-11.

The last control you need to add to your application is the StaticText control. Drag- and-drop an instance of this control onto the window, and align and center it just above the EditField control, as Figure 1-12 shows.

C H A P T E R 1 A N I N T R O D U C T I O N T O R E A L B A S I C

25

Figure 1-11. Adding a EditField control to your REALbasic application

Figure 1-12. The StaticText control lets you display text anywhere on your application’s background window.