REALbasic Cross-Platform Application Development

Book description

REALbasic Cross-Platform Application Development treats REALbasic as a serious development environment and is targeted to developers with a minimum of programming experience, but who may or may not be new to the REALbasic platform. Written by a writer and developer with extensive REALbasic experience with input and guidance from REAL Software, this book will show you how to take advantage of the new cross-platform abilities of REALbasic and teach you how to create cross-platform applications. Don't waste any more time with the other novice-oriented REALbasic books out there. Get inside this development environment with REALbasic Cross-Platform Application Development.

Table of contents

  1. Copyright
  2. About the Author
  3. Acknowledgments
  4. We Want to Hear from You!
  5. Reader Services
  6. Introduction
    1. Chapter 1, Introduction to REALbasic
    2. Chapter 2, Programming with REALbasic
    3. Chapter 3, Classes and Objects
    4. Chapter 4, Cross-Platform Application Development
    5. Chapter 5, Designing a Desktop Application
    6. Chapter 6, XML and Advanced Text Processing
    7. Chapter 7, Console Programming and the Shell
    8. Chapter 8, Databases
    9. Chapter 9, Networking and Internet Programming
    10. Chapter 10, Graphics
    11. Chapter 11, Scripting and Extending REALbasic
    12. Appendix
  7. 1. Introduction to REALbasic
    1. What’s New in REALbasic 2005
    2. Deciding if REALbasic Is Right for You
    3. Strengths and Weaknesses
    4. Who Should Read This Book
    5. What You Can Expect
  8. 2. Programming with REALbasic
    1. Defining a Computer Program
    2. REALBasic Terminology
    3. Quick Start: A Simple Web Browser
      1. Controls
      2. Events
      3. Run Your Application
    4. Procedural Programming in REALbasic
      1. Statements and Declarations and Comments
      2. Expressions: Operands and Operators
      3. Variables and Literals
      4. Intrinsic Data Types
      5. Declaration
      6. Variables and Constants
        1. Scope
        2. Local Variables and Constants
        3. Global Variables (Module Properties) and Module Constants
        4. Scalar Variables and Reference Variables
      7. Arithmetic with Integers, Singles, and Doubles
        1. Integer
        2. Singles and Doubles
        3. Number Literals
        4. Coercion
        5. Mod Operator
        6. Boolean and Comparison Operators
          1. Boolean
          2. Comparison Operators
          3. Boolean Operators
      8. Strings
      9. Color
      10. Literals
      11. Visual Basic Data Types
        1. Byte (1 byte)
        2. Char (2 bytes)
        3. Long Integer (8 bytes) and Decimal (12 bytes)
        4. Date (8 bytes)
        5. User-Defined (Structure)
      12. Methods
        1. Functions
        2. Subroutines
      13. Arrays
        1. Declaring Arrays
        2. ReDim
        3. Ubound
        4. Insert, Append, and Remove
        5. Pop
        6. IndexOf
        7. The Array Function
        8. Assignment by Reference
        9. Multidimensional Arrays
        10. Sort and Shuffle
        11. Split and Join
        12. Using Arrays with Methods
    5. Flow Control—Conditionals
      1. If...Then
      2. If...Then...Else
      3. If...Then...Elseif...Then
      4. Select Case
    6. Flow Control—Loops
      1. Do...Loop
      2. Do...Loop Until
      3. Do Until...Loop
      4. For Each...Next
      5. For...Next...Step
        1. Moving Up and Down: To and DownTo
        2. Skipping Rows: Step
      6. While...Wend
      7. Using Loops
      8. Nesting Loops
    7. Variants
      1. Variants and Operators
      2. Properties
      3. Methods
      4. VarType
      5. When to Use Variants
    8. Modules
      1. Built-in Modules
      2. Built-in Math Functions
        1. Trigonometry
        2. Log, Exp
        3. isNumeric
        4. Abs, Sign
        5. Max and Min
        6. Round (Not to Be Confused with Rnd, Which Generates a Random Number)
        7. Ceil
        8. Val, CDbl
        9. Pow, Sqrt
        10. Bin, Hex, Oct
      3. Built-in String Functions
        1. StrComp
        2. InStr, InStrB
        3. Mid
        4. Left
        5. Right
        6. Asc
        7. Chr
        8. Len
        9. Str, CStr
        10. Format
        11. Trim, RTrim, LTrim
        12. UpperCase, LowerCase, TitleCase
        13. CountFields
        14. NthField
    9. Creating the StringParser Module
      1. Create a New Project
      2. Creating a Module
      3. Access Scope
        1. Global
        2. Protected
        3. Private
      4. Constants
      5. Properties
      6. Adding a Method
      7. Adding the “Split” Method
    10. Summary
  9. 3. Classes and Objects
    1. The Class Hierarchy
    2. Creating a New Class
    3. Declaration and Instantiation
    4. Constructors and Destructors
    5. Garbage Collection
    6. Inheritance
    7. Object Operators
    8. Adding and Overriding Methods
    9. Calling the Overridden Method
    10. Overloading
    11. Casting
    12. Oddities
    13. Encapsulation
    14. Access Scope: Public, Private, Protected
    15. Setting Properties with Methods
    16. Default and Optional Parameters
    17. Declaring Variables Static and Const
      1. Const
      2. Static
    18. Revisiting the StringParser Module
      1. The Dictionary Class
      2. The Properties File Format
        1. Dictionary Properties
        2. Dictionary Methods
    19. Example: Creating a Properties Class
      1. Properties.Constructor
      2. Properties.get
      3. Properties.set
      4. Properties.parsePropertyFile
      5. Properties.parseLine:
    20. Data-Oriented Classes and Visual Basic Data Types
      1. Date Class
        1. ParseDate Function
        2. Date Properties
      2. MemoryBlock Class
        1. The NewMemoryBlock Function
        2. MemoryBlock Properties
        3. MemoryBlock Methods
          1. MemoryBlock.Cstring, MemoryBlock.Pstring, MemoryBlock.Wstring, MemoryBlock.Ptr:
          2. Example: Mimicking a Structure with a MemoryBlock
      3. Collection Class
        1. Collection Methods
    21. Advanced Techniques
      1. Interfaces and Component-Oriented Programming
        1. Interfaces in REALbasic
        2. ReadableTextInputStream Methods
        3. ReadableTextInputStream Properties
        4. ReadableString Methods
        5. ReadableString Properties
      2. Custom Operator Overloading
        1. Special Operators
          1. Function Operator_Lookup(aMemberName as String) as Variant
          2. Function Operator_Compare(rightSideOperand as Variant) as Double
          3. Function Operator_Convert() as Variant
          4. Sub Operator_Convert(rightSideOperand as Variant)
        2. Addition and Subtraction
          1. Operator_Subtract(rightSideOperand as Variant) as Variant, Operator_SubtractRight(leftSideOperand as Variant) as Variant
        3. Boolean
          1. Operator_And(rightSideOperand as Variant) as Boolean, Operator_AndRight(leftSideOperand as Variant) as Boolean, Operator_Or(rightSideOperand as Variant) as Boolean, Operator_OrRight(leftSideOperand as Variant) as Boolean
        4. More Operator Overloading
      3. Extends
        1. Unix Epoch
      4. Conclusion
  10. 4. Cross-Platform Application Development
    1. That Other Cross-Platform Language
      1. AWT
      2. Swing
      3. SWT
    2. Compiling REALbasic Applications
      1. A Note About UNIXlike Systems
      2. The RSS Reader Application
      3. Compiling Applications
        1. Windows
        2. Macintosh
        3. Linux
    3. Configuring the Compiler
      1. Next Steps
    4. The App Class
      1. App Properties Pane
        1. The ID Section
        2. The Appearance Section
          1. Default Window
          2. MenuBar
          3. Icons
        3. The Version Info Section
        4. The Windows Settings Section
          1. WindowsAppName
          2. MDI and MDI Caption
        5. Macintosh Settings
          1. MacAppName
          2. MacOSXAppName
          3. MacClassAppName
          4. MacCreator
          5. AcceptFileTypes
        6. The Linux Settings Section
        7. The Advanced Section
    5. Files and Directory Organization
      1. FolderItem Class
      2. Referencing a FolderItem: Paths and URLs
        1. Absolute Paths
        2. Getting a FolderItem
        3. Relative Paths
      3. How Folders and Files Are Organized
        1. Where Files Go
        2. User Directories
        3. Applications
        4. Documents
        5. Preferences
        6. Configuration Files
        7. Log Files
      4. File Types
        1. File Type Sets
      5. Volume and VolumeCount Functions
      6. Navigating the Directory Tree
      7. File Properties
      8. Permissions and File Access
        1. Properties
        2. Permissions Class
      9. Moving, Copying, and Deleting Files
        1. Extending FolderItem
      10. Opening, Creating, and Saving Files
    6. Compiler Directives
    7. User Interface Differences
      1. Desktops
      2. Windows: Taskbar
        1. TrayItem Class
      3. Macintosh: Dock
      4. Linux: Pane (KDE and Gnome)
      5. Keyboard
      6. Menu Bar
      7. Screen
    8. System Module
      1. Environment Variables
        1. System.Gestalt
      2. Line Endings
        1. EndOfLine Functions
          1. EndOfLine Properties
    9. Windows Registry
      1. HKEY_CLASSES_ROOT
      2. HKEY_CURRENT_USER
      3. HKEY_LOCAL_MACHINE
      4. HKEY_USERS
      5. HKEY_CURRENT_CONFIG
    10. RSSReader Preferences Example
      1. Exporting and Importing Items
      2. Creating the Preferences Class
    11. A Final Word About Macintosh
      1. Macintosh Bundles
    12. Summary
  11. 5. Designing a Desktop Application
    1. Integrated Development Environment
      1. IDE MenuItems
        1. File, New Project
        2. File, New Window
        3. File, Import/Export
        4. Project Menu
          1. View, Editor Only
          2. Main Toolbar
          3. The Editor Toolbar
          4. History
          5. Bookmarks
          6. Help
      2. Preferences
        1. Code Editor
        2. Window Editor
        3. Build Process
        4. Debugger
        5. Printing
      3. Find and Replace
    2. Desktop Applications: Programming Graphical User Interfaces
      1. Event-Driven Programming
      2. Controls and Events
      3. App Events
    3. Model-View-Controller
      1. Organizing Your Code
      2. The RSSReader Application
      3. Controller
        1. Class RSS Inherits Application
          1. RSS Properties
        2. iPreferences Interface
      4. The Model
        1. Data Access Layer
        2. iProvider Interface
        3. iWriter Interface
        4. iWritable Interface
        5. Class SubscribedFeeds
        6. Object Model
        7. Class: mwNode
        8. Interface: iSequence
        9. Class NodeSequence (Implements iSequence)
      5. Views
    4. Windows and Controls
      1. Simple Windows
        1. MsgBox
          1. Button Values
          2. Icons
          3. Default Button
        2. GetOpenFolderItem, GetSaveFolderItem...SelectFolder
        3. MessageDialog
        4. FolderItemDialog, SelectFolderDialog, OpenDialog, SaveAsDialog
      2. Editing Windows
      3. Global Window Functions
      4. Windows ID Properties
      5. Windows Position Properties
        1. Height, Width, MinHeight, MinWidth, MaxHeight, MaxWidth
      6. Windows Appearance Properties
        1. Window.Frame as Integer
          1. Document Window
          2. Modal Window and Movable Modal Window
          3. Floating Window
          4. Global Floating Window
          5. Plain Box
          6. Macintosh Sheet Windows
          7. Drawer Window
          8. Shadowed Box and Rounded Window
        2. Window.Composite as Boolean
        3. Window Colors and Backdrops
        4. Window.Title as String
        5. Visible as Boolean
        6. FullScreen as Boolean
        7. MenuBarVisible as Boolean
        8. CloseButton as Boolean
        9. Resizable as Boolean
        10. LiveResize as Boolean
        11. MaximizeButton as Boolean
        12. MacProcID as Integer
        13. MenuBar as MenuBar1
    5. Managing Windows
      1. Window States
        1. Hide, Show, Open, and Close
        2. Open, Close, and CancelClose Events
        3. EnableMenuItems Event
        4. Close, Minimize, and Maximize Methods
        5. Restore Method
      2. Mouse Position
        1. MouseX and MouseY Properties
        2. MouseDown, MouseUp Events
        3. MouseMove and MouseDrag Events
        4. MouseEnter, MouseExit Events
        5. Top, Left
    6. Controls
      1. The RectControl Class
        1. Top, Left, Height, and Width
        2. LockBottom, LockLeft, LockRight, and LockTop
        3. AutoDeactivate and Active
        4. Deprecated Properties
        5. Enabled
        6. Name
        7. Position - MouseX and Mouse Y
        8. Open and Close Events
        9. Sample Control: BevelButton
      2. Control Order and Control Arrays
      3. Drawing Guides
      4. Binding
      5. Pushbutton Control
        1. Button State
      6. TabPanel
      7. EditField Control
        1. Events
        2. Text and Positioning
        3. Data Entry
        4. Scrolling
        5. Setting Style Properties for All Text
        6. Alignment Constants
        7. Setting Style Properties on Selected Text
        8. StyledText
      8. ListBox
        1. Adding Rows
        2. Selecting Rows and Manipulating Cells
        3. Hierarchical ListBoxes
        4. ListBox Pictures
        5. Inserting and Removing Rows
        6. ListBox Drag and Drop
        7. Class mwNodeListBox Inherits from ListBox
      9. HTMLViewer Control
      10. HTTPSocket Control
      11. ProgressBar
    7. Exception Handling
      1. Runtime Exceptions
      2. Try...Catch...End/Finally
      3. Logging
      4. Debugger
        1. Step Over
        2. Step Into
        3. Step Out
        4. Pause
        5. Stop
        6. EditCode
    8. User Interface Response
      1. Timers
        1. Periodic Events with the Timer Control
          1. App.DoEvents
        2. Threads
        3. Class Window1 Inherits Window
        4. Class ThreadTester Inherits Thread
          1. Using Threads for Background Tasks
        5. Class tWriter Inherits Thread
    9. Menus and Menu Handlers
      1. Adding Menu Constants
      2. Adding the MenuItems
      3. Adding Menu Handlers
      4. Windows and MenuBars
    10. CustomTray
    11. Summary
  12. 6. XML and Advanced Text Processing
    1. Encoding
      1. UCS—Universal Character Set (UCS-2, UCS-4)
      2. UTF—Unicode Transformation Format (UTF-8, UTF-16, UTF-32)
      3. Byte Order Mark
      4. Converting Encodings
        1. TextEncoding Class
        2. Encodings Object
        3. DefineEncoding Function
        4. ConvertEncoding Function
      5. Base64 Encoding
      6. XML and HTML Entity Encoding
      7. Detecting Encoding in XML Documents
    2. XML Processing
      1. Document Node
      2. XMLDocument
        1. XMLNode Properties
        2. XMLNode Methods
        3. XML to HTML Transformation
      3. XMLReader
        1. Class rbXmlReader
          1. Input XML File
          2. Output
        2. State Management with XMLReader
      4. XML and Object Instantiation
    3. Regular Expressions
      1. RegEx Class
      2. RegExMatch Class
      3. RegExOptions Class
        1. Replacing Text
      4. Text Validation and Variable Substitution
      5. Variable Substitution in the Properties Class
    4. StyledText
      1. Apply Styles
        1. Window1 Inherits Window
    5. Summary
  13. 7. Console Programming and the Shell
    1. Sample Applications
    2. The Shell Class
      1. Shell Properties
        1. Synchronous Execution
        2. Asynchronous and Interactive Execution
      2. Shell Events
      3. Shell Methods
      4. Subclassing the Shell
        1. mwShell Inherits Shell
      5. Subversion
        1. SVNclient Inherits mwShell
      6. Ant Shell
        1. AntTargetView Inherits Window
    3. Developing Console Applications
      1. Transformer: Command-Line XML Transformation
        1. Class App
        2. Class mwArgHandler Inherits Dictionary
        3. Class mwTransformer
      2. CGI Application
        1. Class cgiRequest Inherits Dictionary
        2. Class cgiCookie
        3. Class cgiResponse
    4. Conclusion
  14. 8. Databases
    1. The No-Code Database
      1. DataControl
        1. Data Control Properties
        2. DataControl Methods
        3. DataControl Events
        4. Binding EditFields
        5. Binding PushButtons
      2. DatabaseQuery Control
    2. The Coded Database
      1. The Database Classes
        1. Database Class
          1. Database Properties
          2. Database Methods
        2. REALSQLdatabase
          1. REALSQLdatabase Properties
          2. REALSQLdatabase Methods
        3. RecordSet
          1. Properties
          2. Methods
        4. DatabaseRecord
          1. DatabaseRecord Properties
        5. DatabaseField
        6. The Coded Application
        7. RowID
    3. SQL Equivalents
      1. Delete Statement
      2. Insert Statement
      3. Update Statement
      4. Creating Indexes
      5. Select and Joins
        1. Data Normalization
        2. Inner/Outer Joins
        3. Primary Key
      6. Trigger
    4. Conclusion
  15. 9. Networking and Internet Programming
    1. A Simplified View of a Computer Network
      1. The Hypertext Transfer Protocol
      2. URLs, Domain Names, and Hosts
      3. Ports
      4. IP Addresses
    2. The Protocol Stack
    3. The Internet
      1. Network Layer
      2. Transport Layer
      3. Application Layer
    4. REALbasic Networking Classes
    5. Network Object
    6. Network Interface Class
    7. System Members
    8. TCP and UDP Networks
      1. SocketCore Class
      2. Sending and Receiving Data
      3. SocketCore Properties
        1. SocketCore Methods
      4. TCPSocket
        1. TCPSocket Events
          1. TCPSocket Methods
        2. HTTPSocket Inherits TCPSocket
          1. Authentication
          2. Get, Post, and GetHeaders Methods
        3. InternetHeaders Class
      5. From CGI to HTTPServer
        1. ServerSocket Class
      6. The HTTPServer Application
        1. Class HTTPServer Inherits ServerSocket
        2. Handling GET Requests
        3. Control Window1.PushButton1:
      7. Handling POST Requests: Posting Forms and Transferring Files
      8. Uploading a File
        1. Class HTTPConnection Inherits TCPSocket
        2. Class HTTPRequest Inherits Dictionary
        3. SSLSocket
    9. IPCSocket Class
      1. IPCSocket Class
    10. UDPSocket
      1. UDPSocket Class
        1. Properties
          1. Methods
        2. Datagram
    11. Conclusion
  16. 10. Graphics
    1. Raster and Vector Graphics
      1. The Graphics Class
        1. Properties
        2. Graphics Methods
    2. Picture Class
      1. FolderItems and Pictures
      2. Creating a Picture
      3. Handling Transparencies
      4. Creating and Manipulating Pictures
      5. More Picture Properties
      6. RGBSurface Class
    3. Canvas Control
      1. Canvas Properties
      2. Canvas Events
    4. The Canvas Control—Scrolling Text and Images
    5. Object2D Class
      1. PixmapShape
      2. RectShape
      3. RoundRectShape Inherits RectShape
      4. OvalShape Inherits RectShape
      5. ArcShape Inherits OvalShape
      6. StringShape
      7. CurveShape
      8. FigureShape
      9. Group2D
        1. A FigureShape Example
    6. Printing with REALbasic
      1. StyledTextPrinter
    7. Summary
  17. 11. Scripting and Extending REALbasic
    1. Scripting
      1. RBScript
        1. RBScript Object
        2. Web Server Scripting
      2. Office Automation
        1. OLEObject
        2. OLEParameter
        3. OLEParameter Class Type Constants
        4. OLEContainer Control
        5. ActiveX
        6. Handling Events
        7. OLEException
        8. WordApplication Class
        9. Documents Collection
          1. Documents.ActiveDocument as Document
          2. Documents.Add as Document
          3. Documents.Open(aPath as String)
          4. Documents.Close
          5. Document.Save
          6. Documents.SaveAs
    2. Extending REALbasic
      1. Declares
        1. Windows
        2. Macintosh
        3. Linux
        4. Online Documentation
      2. Plug-ins
        1. Third-Party Plug-ins
          1. MonkeyBread Software (http://monkeybreadsoftware.de)
          2. Einhugur (http://einhugur.com/)
          3. Valentina (http://paradigmsoft/)
      3. Component X Graphics (http:/ / www.componentx.com/ CXGraphics/ )
        1. FTPSuite for REALbasic (http:/ / www.pyramiddesign.us/ ftpsuite/ index.html)
    3. Summary
  18. A. Appendix
    1. Sample Code and Application
    2. GNU General Public License
      1. Preamble
    3. Terms and Conditions for Copying, Distribution, and Modification
    4. How to Apply These Terms to Your New Programs
    5. GNU Lesser General Public License
      1. Preamble
    6. Terms and Conditions for Copying, Distribution, and Modification
    7. How to Apply These Terms to Your New Libraries
    8. Online Resources

Product information

  • Title: REALbasic Cross-Platform Application Development
  • Author(s):
  • Release date: April 2006
  • Publisher(s): Sams
  • ISBN: 0672328135