<<

PART 4

■ ■ ■ Appendixes APPENDIX A ■ ■ ■ Migrating Projects to REALbasic

If you are a Visual Basic looking to make the jump to REALbasic, you probably have Visual Basic applications you want to migrate over as well. REALbasic and Visual Basic share a great many similarities. As such, there is no reason why you cannot convert most of your applications over to REALbasic. This way, not only can you run them on Windows, but you also can port them over to Macintosh and . Specifically, you learn

• How to prepare your Visual Basic code for migration

• How to import Visual Basic projects into REALbasic projects

• How to use the REALbasic Project Converter

Porting Visual Basic Projects to REALbasic Depending on the size and complexity of your Visual Basic projects, the challenge of convert- ing your applications may seem daunting. However, you can do a number of things to make the process go smoother and to save yourself considerable time and effort. You should be able to reuse most of your Visual Basic code in your new REALbasic appli- cations. However, many little differences exist between the two programming languages. This should not be surprising given ’s Windows centric approach to implementation. REALbasic, on the other hand, has been implemented using a cross-platform approach that stresses code portability.

347 348 APPENDIX A ■ MIGRATING VISUAL BASIC PROJECTS TO REALBASIC

A sampling of differences between Visual Basic and REALbasic include the following:

• Differences in supported data types. For example, Visual Basic supports the Long and REALbasic does not. Instead, you should use REALbasic Integer data type. Visual Basic also supports the Currency data type, for which REALbasic has no equivalent.

• Differences in classes and data types. For example, in REALbasic the Date is handled as a class, whereas in Visual Basic, the Date is made available as a built-in data type.

• Differences in variable declaration. REALbasic forces you to declare all variables using the Dim keyword. Visual Basic enables you to dynamically create variables, making Option Explicit an optional statement.

• Differences in variable naming rules. In REALbasic, variable names must begin with a letter and are made up of alphanumeric characters. However, Visual Basic variable names can also contain special characters (%, @, &, $, and so forth) leading to potential conflicts.

• Differences in keywords. A valid variable in one language may result in a keyword con- flict in the other language.

• Differences in operators. For example, in Visual Basic, concatenation is performed using the (&) character, whereas REALbasic uses the plus (+) character.

• Differences in the way some keywords are implemented. For example, in Visual Basic, the Mid function can be used to return a substring or to perform a substring replace- ment. In REALbasic, the Mid function can only be used to return a substring.

• Differences in the naming of the same functions. For example, REALbasic has LowerCase and UpperCase functions, whereas Visual Basic has LCase and UCase functions.

• Differences in the application of conditional logic. Unlike Visual Basic, REALbasic does not support single line Case statements.

• Differences in the formation of loops. REALbasic does not support the setup of a loop index on the Next statement in a For…Next loop the way Visual Basic does. Visual Basic supports the creation of loops that iterate negatively, using the To and Step keywords. REALbasic replaces these keywords with the DownTo keyword.

• Differences in how functions operate. Visual Basic allows functions to return a result by setting a value equal to the name of the function. REALbasic requires you to use the .

• Differences in how parameters are supported. Instead of supporting optional parame- ters, REALbasic provides the capability to set up default values for parameters.

• Differences in access. Visual Basic using a Windows-specific approach to accessing the file system, whereas REALbasic uses an independent- access approach. APPENDIX A ■ MIGRATING VISUAL BASIC PROJECTS TO REALBASIC 349

As you can see from this brief sampling, the differences between Visual Basic and REAL- are far too numerous to outline in this appendix. Instead, this appendix is designed to provide you with an overview of your options for converting Visual Basic projects to REALbasic projects and to outline the basic steps involved.

Doing a Little Prep Work You can take a number of simple steps prior to converting your program code that can signifi- cantly simplify the migration process. For starters, review your Visual Basic code and, if necessary, change it so all variables are formally declared. Also, ensure that all variable names conform to REALbasic’s rules. You should spend a little time checking on the data types being used, as well, and change them if necessary. And, while you’re at it, keep an eye on variable names, as well as and function names to make sure they are not in conflict with any REALbasic keywords.

Importing Visual Basic Projects REALbasic provides you with the capability to import any Visual Basic 2 or later form, along with all associated code into REALbasic projects. In doing so, REALbasic automatically re-creates Visual Basic forms as REALbasic windows. In addition, REALbasic creates handlers and methods to store any program code imported along with the Visual Basic forms. The following procedure outlines the steps involved in importing a Visual Basic form into a REALbasic project:

1. Locate the Visual Basic form you want to import.

2. Create a new REALbasic project or open the REALbasic project into which you want to import a Visual Basic form.

3. Drag-and-drop the Visual Basic form into the REALbasic Project Editor screen.

Depending on the complexity of the program code imported along with a Visual Basic form, you may not need to do anything else to get your project to compile under REALbasic. In most cases, though, you’ll have some code statements that REALbasic was unable to convert. To find out, try to compile your new REALbasic application and, if necessary, fix any reported errors.

REALbasic’s Project Converter Utility In addition to importing your Visual Basic forms directly into REALbasic projects, you can use the Visual Basic Project Conversion Utility to assist in the conversion of entire Visual Basic projects to REALbasic projects. This utility is available free: simply download it from the REALbasic web- site (www.realbasic.com/downloads/). According to its documentation, the Visual Basic Conversion Utility is designed to assist in converting Visual Basic 4.x to 6.x projects to REALbasic projects. This utility is not intended as a tool for converting Visual Basic .NET applications. You install the Visual Basic Project Conversion Utility by downloading and decompressing it in the desired location on your . Once installed, you can use it to convert Visual Basic projects by dragging-and-dropping the Visual Basic projects on to the utility. The utility 350 APPENDIX A ■ MIGRATING VISUAL BASIC PROJECTS TO REALBASIC

