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

Beginning REALbasic - From Novice To Professional (2006)

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

About the Technical Reviewer

ALLAN KENT is a born-and-bred South African, who still lives and works in Cape Town. He has been programming in various and diverse platforms for over 20 years. Most recently, while on the hunt for a viable cross-platform programming solution, Allan chanced upon REALbasic and he hasn’t looked back since.

xx

Acknowledgments

This book represents the hard work and efforts of numerous individuals. I would like to thank Chris Mills, who served as the book’s lead editor, for working so hard and for providing me with the opportunity to write this book. Special thanks go out to Allan Kent, the book’s technical reviewer, for offering countless ideas and suggestions that helped make this a much better and stronger book. I would also like to thank Marcia Baker, the book’s copy editor, for her dedication and professionalism, and for her patience in dealing with and fixing my many typos and grammatical errors. I also want to acknowledge and thank Richard Dal Porto, the project manager, for keeping me on schedule and making sure I didn’t forget to tie up any loose ends, and Lori Bring, the book’s production editor, for guiding this book through its final stages. Finally, I’d like to thank everyone else at Apress for all their hard work.

xxi

Introduction

Welcome to Beginning REALbasic! REALbasic is a programming language that provides you with everything you need to create software applications that can run on Macintosh, Windows, and Linux. REALbasic is an extremely powerful programming language that is capable of creating world-class software. Yet, at the same time, REAlbasic is easy to learn and makes a perfect programming language for first-time programmers.

Using REALbasic, you can create applications, utility programs, and computer games. If you are a Windows programmer, REALbasic provides you with all the tools you need to write just about any Windows application imaginable: the same goes for Macintosh and Linux programming. By supporting cross-platform application development, REALbasic significantly enhances your ability to distribute your applications. This means you can share your work with more friends and colleagues, and if you are in the business of developing commercial software, REALbasic can help you attract new consumer markets.

Why REALbasic?

Plenty of programming languages are available today that are similar to REALbasic in many aspects. On any given operating system (OS), they may come close to matching REALbasic’s core set of features. However, none of the other major modern programming languages based on the Basic programming language support application development on all three major desktop OSs. This makes REALbasic unique and gives REALbasic programmers a competitive advantage over other programmers.

As far as modern programming languages go, REALbasic is easy to learn, yet it is every bit as powerful and full featured as any other modern programming language. So, whether you are a student, a hobbyist, or a professional programmer, REALbasic has something to offer you.

REALbasic programmers are supported by a thriving user community and an array of thirdparty developer support. This means you won’t have any trouble finding help or locating companies that do REALbasic software development.

Unlike other programming languages, REALbasic does not require a complex framework to execute. And, unlike Visual Basic .NET, REALbasic applications can run on older versions of Windows, such as Windows 95 or 98, where the .NET Framework is not installed. REALbasic is not restricted to a particular OS. In short, REALbasic is a modern, powerful, cross-platform, object-oriented programming language that is friendly to beginners, yet powerful enough to satisfy the most demanding programmers’ needs.

Who Should Read This Book?

 

The primary purpose of this book is to teach you how to develop applications using REALbasic

 

that can run on Macintosh, Windows, and Linux. Previous programming experience is not

xxii

required, although it certainly is helpful. This book is also designed to assist Visual Basic

I N T R O D U C T I O N

xxiii

programmers in making the jump over to cross-platform development using REALbasic. It accomplishes this goal by pointing out key differences between the two programming languages where appropriate throughout the book.

At a minimum, you need a good understanding of at least one of the OSs that REALbasic runs on (Macintosh, Windows, or Linux). So, whether you are new to programming or an experienced programmer eager to make the transition to cross-platform application development, this book can help you reach your goal.

What You Need to Begin

REALbasic supports cross-platform application development, meaning you can use it to create applications that can be run on Macintosh, Windows, and Linux. To demonstrate and reinforce REALbasic’s cross-platform development capabilities, this book was written using versions of REALbasic that run on all three of these OSs. Therefore, you will see figures and examples of applications running on any combination of these OSs. Except where specifically noted, all the applications you learn how to create in this book run equally well on each OS. Because of differences in how each OS is designed, however, you may notice small differences in the appearance of certain application features. I make every effort to point out where differences occur and to ensure that the examples presented work equally well on Macintosh, Windows, and Linux.

If you do not already have a copy of REALbasic installed on your computer, we have provided Macintosh, Windows, and Linux trial versions on the book’s accompanying CD, along with the source code for all the examples featured in the book. Once you have REALbasic installed, you are prompted to enter a license key when you start it up. If you purchased REALbasic online, you receive your license key via e-mail. If you did not purchase REALbasic online, you are prompted to automatically request a demo key via your Internet connection. This enables you to try REALbasic free for ten days. Once this is done, you are ready to go.

Along with this book, we provide everything you need to begin developing world-class software applications for Macintosh, Windows, and Linux!

How This Book Is Organized

Beginning REALbasic is organized into four parts.

Beginning REALbasic is designed to be read sequentially from cover-to-cover. However, more experienced programmers and programmers with previous BASIC programming experience may want to use this book by reading the first few chapters, and then skipping around and selecting the chapters that interest them the most.

Part 1: Introducing REALbasic

This section is made up of two chapters that are designed to provide you with a solid introduction to REALbasic and its integrated development environment.

xxiv

I N T R O D U C T I O N

Part 2: Learning How to Program with Realbasic

