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

Beginning REALbasic - From Novice To Professional (2006)

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

x C O N T E N T S

The PushButton Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

The RadioButton Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

The Rb3Dspace Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

The RbScript Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

The Rectangle Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

The RoundRectangle Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

The ScrollBar Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

The Separator Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

The Serial Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

The ServerSocket Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

The Slider Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

The SpotlightQuery Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

The SpriteSurface Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

The StandardToolbarItem Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

The StaticText Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

The TabPanel Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

The TCPSocket Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

The Thread Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

The Timer Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

The ToolbarItem Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

The UDPSocket Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

The UpDownArrows Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

The WordApplication Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

Extending REALbasic Functionality by Adding New Controls . . . . . . . . . . 95

Plug-Ins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

ActiveX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

Control Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

Changing Tab Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

Building a Desktop Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98

Designing the User Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

Changing Window and Control Properties . . . . . . . . . . . . . . . . . . . . 100

Adding a Little REALbasic Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

Testing Your Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

C O N T E N T S xi

CHAPTER 4 Working with REALbasic Menus . . . . . . . . . . . . . . . . . . . . . . . . . .

103

Working with REALbasic Menu Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

Examining Menu Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

The Default MenuBar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

Adding a New Menu Bar and Assigning It to a Window . . . . . . . . . 108

Adding Menus, Submenus, and Menu Items . . . . . . . . . . . . . . . . . . . . . . . 109

Adding a New Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

Adding Menu Items. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

Creating a Submenu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

Previewing Your REALbasic Menus . . . . . . . . . . . . . . . . . . . . . . . . . . 117

Enhancing Menu Systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

Using Separator Bars to Organize Menu Items . . . . . . . . . . . . . . . . 119

Setting Up Shortcut Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

Defining Accelerator Keys on Windows and Linux Menus . . . . . . . 121

Using Menu Items to Trigger Command and Code Execution. . . . . . . . . 123

Controlling Access to Menu Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

Reconfiguring Menu Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

Moving Menus and Menu Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

Converting Menu Items to Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

Removing Menu and Menu Items. . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

Customizing the Apple and Macintosh Menus. . . . . . . . . . . . . . . . . . . . . . 128

Creating a StickyPad Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

Designing the User Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

Supplying Application Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

Testing RBQuickNote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

CHAPTER 5

Storing and Retrieving Application Data . . . . . . . . . . . . . . . . .

135

 

Adding Comments to Your Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

135

 

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

135

 

Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

136

 

Property Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

137

 

Storing and Retrieving Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

138

 

Working with Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

139

 

Working with Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

140

 

Creating and Working with Variables. . . . . . . . . . . . . . . . . . . . . . . . .

142

xii

C O N T E N T S

 

 

 

 

Converting Between Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

144

 

 

Built-In Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

145

 

 

String Manipulation Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

145

 

 

Storing Data in Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

146

 

 

Loading Data into Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

147

 

 

Retrieving Data from Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

148

 

 

Changing the Size of Your Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . .

148

 

 

Working with Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

149

 

 

Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

151

 

 

REALbasic’s Built-In Constants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

151

 

 

Defining Your Own Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

152

 

 

Reserved Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

154

 

 

Creating a Starter Desktop Calculator. . . . . . . . . . . . . . . . . . . . . . . . . . . . .

154

 

 

Designing the User Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

155

 

 

Supplying Application Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

157

 

 

Testing RBCalculator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

161

 

 

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

161

 

CHAPTER 6

Making Decisions with Conditional Logic. . . . . . . . . . . . . . . .

163

 

 

Implementing Conditional Logic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

163

 

 

Working with the If…Then Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . .

164

 

 

Single Line If…Then Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . .

165

 

 

Multiple Line If...Then Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

165

 

 

The If…Then…Else Block. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

166

 

 

The If…Then…ElseIf Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

168

 

 

Nesting If…Then Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

168

 

 

The Select…Case Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

169

 

 

#If…#EndIf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

171

 

 

REALbasic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

173

 

 

Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

173

 

 

Mathematical Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

174

 

 

Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

175

 

 

Creating a Computer Game. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

176

 

 

Putting Together the Game’s User Interface. . . . . . . . . . . . . . . . . . .

177

 

 

Defining Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

180

 

 

Adding a Little Program Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

181

 

 

Testing RB Number Guess. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

185

 

 

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

186

C O N T E N T S xiii

CHAPTER 7

Iterative Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