then analyzes all the Visual Basic project’s files. The Visual Basic Project Converter Utility auto- matically converts Visual Basic projects, forms, classes, modules, and program code into equivalent REALbasic projects, windows, classes, modules, and program code. Although, this utility can completely convert simple Visual Basic projects to REALbasic projects, it cannot convert most projects without a little help on your part. For example, you will probably have to rewrite certain portions of program code. In addition, any controls found in Visual Basic applications for which corresponding controls do not exist in REALbasic need to be converted to Canvas controls, leaving it up to you to create your own replacement con- trols or equivalent functionality. The Visual Basic Project Converter Utility’s support is limited. Any database connections found in a Visual Basic project will not be re-created within REALbasic projects. Neither will a database be added to your REALbasic project. Instead, you must go back and reestablish the database connection, and then reset the DataField and DataSource properties for all controls bound to the database. APPENDIX ■ ■ ■ What’s on the CD-ROM?

When it comes to being a good REALbasic programmer, no substitute exists for hands-on experience in creating and testing REALbasic applications. It helps to have a collection of application from which you can learn and experiment. By studying and copying code examples from other REALbasic projects, you can also save time when creating new applications. This book’s companion CD-ROM provides access to all the sample applications presented in this book. This book’s companion CD-ROM also provides you with convenient access to copies of REALbasic 2006 for Macintosh, Windows, and Linux.

REALbasic Program Source Code This book was written with the intention that you create and experiment with each of the sam- ple applications presented in the chapters as you make your way through the book. However, in the event that you may not have had the time to create and test every application presented, you can find copies of each sample application on this book’s companion CD-ROM. Table B-1 provides you with a quick review of each of the sample applications you will find.

Table B-1. REALbasic Projects Available on This Book’s Companion CD-ROM

Chapter Application/Project Description Chapter 1 Hello World.rbp A Hello World! Application Chapter 2 RBBookFinder.rbp The RBBookFinder Browser Chapter 3 RBClock.rbp A Desktop Clock Application Chapter 4 RBQuickNote.rbp The RBQuickNote StickyPad Application Chapter 5 RBCalculator.rbp A Desktop Calculator Chapter 6 RB NumberGuess.rbp The RB Number Guess Game Chapter 7 RB Movie Player.rbp The RB Movie Player Chapter 8 Picture Viewer.rbp The RB Picture Viewer StatesListbox.rbo A custom ListBox Control of State Names Chapter 9 RB Word Processor.rbp The RB Word Processor

Continued 351 352 APPENDIX B ■ WHAT’S ON THE CD-ROM?

Table B-1. Continued

Chapter Application/Project Description Chapter 10 DBBuilder.rbp The RB Book Database Setup Application DBAdd.rbp The RB Book Database Add New Books Front End Chapter 11 RB Painter.rbp The RB Draw Application RB MP3 Player.rbp The RB MP3 Player RB Speech.rbp A Speech Synthesizer Application RB Piano Player.rbp A Minivirtual Piano Chapter 12 Network Interface Checker.rbp The Network Connection Checker APPENDIX ■ ■ ■ What’s Next?

Congratulations on completing Beginning REALbasic. Learning a new programming language is a significant achievement and represents a major effort. But, don’t look at the completion of this book as the end of your REALbasic education. You have plenty more to learn! To help keep your momentum going, this appendix provides you with information about different resources you may want to consider pursuing to further develop your REALbasic programming skills.

Locating REALbasic Resources Online Many websites are dedicated to REALbasic, and some are better than others. The following sec- tions outline a number of good sites. Along with the name and web address of each site, you’ll find a brief description of what you can expect to find.

REALbasic University The REALbasic University website, located at www.applelinks.com/rbu/, provides access to a weekly online column dedicated to Macintosh using REALbasic. This website is a great source for learning new programming techniques and getting tips on how to do things differently.

RBDocs The RBDocs website, located at www.rbdocs.com, is an online community where you can find a collaborative collection of REALbasic documentation. This website’s goal is to provide more detailed documentation than is provided in the REALbasic Reference.

RBGarage The RBGarage website, located at www.rbgarage.com, provides access to over 1,000 different links to REALbasic resources, including links to plug-ins, modules, sample code, and tutorials.

353 354 APPENDIX C ■ WHAT’S NEXT?

VBZone The VB Zone RB website, located at rb.thevbzone.com/, provides access to sample REALbasic projects and tons of sample code. You’ll also find a good collection of programming lessons and links to other REALbasic resources.

REALbasic Gazette The REALbasic Gazette website, located at rbgazette.com/, is a web log where you can go to find REALbasic news. This website also provides a huge supply REALbasic programming tips and program code.

Really Basic REALbasic The Really Basic REALbasic website, located at www.ttpsoftware.com/ReallyBasicRB/, is devoted to providing beginner REALbasic with sample projects, code snippets, and tutorials, as well as other useful resources for those just getting started.

REALOPEN The REALOPEN website, located at realopen.org/, is a public open-source repository for REALbasic code. The REALOPEN website’s main function is to provide a collaborative environ- ment in which REALbasic software developers can organize and share access to projects. But, this is also a great place to find plenty of REALbasic news.

Realgurus.com The Realgurus.com website, located at realgurus.com/board/, provides access to forums where you can access thousands of online discussions about REALbasic programming.

REALbasic Developer Magazine Another excellent source for cutting-edge information and REALbasic is the REALbasic Developer magazine, which you can subscribe to by visiting www.rbdeveloper.com, as shown in Figure C-1. REALbasic Developer magazine provides access to an assortment of articles of interest to both beginner and professional programmers, and it provides an essential resource for serious REAL- basic programmers. APPENDIX C ■ WHAT’S NEXT? 355

Figure C-1. REALbasic Developer magazine provides access to REALbasic articles and advertisements sponsored by third-party developers. 356 APPENDIX C ■ WHAT’S NEXT?

Joining REALbasic Mailing Lists You can find a Mailing Lists link to REALbasic mailing lists located on the support page at the REALbasic website (www.realbasic.com/support/). Go to this URL and you’ll be given the opportunity to sign up with any of the following mailing lists.