This section consists of six chapters, each of which addresses a specific programming topic. These topics include interface development, menu development, storing and retrieving data, conditional logic, loops, and object-oriented programming.

Part 3: Advanced Topics

The Advanced Topics section, which is made up of four chapters, covers processing files, creating and accessing databases, and working with graphics and audio.

Part 4: Appendixes

This section is made up of three appendixes that address porting a Visual Basic application over to REALbasic, the contents of the book's CD-ROM, and different resources available to you as you continue learning about REALbasic.

Conventions Used in This Book

One of the goals I had in writing this book was to make it as clear and easy to understand as possible. Throughout the book, you will find a number of special elements designed to make reading and working with the presented material easier. The following provides a quick review of these special elements.

Tip Tips are suggestions that point out different ways of accomplishing tasks or helping you to work more efficiently and effectively.

Note Notes are designed to provide you with additional information about a topic being discussed or to bring additional emphasis to a particular point.

SIDEBAR

Sidebars are designed to provide you with information that, while not necessarily essential to the topic being discussed, is still important and worth learning. Sidebars are also used to identify real-world situations where REALbasic can be applied.

P A R T 1

■ ■ ■

Introducing REALbasic

C H A P T E R 1

■ ■ ■

An Introduction to REALbasic

REALbasic is a cross-platform programming language designed to facilitate the creation of software applications that run on Macintosh, Windows, and Linux. REALbasic is a great tool for developing commercial software. It is also an excellent choice to learn as a first programming language. A great deal of time and effort has gone into making REALbasic both powerful and easy to use. In this chapter, you get an overview of what REALbasic is and the kinds of things you can do with it. You also get to see how REALbasic stacks up against competing application development tools that run on Macintosh and Windows. Finally, you jump right in and get your feet wet through the development of your first REALbasic application. Through the creation of your first REALbasic application, you

Get a introduction to components that make up a REALbasic application

Learn the steps involved in building a REALbasic application

Get the chance to compare REALbasic to other application development tools and programming languages

Learn how to compile a REALbasic application to run on different operating systems(OSs)

Overview of REALbasic

REALbasic is a software development tool that provides programmers at all levels with everything they need to create just about any kind of software application you can think of. This includes everything from major enterprise applications to small personal utility programs or even computer games. With REALbasic, the name of the game is cross-platform software development. What this means is that REALbasic enables programmers to create and deploy software applications that can run on different OSs, including Macintosh, Windows, and Linux.

REALbasic is an object-oriented implementation of the BASIC programming language. REALbasic is also a visual programming language, meaning you visually create your REALbasic application’s graphical user interface (GUI) by dragging-and-dropping prebuilt controls onto windows generated by REALbasic. The graphical user interface is the part of the application that the user sees and can interact with using the mouse and keyboard.

3

4

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

Note The term “BASIC” stands for Beginners All-Purpose Symbolic Instruction Code. BASIC was created in 1963 at Dartmouth College.

Using REALbasic, programmers create stand-alone applications. Stand-alone, in this instance, means that once written and compiled, an application can run natively on the OS for which it was created. Nothing else is required. Compiling is the process of translating programming statements into a format that can be executed on a particular OS.

REALbasic is made up of a graphical integrated development environment (IDE), an object-oriented programming language, a debugger, and a cross-platform compiler, as Figure 1-1 shows. REALbasic provides a powerful collection of tools that any professional software developer can appreciate. At the same time, first-time programmers and computer hobbyists will find that REALbasic is easy to learn and fun to work with.

Figure 1-1. The REALbasic IDE, as shown on Windows

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

5

COMPETING PROGRAMMING LANGUAGES

Plenty of other software companies have developed various programming languages based on BASIC. These companies include Microsoft’s Visual Basic, Pyxia’s iBasic, Shoptalk Systems’ JustBasic and Liberty Basic, the GameCreators’ DarkBasic, and many more. However, all these BASIC implementations are designed to run only on the Windows OS. Each of these BASIC implementations has its own particular set of strengths and weaknesses, but none can complete with REALbasic when it comes to cross-platform software development.

From its introduction, REALbasic has been recognized as a programming language that is easy to learn, yet powerful enough to build complex applications. REALbasic quickly became popular for a number of reasons, including

REALbasic facilitates drag-and-drop GUI design.

REALbasic is an object-oriented programming language.

REALbasic supports rapid application development (RAD).

REALbasic provides for cross-platform application development.

Drag-and-Drop GUI Design

One of the features that makes REALbasic popular is the capability to create professional GUIs without requiring that you write a single line of code. Each time you start REALbasic, its IDE appears and you are presented with a new project. A project represents the collection of resources that make up a REALbasic application. Included in every project is a new blank window. You can use this window to create your application’s GUI by dragging-and-dropping predefined controls supplied by REALbasic on to it.

Note An Integrated Development Environment (IDE) is the workspace you are given to work with when creating your application, along with all its associated menus, toolbars, windows, and built-in editors.

REALBASIC’S TIMELINE

REALbasic is developed by REAL Software, Inc. (www.realsoftware.com), which was founded in 1996. REALbasic started out as a software development tool for the Macintosh OS. REALbasic was first released on the Apple Macintosh in 1998, where it quickly received much acclaim and praise. In 2003, the Windows version of REALbasic was released. Later, in February 2004, REAL Software added the capability to compile software that could run on the Linux OSs to both the Macintosh and the Windows versions of REALbasic. However, REALbasic itself still only ran on Macintosh and Windows. This situation changed in September 2005, when REALbasic 2005 for Linux was released.