187

 

Processing Data with Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

187

 

Do…Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

188

 

The While…Wend Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

192

 

The For…Next Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

193

 

The For…Each Loop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

195

 

Shortcuts for Creating Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

197

 

Guarding Against Endless Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

199

 

Creating a REALbasic Movie Player . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

200

 

Assembling the Application’s User Interface . . . . . . . . . . . . . . . . . .

201

 

Adding the Program Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

203

 

Testing RB Movie Player . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

206

 

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

207

CHAPTER 8

Object-Oriented Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . .

209

 

An Introduction to Object-Oriented Programming. . . . . . . . . . . . . . . . . . .

209

 

Advantages of Working with REALbasic Classes

 

 

and Subclasses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

210

 

Instantiating Objects from Classes and Subclasses . . . . . . . . . . . .

211

 

Event-Driven Programming. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

218

 

Working with Event Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

219

 

Working with Menu Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

220

 

Working with Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

220

 

Adding Modules to REALbasic Applications . . . . . . . . . . . . . . . . . . .

221

 

Scoping Modules Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

222

 

Adding a Property to a Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

222

 

Adding a Method to a Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

222

 

Adding a Constant to a Module. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

224

 

Working with Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

225

 

Windows Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

226

 

Windows Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

226

 

Associating New Methods with Windows . . . . . . . . . . . . . . . . . . . . .

226

 

Building the RB Picture Viewer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

231

 

Putting Together the Application’s User Interface . . . . . . . . . . . . . .

232

 

Adding Custom Constants and Methods . . . . . . . . . . . . . . . . . . . . . .

235

 

Adding a Little Program Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

236

 

Testing RB Picture Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

238

 

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

239

xiv

C O N T E N T S

 

 

 

PART 3 ■ ■ ■ Advanced Topics

 

 

CHAPTER 9

Processing Text Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

243

 

 

Working with Plain and Styled Text Documents . . . . . . . . . . . . . . . . . . . .

243

 

 

Defining File Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

243

 

 

Specifying File Types in Your REALbasic Applications . . . . . . . . . .

244

 

 

Working with File Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

245

 

 

Accessing Files and Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

245

 

 

Specifying File or Folder Location . . . . . . . . . . . . . . . . . . . . . . . . . . .

246

 

 

Accessing Special Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

247

 

 

Using Open File and Folder Dialog Windows . . . . . . . . . . . . . . . . . .

247

 

 

Verifying Path and File or Folder Existence. . . . . . . . . . . . . . . . . . . .

249

 

 

Deleting Files and Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

250

 

 

Process Text Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

250

 

 

Reading from Text Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

250

 

 

Writing to Text Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

252

 

 

Working with Styled Text. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

252

 

 

Reading Styled Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

253

 

 

Writing Styled Text to Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

253

 

 

Saving Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

254

 

 

Printing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

255

 

 

Working with the Page Setup Dialog Window . . . . . . . . . . . . . . . . .

255

 

 

Using the Print Dialog Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

256

 

 

Bypassing the Print Dialog Window . . . . . . . . . . . . . . . . . . . . . . . . . .

258

 

 

Printing Styled Text. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

258

 

 

Creating a REALbasic Word Processor . . . . . . . . . . . . . . . . . . . . . . . . . . . .

259

 

 

Putting Together the User Interface . . . . . . . . . . . . . . . . . . . . . . . . . .

259

 

 

Defining Supported File Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

262

 

 

Adding Custom Constants and Properties. . . . . . . . . . . . . . . . . . . . .

263

 

 

Adding Code That Supports the Menu System. . . . . . . . . . . . . . . . .

263

 

 

Adding Code That Supports the Window and Its Controls . . . . . . .

268

 

 

Testing RB Word Processor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

272

 

 

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

272

C O N T E N T S xv

CHAPTER 10 Working with Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

273

REALbasic’s Database Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273

Database Plug-Ins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274

Structured Query Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274

Creating and Opening REAL SQL Databases . . . . . . . . . . . . . . . . . . . . . . . 275

Creating a New REAL SQL Database from the IDE . . . . . . . . . . . . . 275

Creating a Database in Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276

Connecting to an Existing Database from the IDE . . . . . . . . . . . . . . 276

Connecting to an Existing Database in Code . . . . . . . . . . . . . . . . . . 277

Defining Database Schema. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