• Getting Started. A mailing list dedicated to the needs of beginning REALbasic programmers.

• REALbasic NUG. A mailing list where experienced REALbasic programmers post ques- tions and share answers.

• REAL News. A mailing list where you can sign up to receive REALbasic announcements.

• Tips. A mailing list that provides access to useful information and tips provided by Geoff Perlman, CEO of REAL Software.

• REALbasic Games. A mailing list dedicated to discussions and questions related to game development using REALbasic.

• Plugins. A mailing list where you can get information about REALbasic plug-ins.

To sign up with one or more of these mailing lists, all you need to do is provide your e-mail address, and then specify whether you want to receive individual mailing-list postings or mes- sages in digest format before you click the Submit Request button. Index

■Symbols Advanced button, 288, 296 #If … #EndIf , 164, 171–172 aligning controls, 96–97 & (ampersand) character, 123 alignment tools, 96–97 + (plus) button, 287 Alt key, 123 + (plus) character, 158 AlternateActionButton, 217 < operator, 173 Alternate-MenuModifier property, 121 <= operator, 173 ampersand (&) character, 123 <> operator, 173 Analysis, EditField control, 183 = (equals) operator, 173 And operator, 175 > operator, 173 App class object, 263 >= operator, 173 App item, 22, 75, 177, 293 ■A Append method, 149, 196 AppendToTextFile method, 252 About window, Help menu, 235 Apple menu, 37, 128 accelerator keys, menus, 105, 118, 121, 123 Apple QuickTime, 86, 203 AcctStatus column, 289 Apple WebKit, 58 Action event handler, 268, 271, 298, 309, 320, 341 AppleMenuItem value, 128 Action events, 29–30, 32, 50, 63, 101, 184 Apples vs. REALbasic, 16 ActionButton, 217 application data overview, 135 ActionButtonCaptain , 248 application development cycle, 19 ActiveX controls (Microsoft), 95–96 Application menu, Mac OS X, 128 Add Bookmark menu, Main toolbar, 38 application windows, 78 Add Constant button, 235, 263 ArrayName, 147 Add Menu Event Handler button, 157 arrays, 146 Add Menu Handler button, 132, 185, 204, changing size, 148–149 220, 237, 320 defined, 138 Add Method button, 235, 340 dimensions, 147 Add Module button, 221 loading data, 147 Add Property button, 137, 263, 319 multidimensional, 147 Add Window button, 68, 225, 234 retrieving data, 148 Add Window icon, 47 audio adding new controls, 95 NotePlayer control, 301, 305–309 AddRow method, ListBox control, 188, 190 Sound class, 301–304 357 358 ■INDEX

audio (continued) ■C sound effects, 301 calculator application, 154, 156–161 speak method, 301, 304–305 Cancel button, Open dialog window, 251 AutoEnable property, 126 CancelButton, MessageDialog, 217 ■B CancelButton, MessageDialogButton, 217 CancelButtonCaption property, 248 Back button, Windows Editor toolbar, 98 Canvas control, 80, 84, 301, 310, 313, 317, 349 BackColor property, 310 cAppName constant, 153 BackDrop property, 313 Caption property, 28, 62, 140–142, 269 Backward button, Windows Editor toolbar, 98 Case Else statement, 170 Backward menu, Main toolbar, 38 Case statement, 169 BASIC programming language, 3–4 Catch blocks, 337 bbBold PushButton control, 271 CDbl data type conversion, 145 bbFontSize control, 270 CDbl function, 145 beep method (sound effect), 301–302 changing properties, 61 BevelButton control, 79, 260, 268–272 CheckBox control, 78, 80, 320 bitmap file, 232 Checked property, 204, 206 blnExitApp variables, 165 Child method, FolderItem class, 246 Bold property, 27 Clear button, 158 book database application, 292 Clear method, 151 Bookmarks menu, 37 Clone method, Sound class, 302 Boolean constants, 171 CloseButton control, 100 Boolean expression, 198 CMY color model, 312 Boolean value, 140, 228 code blocks, 143, 164–165 Break keyword, 330 Code Editor, 11, 29–30, 42, 49, 101, 136, 157, breakpoints, 329–330 181, 203, 219–220, 226, 235, 293, 327 Browse button, 283 Code Editor pane, 330 Browser pane, 220 Code Editor toolbar, 220 Browser windows, 219 Code view, 131 bugs, 323 Color Picker window, 310 Build icon, 32 Column List field, 286 Build menu, Main toolbar, 38 Column method, DatabaseRecord class, 283 Build Process icon, 325–326 ColumnCount property, 289 Build Settings option, 32 ComboBox control, 81, 191, 199 built-in constants, 151 Comment Command button, 136 built-in database support, REALbasic 2006 comments, 135–136, 138 standard edition, 11 Commit method, Database class, 283 built-in source code, 211 common prefix characters, 143 ■INDEX 359

Common UNIX Printing System (CUPS), 10 ComboBox, 81 comparison operators, 173 Container, 80 compiling applications, 4, 32–33 ContextualMenu, 81 conditional logic, 163, 348 DatabaseQuery, 81 #If … #EndIf block, 171–172 DataControl, 82 If … Then … Else block, 166, 168 deleting, 79 If … Then … ElseIf block, 168–169 DisclosureTriangle, 82 If … Then statement, 164–165 EditField, 82 multiple line If … Then blocks, 165 ExcelApplication, 83 OS specific conditions, 171–172 Favorite controls, 47 overview, 163–164 GroupBox, 83 Select … Case block, 169, 171 HTMLViewer, 84 single line If … Then statement, 165 ImageWell, 84 Find it faster at http://superindex.apress.comFind it faster Find it faster at http://superindex.apress.comFind it faster types of conditional statements, 163 Line, 85 Config.txt, 246 ListBox, 85 Connect method, REALSQLDatabase lost controls, 78 class, 277 MoviePlayer, 86 console application, 13, 44, 292 NotePlayer, 86 CONST keyword, 152 OLEContainer, 86 Const statement, 152 Oval, 87 Constant Name field, 235 PagePanel, 87 constants, 138, 153 Placard, 88 locally defined, 152 Plug-in controls, 47 modules, 224 PopupArrow, 88 windows, 226, 233, 235 PopupMenu, 88 Container control, 80 PowerPointApplication, 89 contextual menu, Code Editor, 198 ProgressBar, 89 ContextualMenu control, 81 ProgressWheel, 89 control objects, 209 Project controls, 47 control subclasses, 212 properties, 78 controlling statement execution, 332 PushButton, 90 controls, 23 RadioButton, 90 adding, 78, 95 Rb3Dspace, 90 alignment, 96–97 RbScript, 90 BevelButton, 79 Rectangle, 90 built-in, 47 RoundRectangle, 91 Canvas, 80 ScrollBar, 91 CheckBox, 80 Separator, 91 360 ■INDEX

controls (continued) data type conversion, 144 Serial, 92 dictionaries, 149–150 ServerSocket, 92 key-value pairs (dictionaries), 149–150 Slider, 92 REALbasic data types, 139–140 SpotlightQuery, 92 scope of variables, 144 SpriteSurface, 92 storing and retrieving overview, 138 StandardToolbarItem, 93 string manipulation, 145–146 StaticText, 93 variables, 142 tab order, 97 data type conversion, 144 TabPanel, 93 data types, 139–140, 348 TabSocket, 93 Database Editor, 283, 285, 287–288 , 94 Database property, REALSQLDatabase class, Timer, 94, 99 277, 291 ToolbarItem, 94 DatabaseFile property, REALSQLDatabase class, 276 UDPSocket, 94 DatabaseQuery control, 81, 289–291 UpDownArrows, 94 DatabaseRecord class, 283 WordApplication, 94 Controls pane, 47, 77 Add Database (REALbasic IDE), 275 Conversion Utility for Visual Basic projects, 349–350 adding tables, columns and indexes (REALbasic IDE), 278–279 coordinate system, graphics, 310 changing data (IDE), 288 Count property, 150, 247 Connect method, 277 Counter variable, 193 connecting to a database (REALbasic CreateDatabaseFile method, 276, 281–283 IDE), 276 CreateTextFile method, 252 CreateDatabaseFile method, 276, 281–283 cross-platform remote , 13 creating REAL SQL databases, 275 cryptic errors, 333 Database Editor, 283, 285, 287–288 CStr data type conversion, 145 DatabaseQuery control, 289–290 CStr function, 145 DataControl control, 291–292 cTitlebarMsg constant, 263 defined, 273 CUPS (Common UNIX Printing System), 10 front-end programs, 289 custom control classes, 212, 215 indexes, 280–281 custom project templates, 44 opening REAL SQL databases, 275 custom properties and methods, 339, 341 plug-ins, 274 Customize Main Toolbar dialog, 38–39 queries, 283, 285, 287 ■D schemas, 277 data, 138 SELECT keyword, 287–288 arrays, 146–149 SQLExecute method, 281–283 constants, 151–153 ■INDEX 361

Structured Query Language (SQL), 274, demo REALbasic version, 12 287–288 design conventions, menus, 122 DataControl control, 82, 289, 291–292 desktop calculator, 154 DataField property, 291–292, 350 desktop clock application, 98–101 DataSource property, 291–292, 350 development platform, 8 DataType keyword, 193–194 dictionaries, 138, 149–150 Date class, 215 Dim keyword, 147, 150 DebugBuild constant, 151, 171 Dim statement, 142–143 DebugBuild OS specific condition, 171 dimensions, 147 debugger operation, 328 dimensions of arrays, 147 debugger toolbar, 333 disabling menu items, 126 debugging, 8 DisclosureTriangle control, 82 breakpoints, 329 Display Name, 245 Find it faster at http://superindex.apress.comFind it faster controlling statement execution, 332 DisplayMsg subroutine, 229 debugger operation, 328 DLL "hell" and REALbasic, 15 error categories, 323 Do … Loop, 188–189 error handler code, 333–337 Do … Until Loop, 189–191 error prevention, 324 Document window, 69, 87 exception blocks, 334–337 documentation, 52–53, 56 listing syntax errors, 326 Do ... Loop loop, 188 logical errors, 328 dot notation, 140 run-time errors, 327–328, 334 downloading REALbasic, 13 Stack list, 330 DownTo keyword, 194 stepping program execution, 333 DrawBlock method, 258, 266–267 syntax errors, 324–325 Drawer Window, 75 toolbar, 333 DrawLine method, 316 tracking values, 330, 332 DrawStopIcon method, 315 trapping errors, 333–337 DrawString method, 257–258, 314–315 Try - Catch blocks, 337 dynamic arrays, 148–149 Variables pane, 330, 332 ■E DecimalButton control, 158 edfTextArea control, 265, 270 Decrypt window, 77 Edit Bookmarks dialog, 40 default window, 47, 75 Edit menu, 37, 107–108, 179, 233 Delete method, FolderItem class, 250 Edit Value window, 27 deleting EditField control, 24, 27, 60, 63, 81–82, 99, files or folders, 250 130, 143, 158, 177, 183, 185, 192, 196, windows, 76 252, 258, 260, 269–270, 287, 296, deleting controls, 79 298–299 demo application, 293 Editor Only menu item, 42 362 ■INDEX