Adding Tables, Columns, and Indexes from the IDE . . . . . . . . . . . . 278

Adding Tables, Columns, Indexes, and Records in Code . . . . . . . . 281

Querying Database Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

Letting REALbasic Generate Your SQL Statements . . . . . . . . . . . . . 283

Advanced SQL Query Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

Changing Column Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288

Developing Database Front-Ends. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

The DatabaseQuery Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

The DataControl. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291

The RB Book Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

Creating the PersonalBookDB Database . . . . . . . . . . . . . . . . . . . . . . 293

Creating a Utility to Add New Books . . . . . . . . . . . . . . . . . . . . . . . . . 296

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299

CHAPTER 11 Working with Graphics and Audio . . . . . . . . . . . . . . . . . . . . . . . .

301

Adding Sound Effects to REALbasic Applications . . . . . . . . . . . . . . . . . . . 301

Getting the User’s Attention. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302

Playing Audio Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302

Giving Your Application a Voice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304

Making Music . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305

Working with Graphics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

REALbasic’s Coordinate System. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

Displaying Graphic Files as a Window’s Background Image . . . . . 310

Drawing Custom Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313

The Fun and Practical Side of Working with Graphics . . . . . . . . . . 317

xvi

C O N T E N T S

Building an MP3 Player . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317

Designing the User Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318

Setting Up the Menu System. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319

Setting Up Property Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319

Adding Program Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319

Testing the RB MP3 Player . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321

CHAPTER 12 Debugging REALbasic Applications . . . . . . . . . . . . . . . . . . . . . .

323

Tracking Down and Fixing Errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

Understanding Syntax Errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324

Understanding Run-Time Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327

Understanding Logical Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328

Working with the REALbasic Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . 328

Setting Breakpoints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329

Tracking Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330

Using Break Points to Control Statement Execution . . . . . . . . . . . . 332

Developing Error Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333

Handling Run-Time Errors with Exception Blocks . . . . . . . . . . . . . . 334

Handling Run-Time Errors with Try Blocks. . . . . . . . . . . . . . . . . . . . 337

Building a Network Connection Checker Application . . . . . . . . . . . . . . . . . 338

Setting Up the User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339

Adding Custom Properties and Methods. . . . . . . . . . . . . . . . . . . . . . 339

Adding a Little Program Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341

Testing the Network Connection Checker. . . . . . . . . . . . . . . . . . . . . 342

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343

PART 4 ■ ■ ■ Appendixes

APPENDIX A Migrating Visual Basic Projects to REALbasic . . . . . . . . . . .

347

Porting Visual Basic Projects to REALbasic . . . . . . . . . . . . . . . . . . . . . . . . 347

Doing a Little Prep Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349

Importing Visual Basic Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349

REALbasic’s Project Converter Utility. . . . . . . . . . . . . . . . . . . . . . . . . 349

C O N T E N T S xvii

APPENDIX B What’s on the CD-ROM?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

351

REALbasic Program Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

351

APPENDIX C What’s Next?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

353

Locating REALbasic Resources Online . . . . . . . . . . . . . . . . . . . . . . . . . . . .

353

REALbasic University . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

353

RBDocs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

353

RBGarage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

353

VBZone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

354

REALbasic Gazette . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

354

Really Basic REALbasic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

354

REALOPEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

354

Realgurus.com. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

354

REALbasic Developer Magazine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

354

Joining REALbasic Mailing Lists. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

356

INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

357

About the Author

JERRY LEE FORD, JR. is an IT professional with over 16 years experience in the industry. His background includes roles as an automation analyst, technical manager, technical support analyst, automation engineer, security analyst, and college instructor. Jerry has a master’s degree in Business Administration from Virginia Commonwealth University in Richmond, Virginia. He is an MCSE and a CISSP. Jerry is the author of 17 other books, including Microsoft Visual Basic 2005 Express Edition Programming for the Absolute Beginner, Microsoft

VBScript Professional Projects, Microsoft Windows Shell Scripting and WSH Administrator’s Guide, Learn VBScript: In a Weekend, Microsoft Windows Shell Script Programming for the Absolute Beginner, Learn JavaScript: In a Weekend, and Microsoft Windows XP Professional Administrator’s Guide. Jerry lives in Richmond, Virginia, with his wife Mary, and their children Alexander, William, and Molly.

xix