Editor toolbar, 42, 45 ■F editors, 42 file and folder processing Element variable, 195 Child method, 246 elements, 146 Count property, 247 Else statement, 166 deleting files or folders, 250 embedding comments, 135 FolderItems, 245 EnableMenuItems event handler, GetOpenFolderItem, 245, 247–248 edfTextArea control, 265 location, 246 Encrypt window dialog, 76 OpenDialog class, 247–248 encrypting and decrypting windows, 76–77 overview, 243 endless loops, 199 special folders, 247 EndOfLine class, 215 verifying file or folder existence, 249 EndOfLine object, 193, 216 File menu, 37, 107, 262 enhanced database support, REALbasic 2006 file system access, 348 professional edition, 12 file type, 243 equals (=) operator, 173 File Type Set, 244–245, 262 error categories, 323 File Type Set Editor, 245, 262 error handler code, 333–337 FileClear menu, 131 ErrorParameter parameter, 334 FileOpen menu, 204 ErrorType parameter, 334 FileOpen menu handler, 264 event code, 62–63 FileOpen menu item, 237 event handlers, 219–220 FileOpenMP3File menu item, 320 Event Handlers entry, 293 FilePlay menu, 205 event programming, 29–30 FilePrint menu handler, 266 event-driven programming, 218–220 FileQuit menu handler, 267 events, 50 FileQuit menu item, 131 ExcelApplication control, 83 FileSave menu handler, 264 exception blocks, 334–337 FileStop menu item, 206 execution platform, 8, 10 FileType class, 204 Exists method, 249 FillRect method, Graphics class, 316 Exit option, 119 Filter property, 248 Exit statement, 189 Floating Window, 70 Explanation, MessageDialog, 217 focus, controls, 97 Export option, 212 FolderItem class, 205, 247, 252, 303, 310 exporting control classes, 212 FolderItem objects, 276 extensibility, REALbasic 2006 standard FolderItem reference, 246, 250 edition, 12 FolderItems, 245 extension file identifier, 244–245 folders. See file and folder processing Extensions property, 204, 245 font changes, styled text, 252–253 ■INDEX 363

Font section, 27 Graphics object, 256–258 For … Each loop, 188, 195, 197 GroupBox control, 83, 90, 166–167, 177 For … Next loop, 148, 188, 193–195 GUI programming, 22–23 ForeColor property, Graphics class, 314 ■H Forward button, Windows Editor toolbar, 98 hardware requirements Forward menu, Main toolbar, 38 Linux, 10 Frame property, 68, 225 Macintosh, 8 Front button, Windows Editor toolbar, 98 Windows, 9 front-end database programs, 289 HasBackColor property, 310 functions, 227–228, 348 Hello World first application, 19–20, 23, 26 ■G Help menu, 37, 52–53, 56, 157 GetFolderItem method, 246, 277, 303 help system, REALbasic 2006 standard

GetNetworkInfo method, 340–341 edition, 11 at http://superindex.apress.comFind it faster GetNetworkInterface method, 338 HelpAbout menu item, 132, 206 GetOpenFolderItem function, 205, 245, HelpOnlineSupport menu item, 237 247–248, 251, 264, 304 higher-level scope, 180 GetRandomNumber function, 230 History menu, 37 GetSaveFolderItem function, 254–255, 264 horizontal alignment indicators, 96–97 global bookmark, 39 HSV color model, 312 Global Floating Window, 73 HTMLViewer component, 57–59, 61–64 Global level, 222 HTMLViewer control, 59, 84 global module scope, 222 HTMLViewer1 control, 62 graphic file types supported, 231 ■I graphical integrated development icon file association, 245 environment (IDE), 4 Icon property, 177, 201 graphics icons, drawing with Graphics class, 314–315 Canvas control, 313 IDE (Integrated Development Environment), CMY color model, 312 4–5, 7, 20, 35–36, 67, 103, 273, 325 coordinate system, 310 If … Then … Else block, 166, 168, 276 Graphics class, 313–316 If … Then … ElseIf block, 168–169 HSV color model, 312 If … Then statement, 164–165 icons, 314–315 ImageWell control, 84, 232 lines, drawing, 315 importing Paint event, 313 control classes, 212 Pixel property, 313 Visual Basic projects, 349 RGB color model, 312 indexes, 147, 280–281 shapes, drawing, 316 infinite loops, 199 Windows backgrounds, 310, 313 InitialDirectory property, 248 Graphics class, 301, 310, 313–316 InRange method, Random class, 182 364 ■INDEX

Insert method, arrays, 149 user interface design, 68 instance, controls, 24 ListBox control, 85, 212, 289 instantiation, 209 listing syntax errors, 326 InStr string manipulation function, 145 Load caption, 63 Instrument property, 306 LoadURL method, 62 intCounter variable, 188, 190, 197, 199 local bookmark, 39 IntegerColumn method, DatabaseRecord Location area, 56 class, 283 Location menu, Main toolbar, 38 integers, 140 log file, 163 Integrated Development Environment (IDE), logical errors, 328 5, 7, 20, 35–36, 67, 103, 273, 325 logical operators, 169, 175 Intel Macintosh, 9 LongTime property, Data object, 101 Interface Assistant displays, 96 loops, 148, 348 interface scrolling, 94 For … Each loop, 195, 197 InterfaceID property, 340 For … Next loop, 193–195 internet development features Do … Loop, 188–189 REALbasic 2006 professional edition, 12 Do … Until Loop, 189–191 REALbasic 2006 standard edition, 11 endless, 199 Interrupt parameter, 304 overview, 187–188 intResult variable, 159 shortcuts for creating, 197–198 intSecretNumber property, 182, 185 While … Wend loop, 192–193 IsPlaying method, Sound class, 302 lost controls, 78 iterative processing overview, 187–188 Lowercase string manipulation function, 145 ■K Ltrim string manipulation function, 145 Key property, 120–121 ■M keyboard equivalents, 118 MacControlKey property, 121 keywords, 348 MacCreator file type, 245 ■L Macintosh, 10 language reference, 54 applications, 119 lbxInterfaceIDs ListBox control, 341 hardware requirements, 8 Left property, 248 user interface design, 68 Len string manipulation function, 145 Macintosh Classic, 128 Line control, 85, 261 Macintosh menu customizing, 128 Line Separator bars, 262 Macintosh-only modifier keys, 121 line-by-line control, 330 MacOptionKey property, 121 lines, drawing with Graphics class, 315–316 MacType, 245 Linux, 10 MacType file type, 245 hardware requirements, 10 main toolbar OS compatibility, 10 Add Bookmark, 38 ■INDEX 365

Backward, 38 keyboard equivalents, 118 Build, 38 menu components, 105–106 configuration, 38–39 menu items, 112, 114 Forward, 38 Menubar default, 106–107 Location, 38 overview, 103–104 Run, 38 previewing menus, 117 Search, 38 Project menu, 37 Mandatory key, 279 reconfiguring menu organization, mathematical operators, 173–174 126–127 MaximizeButton, 61 removing menu and menu items, 128 MediaPlayer, Windows, 86, 203 separator bars, 119 Menu Editor, 42, 47, 49, 103, 117 shortcuts, 118, 120–121 Menu Event Handler button, 131 submenus, 37, 109, 112, 115–116 Find it faster at http://superindex.apress.comFind it faster menu handlers, 124, 220, 233 triggering commands, 123, 125 menu headings, 122 View menu, 37 menu items, 103, 105 Window menu, 37 menu system, 103, 179 Message, MessageDialog, 217 MenuBar control, 99 MessageDialog class, 76, 216–218, 231, 263, 267–268 MenuBar Editor, 130–131, 157, 179, 202, 233 MessageDialog object, 217 MenuBar items, 104 MessageDialogButton class, 217 MenuBar1 item, 22 Metal window, 74 MenuHandlerName placeholder, 126 Method Name field, 235 MenuItem Name drop-down list, 204, 237 methods MenuItem Name field, 132, 157, 263 modules, 222–223 MenuModifier property, 120–121 parameters, 227–228 menus, 105 windows, 226, 228, 230, 235 accelerator keys, 118, 121, 123 Microsoft ActiveX controls, 95–96 adding a new menu bar, 108–109 , 83, 89, 94 Apple and Macintosh menu customizing, 128 Mid function, 145 autoenable, 126 Mid string manipulation function, 145 Bookmarks menu, 37 MIDI, 305 converting menu items to menus, 127 migrating from Visual Basic disabling menu items, 126 Conversion Utility, 349–350 Edit menu, 37 differences, 348–349 example word processor application, importing Visual Basic projects, 349 263–268 overview, 347 File menu, 37 preparation, 349 Help menu, 37 Mile, 95 History menu, 37 MinimizeButton control, 100 366 ■INDEX

Modal Window, 70 number guessing application, 176, 178–179, module scope, 222 181, 183–184, 186 modules, 220–222 numeric data types, 140 Monkeybread plug-in controls, 95 ■O Mouse Move drag event, 184 object binding, 289 MouseMove event handler, 228 Object class, 210 Movable Modal Window, 69–70 ObjectName, 140 movie player application, 200, 202–204, object-oriented programming (OOP), 6, 209 206–207 advantages, 210 MoviePlayer control, 86, 200–201, 205, 301 classes, 209, 215–216 Mozilla browser, 58 control objects, 209, 211–212 MP3 Player application, 317, 319–321 events, 218–220 MPEG video files, 200, 202–204, 206–207 instantiation, 209, 211, 215–216 MsgBox function, 76, 133, 157, 165, 197, 216 menu handlers, 220, 233 multidimensional arrays, 147 modules, 220–222 multiline input, 82 noncontrol classes, 209–210 Multiline property, EditField control, overview, 209 253, 304 REALbasic 2006 standard edition, 11 multiplatform application creation, REALbasic 2006 professional edition, 12 windows, 225–226 multiple line If … Then blocks, 165 OLEContainer control, 86 multiple operating systems (OSs), 117 Online Support web page, 234 MyTestDB database, 291 OOP. See object-oriented programming Open dialog, 177, 205 ■ N Open dialog window, 245, 247–248, 264 Name property, 156, 204, 221, 225 Open event, 181, 203 Network Connection Checker, 338 Open event handler, 237, 269–270, 313, 335 network connection checker application, Open file dialog window, 245 338–343 Open menu item, 218 NetworkInterface object, 338–339 Open subroutine, 227 NetworkInterfaceCount property, 338 OpenAsSound method, 303 New keyword, 150, 182 OpenAsTextFile method, 251 New Project dialog, 43 OpenDialog class, 247–248, 254 NewChanges property, 265 OpenImage method, 236 NextPage method, Graphic class, 257 OpenPrinter function, 258 Not operator, 175 OpenPrinterDialog function, 256, 267 NotePlayer class, 307 OpenStyledEditField method, 253, 264 NotePlayer control, 86, 301, 305–309 OpenStyledEditField method, FolderItem notes, 136 class, 253 null array, 148 operator precedence, 174 ■INDEX 367 operators, 348 platform-specific application creation, Optional keyword, 231 REALbasic 2006 standard edition, 12 Options menu item, 325–326 Play method Options window, 325 MoviePlayer control, 206 OptionsMediaPlayer menu item, 206 Sound class, 302–303, 320 OptionsQuickTime menu item, 204, 206 PlayerType property, MoviePlayer control, 206 Or operator, 175 PlayLooping method, Sound class, 302, 320 OS compatibility, Linux, 10 PlayNote method, 307 OS specific conditions, 171–172 plug-ins, 95, 274 OutOfBoundsException error, 336, 341 plus (+) button, 287 OutOfMemoryException run-time error, 327 plus (+) character, 158 Oval control, 87 PopupArrow control, 88 PopupMenu control, 81, 88, 191

■P at http://superindex.apress.comFind it faster porting, 9 Page Setup dialog, 255–258, 267 PowerPointApplication control, 89 Page Setup settings, 263 prebuilt program code, 209 PagePanel control, 87 predefined constants, 226 Paint event, 313 predefined properties, 226 Pan method, Sound class, 302 Preferred player, 203 parameter line, 227 PrefsMenuItem value, 128 parameters preventing programming errors, 324 default values, 230 Primary key, 279 methods, 227–228 Print dialog, 255–258 Parameters field, 230 PrinterSetup object, 266–267 Parent property, FolderItem class, 246 printing Pause button, Debugger toolbar, 333 files, 255–258 pbnAdd PushButton, 299 styled text, 258 pbnMute control, 320 PrintSettings object, 267 pbnPlay control, 320 Professional version features, 12–13 pbnStop control, 320 Professional versus Standard REALbasic, 10 PCAltKey property, 121 program code, 29, 187 PersonalBookDB database, 292 ProgressBar control, 89, 194, 209 PersonalBookDB item, 299 ProgressWheel control, 89 picture viewer application, 231, 233–238 Project Controls option, 214 pitch integer, 307 Project Editor, 42–45, 76, 201, 212, 221, 232, pixel, 85 244, 277, 283 Pixel property, 313 Project menu, 37 Placard control, 88 Project screen, 221, 225, 234, 275 Plain Box Window, 71 Project tab, 32, 64 368 ■INDEX

Project Templates folder, 44 rapid release online distribution model, 8 projects, 5 RB Book Database application, 292 Projects screen, 99 RB Movie Player application, 200, 202–204, PromptText property, 248 206–207, 301 properties, 61, 140 RB MP3 Player application, 317, 319–321 assigning values, 140–141 RB Number Guess application, 176, 178–179, 181, 183–184, 186 controls, 26–28, 78 RB Picture Viewer application, 231, 233–238 Me keyword, 141 RB Word Processor, 258, 262 modules, 222 RB Word Processor application, 172, overview, 140 259–260, 262–272, 294–296, 298–299 retrieving values, 141–142 Rb3Dspace control, 90 Self keyword, 141 RBBookFinder Browser application, 57–59, windows, 226 61–64 Properties pane, 26, 46, 61, 78, 221, 225 RBCalculator application, 140, 154, 156–161 property comments, 137 RBClock application, 98–101 Property Sheet, 214 RBClock desktop clock application, 98 PropertyName, 140, 142 RBQuickNote application, 129–133 Protected level, 222 RbScript control, 90 protected module scope, 222 RBVersion constant, 151, 171 prototyping, 6 ReadAll method, TextInputStream Public level, 222 method, 251 public module scope, 222 reading text files, 250–251 public-level scope, 180 ReadLine method,TextInputStream, 250–251 PushButton control, 6, 23, 28–29, 50, 60, ReadOnly property, 27, 100 62–63, 87, 90, 99–100, 112, 141, 154, REAL Software website, 18 157–158, , 163, 166, 177, 184, 196, 210, REALbasic 218–219, 225, 261, 268, 309, 318 advantages, 5 ■Q versus Apples XCode, 16 queries, 283, 285, 287 compiling, 32–33 Query button, 284, 296 cross-platform compatibility, 6 QuickTime, 86, 203–204, 305 data types, 139–140 Quit option, 119 defined, 3 ■ demo version, 12 RAD (rapid application development), 6 development/execution platform, 8 RadioButton control, 78, 83, 90, 166–167 documentation, 52–53, 56 Random class, 176 download distribution, 13 random numbers, 230 executable files, 32–33 Random object, 182, 185 Intel Macintosh, 9 rapid application development (RAD), 6 language reference, 54 ■INDEX 369

Linux, 10 Resizable property, 61 Macintosh, 8 Resume button, Debugger toolbar, 333 major components, 4 RGB color model, 312 migrating from Visual Basic, 347 Rounded Window, 72 multiple projects, 7 RoundRectangle control, 91 operators, 173–175 royalty-free deployment, 12 Professional version features, 12–13 Rtrim function, 145 purchasing, 13 Rtrim string manipulation function, 145 REALbasic, 7 Run Event Handler, 294 remote debugging, 8 Run icon, 26, 60, 63 reserved keywords, 154 Run menu, Main toolbar, 38 software keys, 14 Run screen, 330 SQLite database, 8 RunQuery method, DatabaseQuery Find it faster at http://superindex.apress.comFind it faster stand-alone applications, 4 control, 289 Standard version features, 11–12 run-time errors, 327–328, 334 Standard versus Professional version, 10 ■S support services, 17, 19 SampleReport.doc, 244 testing an application, 30 sampling, 348 timeline, 5 SaveAsDialog class, 254–255 upgrade schedule, 8 SaveStyledEditField method, 253, 264 vs. Visual Basic, 9, 14–15, 348–349 schemas, 277 Windows, 9 scope of variables, 143–144 REALbasic Feedback, 53 screen area components, 41 REALbasic plug-ins folder, 95 screens, 42 REALbasic Plugins Web ring, 95 ScrollBar control, 91 REALbasic project, 212 Search menu, Main toolbar, 38 REALSQLDatabase class, 275 securing source code, 76–77 REALSQLDatabase object, 276 SelChange event handler, EditField Rectangle control, 90 control, 269 RectControl class, 209 Select … Case block, 169, 171 Redim statement, arrays, 148 SELECT keyword, 287–288 reduced code maintenance, 211 Select … Case statement, 164 RefreshDisplay( ) method, 340–341 SelectFolder function, 249 REM keyword, 135 SelectFolderDialog class, 249, 254 remote debugging, 8 Self keyword, 141 Remove method, arrays, 149 SelTextFont property, EditField control, 253 removing menu and menu items, 128 SelTextSize property, EditField control, 253 Replace string manipulation function, separator bars, 105, 118–119 145–146 Separator control, 91 370 ■INDEX

Serial control, 92 stand-alone applications, 4 ServerSocket control, 92–93 Standard version features, 11–12 Shadowed Box Window, 72 Standard versus Professional REALbasic, 10 Sheet Window, 73 StandardToolbarItem control, 93 shortcuts starting REALbasic, 35 for creating loops, 197–198 statement parameters, 324 menus, 118, 120–121 statements, 164, 188 Show Control Order button, Windows Editor StatesListBox class, 214 toolbar, 98 StaticText control, 24, 27, 62, 77, 93, 177, 296, Show method, windows, 226 298, 308, 318 ShowModal, MessageDialog, 218 Step button, Debugger toolbar, 333 ShowModalWithin, MessageDialog, 218 Step In button, Debugger toolbar, 333 SimpleText application, 243 Step keyword, 195 single dimensional array, 147 Step Out button, Debugger toolbar, 333 single line If … Then statement, 165 Step value, 194 single-line input, 82 stepping program execution, 333 Slider control, 92, 176–177, 182–184, 318 stickypad application, 129–133 smaller applications, 211 Stop button, Debugger toolbar, 333 software keys for REALbasic development Stop method system, 14 MoviePlayer control, 206 Sort Data window, 286 Sound class, 302 Sort Order field, 286 Str data type conversion, 145 Sound class, 301–304, 319 Str function, 145 sound effects, 301 strCustomerArray array, 335 SoundFile object, 320 strCustomerName variables, 170 source code, 238 string comparisons, 173 Speak method, 301, 304 string manipulation, 145–146 speak method, audio, 301, 304–305 strMessage variable, 197 special folders, 247 strNamesDictionary object, 150 SpecialFolder object, 247 strPrintSettings variable, 256 SpotlightQuery control, 92 strSampleMsg variable name, 146 sprite, 92 Structured Query Language (SQL), 274, SpriteSurface control, 92 287–288 SQL (Structured Query Language), 274, strUserName, 165 287–288 strWishListArray property, 196 SQLExecute method, 281–283 Styled property, EditField control, 252–253 SQLite database, 8 styled text, 243, 252–253, 258 SQLQuery property, 289 StyledTextPrinter class, 258, 266 Stack list, debugging, 330 subcategories, 55 ■INDEX 371 subclasses, 210 SaveAsDialog class, 254–255 submenus, 105, 109, 112, 115–116 SaveStyledEditField method, 253 subroutine, 183, 227 styled text, 252–253, 258 , 227–228 writing files, 252 Super Class, 211, 220 Text properties, 157 Super property, 128 Text property, 27, 123 support for REALbasic, 17, 19 TextAlign property, 28 Support page, REAL Software website, 18 TextColor property, 27 SupportWindow, 225 TextFont property, 269 syntax errors, 324–326 TextInputStream, 250–251 System object, 338 TextOutputStream object, 252 ■T TextPhrase placeholder, 304 TextSize property, 100, 269 tab order for controls, 97 at http://superindex.apress.comFind it faster TextTypes variable, 204 TableName property, 291 TextWindow variable, 264 TabPanel control, 93 Then keyword, 165 Tabs bar, 41 Thread control, 94 TabSocket control, 93 Timer control, 77, 94, 99 TargetBigEndian OS specific condition, 171 Tips bar, 51–52 TargetCarbon OS specific condition, 172 Title, MessageDialog, 217 TargetFile, 246 Title property, 26, 233, 248, 308 TargetHasGUI OS specific condition, 171 ToolbarItem control, 94 TargetLinux OS specific condition, 172 toolbars, 38–39 TargetLittleEndian OS specific condition, 172 Top property, 248 TargetMachO OS specific condition, 172 trapping errors, 333–337 TargetMacOS OS specific condition, 172 trigger command, 114 TargetMacOSClassic OS specific condition, 172 triggering commands with menus, 123, 125 TargetWin32 OS specific condition, 172 Trim function, 145 TCPSocket control, 77 Trim string manipulation function, 145 Terminal window, 296 Try - Catch blocks, 337 text file processing Try block, 337 file type set, 244–245 Try keyword, 337 GetSaveFolderItem function, 254–255 TypeMismatchException run-time error, 327 Graphics object, 256–258 OpenStyledEditField method, 253 ■U overview, 243 Ubound function, 148 printing files, 255–258 UDPSocket control, 94 printing styled text, 258 Until keyword, 189 reading files, 250–251 Update Database records window, 288 372 ■INDEX

UpDownArrows control, 94 ■W Uppercase function, 145–146 web browser application, 57–59, 61–64 URLSite window, 237 web server development enhancements, 12 user interface While … Wend loop, 188, 192–193 design, 59–60, 67–70, 72, 75–76 Window Code editor, 319 windows, 67–70, 72, 75–76 Window Editor, 11, 45, 47, 59, 157 ■V Window Layout view, 181 Window menu, 37 Val data type conversion, 145 windows, 10 Val function, 145 adding, 68, 225 Value keyword, 193 backgrounds, 310, 313 Value property, 194 constants, 226, 233, 235 ValueChanged event handler, 321 displaying, 225 Van Hoek Software, 95 methods, 226, 228, 230, 235 Varchar data type, 282 overview, 225 variable declaration, 348 properties, 226 variables, 180 REALbasic choices, 68 defined, 138 user interface design, 68 naming, 143, 348 Windows Editor, 42, 97, 99, 181 syntax rules, 142 Windows Layout view, 203 Variables pane, debugging, 330, 332 Player, 86, 203–204 velocity integer, 307 Windows operating system, hardware verifying file or folder existence, 249 requirements, 9 vertical alignment indicators, 96–97 Windows property, EndOfLine class, 216 View As drop-down list, 39 Windows1 item, 22 View menu, 37 WindowsAppName property, 64 visible and invisible controls, 77 word processor application, 259–260, Visual Basic background, 80 262–272, 294–296, 298–299 Visual Basic Project Conversion utility, 349 WordApplication control, 94 Visual Basic vs. REALbasic, 9, 14–15 WriteLine method, TextOutputStream Volume function, 246 object, 252 Volume method, Sound class, 302 writing text files, 252 Volume property, 321 ■Y Year property, 216