Palm
™
D
e
v
201 West 103rd Street Indianapolis, Indiana 46290
e
l
o
p
m
e
n
t
Clayton Crooks
Publisher
Palm™ Development
David Culverwell
Copyright © 2002 by Que Publishing
Acquisitions Editor
All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein.
Loretta Yates
Palm OS, Palm Computing, HandFAX, HandSTAMP, HandWEB, Graffiti, HotSync, iMessenger, MultiMail, Palm.Net, PalmPak, PalmConnect, PalmGlove, PalmModem, PalmPoint, PalmPrint, and PalmSource are registered trademarks of Palm, Inc. Palm, the Palm logo, MyPalm, PalmGear, PalmPix, PalmPower, AnyDay, EventClub, HandMAIL, the HotSync logo, PalmGlove, Palm Powered, the Palm trade dress, Smartcode, Simply Palm, WeSync, and Wireless Refresh are trademarks of Palm, Inc.
Benjamin Berg
International Standard Book Number: 0-7897-2649-1
Bryan Morgan
Library of Congress Catalog Card Number: 2002102857
Team Coordinator
Development Editor Bryan Morgan
Managing Editor Thomas Hayes
Project Editors Tricia Liebig Karen Shields
Production Editor Indexer Sandy Henselmeier
Proofreaders Bob LaRoche Cindy Long
Technical Editor
Cindy Teeters Printed in the United States of America First Printing: April 2002 05
04
03
02
Interior Designer Karen Ruggles
4
3
2
1
Cover Designer Duane Rader
Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Que cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.
Warning and Disclaimer Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an “as is” basis. The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book.
iii
Contents at a Glance 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Introduction to the Palm Pilot . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Overview of Palm OS Development Tools . . . . . . . . . . . . . . . . . . .18 POSE—The Palm OS Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . .34 Basics of Satellite Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46 Your First Palm Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56 Satellite Forms Database Applications . . . . . . . . . . . . . . . . . . . . .76 Advanced Satellite Forms Database Development . . . . . . . . . . . . .98 Introduction to AppForge: Visual Basic for the Palm OS . . . . . . .116 Beginning AppForge Programming: A Calculator Example . . . . .132 Database Programming with AppForge . . . . . . . . . . . . . . . . . . . .146 Using Additional AppForge Ingots . . . . . . . . . . . . . . . . . . . . . . . .156 Introduction to PDA Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162 The Travel Database Application . . . . . . . . . . . . . . . . . . . . . . . . .168 CodeWarrior for Palm OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178 Creating Applications with CodeWarrior . . . . . . . . . . . . . . . . . . .188 Java Virtual Machines for the Palm OS . . . . . . . . . . . . . . . . . . . .200 Programming Waba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206
Appendixes A Important Web Sites for Palm OS Developers B Satellite Forms Controls Properties . . . . . . . . C Standard Naming Conventions . . . . . . . . . . . Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
.216 .220 .228 .234
Table of Contents 1
2
Introduction to the Palm Pilot . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Overview of the Palm Operating System (OS) . . . . . . . . . . . . . . . . .4 Hardware Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 Keyboard, or Lack Thereof . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 Battery Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 Processing Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 Small Screens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 Limited Memory and Storage Capacity . . . . . . . . . . . . . . . . . .7 Common Usage Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 Hardware Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 Types of Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Traditional Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Web Clipping Applications . . . . . . . . . . . . . . . . . . . . . . . . . . .12 Conduits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 New Features in Palm OS 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14 Secondary Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14 Telephony . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 Bluetooth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 Web Clipping Improvements . . . . . . . . . . . . . . . . . . . . . . . . .15 Direct Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16 Tool Improvements in the Software Developers Kit (SDK) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 What’s Next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Overview of Palm OS Development Tools . . . . . . . . . . . . . . . . . . .18 Palm SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20 CodeWarrior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20 PRC-Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 On-Device C Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . .22 Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 VisualAge Micro Edition . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 Sun’s Java 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 Waba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
3
4
Basic Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . NS Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . AppForge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Building Database Applications . . . . . . . . . . . . . . . . . Satellite Forms . . . . . . . . . . . . . . . . . . . . . . . . . . Pendragon Forms . . . . . . . . . . . . . . . . . . . . . . . . IBM DB2 Everyplace . . . . . . . . . . . . . . . . . . . . . FileMaker Mobile . . . . . . . . . . . . . . . . . . . . . . . . PDA Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . Working with Spreadsheets and Flat File Databases Miscellaneous Tools . . . . . . . . . . . . . . . . . . . . . . . . . . Assembly Language Tools . . . . . . . . . . . . . . . . . CASL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PRC Editing Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Forth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Smalltalk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pascal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . What’s Next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . POSE—The Palm OS Emulator . . . . . . . . . . . . . . . . . Using POSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Setting Up POSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . Obtaining ROMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using POSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Loading an Application into POSE . . . . . . . . . . . . . . . Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Basics of Satellite Forms . . . . . . . . . . . . . . . . . . . . . . The App Designer (IDE) . . . . . . . . . . . . . . . . . . . . . . . Setting Application Properties . . . . . . . . . . . . . . . . . . Built-In Components . . . . . . . . . . . . . . . . . . . . . . . . . Database Connectivity . . . . . . . . . . . . . . . . . . . . . . . . Basics of Relational Databases . . . . . . . . . . . . . Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. .25 . .26 . .26 . .27 . .27 . .28 . .28 . .29 . .29 . .30 . .30 . .30 . .31 . .31 . .32 . .32 . .32 . .32 . .32 . .32 . .34 . .36 . .38 . .39 . .42 . .44 . .44 . .46 . .48 . .49 . .50 . .53 . .53 . .54
vi
5
6
7
8
Your First Palm Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56 Building Your First Application . . . . . . . . . . . . . . . . . . . . . . . . . . .58 The Satellite Forms Development Process . . . . . . . . . . . . . . .58 Satellite Forms Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 HotSyncing with POSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64 Downloading to Satellite Forms . . . . . . . . . . . . . . . . . . . . . . . . . . .71 Troubleshooting POSE with Satellite Forms . . . . . . . . . . . . . . . . .73 Downloading to a Live Device . . . . . . . . . . . . . . . . . . . . . . . . . . . .74 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74 Satellite Forms Database Applications . . . . . . . . . . . . . . . . . . . . .76 Creating the Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78 Navigating the Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80 Creating a Palm Database Using Satellite Forms . . . . . . . . . . . . .82 Creating Tables in the Database . . . . . . . . . . . . . . . . . . . . . .83 Creating Additional Tables . . . . . . . . . . . . . . . . . . . . . . . . . . .85 Creating the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88 Adding Control Buttons to Our Forms . . . . . . . . . . . . . . . . . .92 Testing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96 Advanced Satellite Forms Database Development . . . . . . . . . . . . .98 Creating the Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100 Creating Tables for the Application . . . . . . . . . . . . . . . . . . . . . . .101 Creating the frmTime GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 Database Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104 Building the Search Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107 Testing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112 Integrating with a Desktop Database . . . . . . . . . . . . . . . . . . . . . .114 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115 Introduction to AppForge: Visual Basic for the Palm OS . . . . . . .116 Installing AppForge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118 The Visual Basic IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118 Primary IDE Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120 The Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120 Individual Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121 The Form Editor Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . .121
vii
Primary IDE Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123 The Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123 The Form Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126 The Code Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127 The Project Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127 The Properties Window . . . . . . . . . . . . . . . . . . . . . . . . . . . .128 Form Layout Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128 AppForge-Specific Menu and Toolbars . . . . . . . . . . . . . . . . . . . . .130 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131 9 Beginning AppForge Programming: A Calculator Example . . . . .132 Creating the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134 Creating a GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134 Handling GUI Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139 Supporting Negative Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . .140 Working with Decimal Values . . . . . . . . . . . . . . . . . . . . . . . . . . .141 TAN Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141 Add, Subtract, Multiply, and Divide . . . . . . . . . . . . . . . . . . . . . . .141 Calculating the Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .143 Testing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .145 10 Database Programming with AppForge . . . . . . . . . . . . . . . . . . . .146 Constructing the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148 Designing the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . .149 Creating the Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .152 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .154 11 Using Additional AppForge Ingots . . . . . . . . . . . . . . . . . . . . . . . .156 Creating the Illusion of Spinning . . . . . . . . . . . . . . . . . . . . . . . . .160 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161 12 Introduction to PDA Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162 The PDA Toolbox GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164 Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164 Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .167
viii
13 The Travel Database Application . . . . . . . . . . . . . . . . . . . . . . . . .168 Creating the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170 Create a Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171 Adding Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172 Synchronizing Data with the Desktop . . . . . . . . . . . . . . . . . . . . .175 Chapter Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177 14 CodeWarrior for Palm OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180 Running CodeWarrior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180 Alternatives to CodeWarrior . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180 Setting Up an Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180 Running the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .182 Changing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184 Creating a Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .185 Changing Display Name and Icon . . . . . . . . . . . . . . . . . . . .185 Chapter Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .187 15 Creating Applications with CodeWarrior . . . . . . . . . . . . . . . . . . .188 Overview of New Application . . . . . . . . . . . . . . . . . . . . . . . . . . . .190 Writing Some Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .193 Application Launching . . . . . . . . . . . . . . . . . . . . . . . . . . . . .194 AppHandleEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .195 Chapter Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198 16 Java Virtual Machines for the Palm OS . . . . . . . . . . . . . . . . . . . .200 The Choices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202 Sun’s KVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202 Kawt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202 IBM’s J9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203 Waba/SuperWaba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203 Discontinued But Still Valuable . . . . . . . . . . . . . . . . . . . . . .203 Chapter Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .204 17 Programming Waba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206 Sun’s Java SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .208 Waba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209 Visual Waba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209 Creating an Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211 Chapter Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .215
ix
Appendixes A Important Web Sites for Palm OS Developers B Satellite Form Controls Properties . . . . . . . . . Properties Common to All Controls . . . . . . . . Properties Common to Most Controls . . . . . . . Specific to Individual Controls . . . . . . . . . . . . Auto Stamp . . . . . . . . . . . . . . . . . . . . . . Bitmap . . . . . . . . . . . . . . . . . . . . . . . . . . Button . . . . . . . . . . . . . . . . . . . . . . . . . . . Check Box . . . . . . . . . . . . . . . . . . . . . . . . Drop List . . . . . . . . . . . . . . . . . . . . . . . . Edit Control . . . . . . . . . . . . . . . . . . . . . . Graffiti Shift Indicator . . . . . . . . . . . . . . Ink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . List Box . . . . . . . . . . . . . . . . . . . . . . . . . Lookup . . . . . . . . . . . . . . . . . . . . . . . . . . Paragraph Control . . . . . . . . . . . . . . . . . Radio Button . . . . . . . . . . . . . . . . . . . . . SFX Custom Control . . . . . . . . . . . . . . . Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Title . . . . . . . . . . . . . . . . . . . . . . . . . . . . C Standard Naming Conventions . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .
.216 .220 .222 .222 .223 .223 .223 .223 .224 .224 .225 .225 .225 .225 .226 .226 .226 .227 .227 .227 .228
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .234
x
About the Author Clayton E. Crooks II is a consultant, computer writer, and a partner in Advanced Information Systems LLC, a consulting firm that specializes in software development and hardware solutions for business, education, and government entities. He has served as a beta tester for numerous development tools, and has developed many Palm applications as custom solutions for his clients using the tools discussed in this book. He is a regular contributor to several magazines and Web sites, including Newsguy, Web Techniques, Inside Solaris, Inside Visual Basic, Wireless Developer Network, and Handheld Computing Magazine.
xi
Dedication This book is dedicated to my parents, Clayton and Donna. Thank you for your love, guidance, and support.
Acknowledgments Rarely is a book solely the work of a single individual who gets his name displayed on the cover, and it is definitely not the case with this project. One of the most gratifying aspects of writing a book is thanking all of those individuals who have worked so hard to get it into your hands. I’d like to begin by thanking everyone at Que, and specifically, Loretta Yates the acquisitions editor, whose ideas and efforts got this project off the ground; project editors, Karen Shields and Tricia Liebig, who managed to keep things moving along smoothly; Bryan Morgan, the development and technical editor, for his input and ideas to the projects and development tools; and Benjamin Berg for his help with the manuscript. I extend my sincerest gratitude to each of them. Lastly, I’d like to thank my wife Amy for her support and understanding during the long hours spent writing this book. To my son, Clayton III, for reminding me to take a few breaks from work, and my family and friends for putting up with me.
xii
Tell Us What You Think! As the reader of this book, you are our most important critic and commentator. We value your opinion and want to know what we’re doing right, what we could do better, what areas you’d like to see us publish in, and any other words of wisdom you’re willing to pass our way. As a publisher for Que, I welcome your comments. You can fax, e-mail, or write me directly to let me know what you did or didn’t like about this book—as well as what we can do to make our books stronger. Please note that I cannot help you with technical problems related to the topic of this book, and that due to the high volume of mail I receive, I might not be able to reply to every message. When you write, please be sure to include this book’s title and author as well as your name and phone or fax number. I will carefully review your comments and share them with the author and editors who worked on the book. Fax:
317-581-4666
E-mail:
[email protected]
Mail:
David Culverwell Que 201 West 103rd Street Indianapolis, IN 46290 USA
1 Introduction to the Palm Pilot
4
Chapter 1: Introduction to the Palm Pilot
Overview of the Palm Operating System (OS) With more than 16 million Personal Digital Assistants (PDAs) shipped to date, Palm has clearly defined the market for handheld devices. The strength and reason for the popularity of the devices is clearly the Palm OS. It provides a simple and powerful operating environment that has allowed Palm to dominate the PDA market since its inception. Third-party developers, who total more than 130,000 registered users, have been a key in the acceptance of the devices, as they have created more than 10,000 applications for them. The growth of the PDA market will undoubtedly remain strong as corporate environments continue to adopt the devices creating additional opportunities for developers. In 1994, Palm Computing introduced handwriting-recognition software that offered never-before-seen accuracy and speed for handheld computers. Utilizing a very basic form of shorthand, the Graffiti software has been the basis for every Palm OS–based device ever developed. By revolutionizing the handheld device market, Palm has established itself as the leader in the Personal Digital Assistant (PDA) marketplace, accounting for as much as 75% of PDA sales. Palm continues to be the market leader in both the United States and Europe, with sales continuing to grow at a pace that many expect will soon exceed desktop PCs. The Graffiti software was originally developed for devices produced by other manufacturers, such as the Apple Newton, but in mid-1996, Palm Computing decided that it would create its own PDA. The result was the release of the Palm 1000 followed by the Pilot 5000. The rapidly expanding user base soon topped one million and Palm has never looked back. From the beginning, Palm devices had the capability to add third-party applications, but it was the core functionality that allowed it to be so successful. Perhaps not wanting to change what was already working very well, Palm devices have remained fairly consistent throughout their many releases since 1996. The original built-in applications included Dates, Address Book, To Do List, Memo Pad, and Calculator. These applications are still common today, albeit in much more refined forms. The hardware of the devices has undergone a larger change with the addition of backlit screens, additional memory, TCP/IP support, IR support, and color screens. This list is very simple and does not take into consideration the large number of extensions available from other companies that design Palm OS devices such as Sony and Handspring. Handspring, for instance, offers a revolutionary addition to standard Palm hardware via the
Hardware Limitations
5
Springboard module. We’ll take a detailed look at the many devices available from Palm and other OEM manufacturers later in this chapter.
Hardware Limitations Developing applications for Palm OS–based devices is very different than writing desktop applications and requires a completely different thought process. There are a plethora of differences between a Pentium-based desktop computer and a Palm OS–based handheld. These differences range from the very obvious, such as screen size and processing power, to those that could be overlooked at first glance, such as data storage or power consumption. The Palm PDAs are remarkable devices and in order to develop software for them, we need to look at what they have and—maybe more interestingly—what they lack. Although there are variations to the devices, in general they do not offer keyboards and they do run on battery power. They also have relatively light processing power, small screens, limited memory/storage capacity, and are used in a much different manner than their desktop counterparts. Understanding these areas is crucial to the development of software that takes advantage of the strength of the devices and, at the same time, minimizes the inherent weaknesses that are apparent in a PDA.
Keyboard, or Lack Thereof As you can see in Figure 1.1, in order to keep PDAs small and compact, Palm-based devices typically do not have keyboards. Instead, they use the aforementioned Graffiti software for handling user input. The Graffiti software is adequate for inputting small amounts of data, but it is not a very efficient means for entering large amounts of data. Unless your users plan to use an attachable third-party keyboard, you should always keep this in mind when developing Palm software. The keyboards are available from several sources including Landware (http://www.landware.com), iBiz Technology (http://www.ibizcorp.com) and Think Outside (http://www.thinkoutside.com). Remember that a PDA is actually an extension of the computer and not a direct replacement. If your software requires large amounts of data input, you should consider giving your users the ability to actually enter the data on their PC instead of on the Palm device.
6
Chapter 1: Introduction to the Palm Pilot
Figure 1.1: Input for Palm devices is generally limited to Pen input using the Graffiti software.
Battery Power Because Palm PDAs have been designed to be easily carried and are generally small, the batteries that power them also tend to be small. The battery life of the devices is actually one of their strong points, however; depending on the amount of use, a Palm’s battery life can often exceed a month. Many devices utilize standard disposable AAA batteries, while newer high-end models use rechargeable batteries that are recharged when they are in their docking cradle. There are certain tasks that consume batteries at a greater pace than others and, as programmers, we must take these into account when we design applications. These tasks, which include IR communications, sound, animation, or any general task that utilizes the CPU for a long period of time, should be avoided when possible. This is not to say that they should never be used, but they should be employed as little as possible.
Processing Power Palm PDAs use processors that range from 16MHz to 33MHz, which obviously equates to much lower processing power than desktop computers. This can be a problem for a programmer because many of us have become so accustomed to the processing power of desktop PCs and have become sloppy in our programming techniques and implementations. You should
Hardware Limitations
7
attempt to use a desktop computer for complex processing if possible or at least make sure that you keep the user informed of what is happening if you use the device. A program that appears to freeze can cause many anxious moments for users of the software.
Small Screens The vast majority of Palm OS–based devices, an example of which can be seen in Figure 1.2, have very small screens which offer about 160×160 pixels. This is a limiting factor for developers as you obviously cannot display as much information on a Palm device as you could on a desktop computer screen. Consequently, you have to be much more creative in the development of a graphical user interface (GUI) for Palm applications, with very simple input screens that should display only the necessary information.
Figure 1.2: Screen sizes are a limiting factor for developers.
Limited Memory and Storage Capacity Another area that programmers need to consider is the limited storage and memory available on Palm OS–based devices. The storage spaces vary from 512KB to 8MB, with a dynamic heap in the range of 32KB to 256KB. The newest devices tend toward the high end of each. With limited space to work in, developers should always attempt to create highly optimized applications that take up as little space as possible.
8
Chapter 1: Introduction to the Palm Pilot
All Palm OS memory is considered part of a removable card, which allows for upgrades. Currently, all devices utilize a single card for both, although the OS itself can support up to 256 individual cards. The following list details the differences between RAM and ROM: • ROM: Contains the operating systems, including built-in applications and databases. The size of the ROM varies from 512KB to 2MB, depending on the device. • RAM: Used to store add-on applications and user data. The size of RAM can vary from 128KB up to a maximum of 12MB.
Common Usage Patterns People who use PDAs do not want to stare at an hourglass waiting for the next screen to appear (for that matter, none of us really like waiting, but we are much more likely to wait for a desktop machine). Typically, a user will utilize their PDA for smaller amounts of time but will also cycle it on and off more often as well. In other words, they will use it in short bursts of activity throughout the day. Therefore, you should try to keep their waiting time to a minimum. For instance, when doing a calculation on a desktop computer, waiting two minutes for it to finish is probably not a big problem, especially if you are using it for hours at a time. However, if it takes two minutes to do a calculation on a PDA, the user will probably not be so agreeable, as they probably were only planning to use it for a couple of minutes total.
Hardware Devices Now that you have a basic idea of Palm hardware, we’ll take a look at a detailed list of devices from Palm and other OEM hardware manufacturers. The following list details many of the available devices but is not meant to cover every device available which, as you can see in Figure 1.3, can be varied in size, shape, and color. Table 1.1: Palm Inc. Devices Device Palm Palm Palm Palm Palm Palm Palm
Pilot Pilot Pilot Pilot Pilot Pilot III
1000 5000 Personal Pro Pro
RAM
OS Version
CPU(MHz)
Display
128KB 512KB 1MB 512KB 1MB 1MB 2MB
1.0 1.0 1.0 2.0 2.0 2.0 3.0
DB-16 DB-16 DB-16 DB-16 DB-16 DB-16 DB-16
FSTN, No backlight FSTN, No backlight FSTN, No backlight FSTN, No backlight FSTN, backlight FSTN, backlight FSTN, backlight
Hardware Devices
9
Table 1.1: continued Device
RAM
OS Version
CPU(MHz)
Display
Palm Palm Palm Palm Palm Palm Palm Palm Palm Palm Palm Palm Palm
2MB 8MB 4MB 2MB 8MB 2MB 8MB 2MB 8MB 2MB 8MB 8MB 8MB
3.0 3.5 3.1 3.1 3.5 3.1 3.3/3.5 3.2/3.25 3.5 3.5.1 3.5.1 4.0 4.0
DB-16 EZ-20 EZ-16 EZ-16 EZ-16 EZ-16 EZ-20 16 or EZ-16 EZ-20 EZ-16 EZ-16 VZ-33 VZ-33
FSTN, backlight TFT, 256 colors FSTN with TDF Film FSTN with TDF Film FSTN with TDF Film FSTN with .34mm FSTN with .34mm FSTN with TDF FSTN with 150MHz FSTN with .29mm FSTN with .29mm Pitch .34 TFT, 16 bit
2MB IIIc IIIx IIIe IIIxe V Vx VII VIIx m100 m105 m500 m505
Licensee Devices, OEM Devices, and Unique Hardware Accessories Claudia Schiffer
8MB
3.3/3.5
EZ-20
Epocrates Healthcare
8MB
3.3/3.5
EZ-20
Visor Deluxe
2,8MB
3.1
EZ-16
Visor Platinum
8MB
3.5
VZ-33
Visor Prism
8MB
3.5
VZ-33
Visor Edge
8MB
3.5.2
VZ-33
IBM WorkPad
4MB
3.1
EZ-16
IBM WorkPad c3
2MB
3.1
EZ-16
FSTN, with .34mm. OEM device based on Palm Vx handheld FSTN, with .34mm. OEM device based on Palm Vx handheld Handspring with built-in Springboard slot and microphone Handspring built-in Springboard slot and microphone Handspring 16-bit Handspring built-in Springboard slot and microphone Handspring built-in Springboard slot and microphone FSTN with TDF Film OEM device based on the Palm IIIx handheld FSTN with .34mm. OEM device based on the Palm Vx
10
Chapter 1: Introduction to the Palm Pilot
Table 1.1: continued Device
RAM
OS Version
CPU(MHz)
Display
Qualcomm pdQ 800
2MB
3.02
DB-16
Qualcomm pdQ 1900
2MB
3.02
DB-16
CLIÉ PEG-S300
8MB
3.5
EZ-20
CLIÉ PEG-S500c
8MB
3.5
EZ-20
Supra eKey
2MB
3.1
EZ-16
Symbol SPT1500 Symbol SPT1700
2,4MB 2,4,8MB
3 3.2
DB-16 DB-16
Symbol SPT1740
2,4,8MB
3.2
DB-16
TRG TRGpro
8MB
3.3/3.5.1
EZ-16
Qualcomm 160×192 800MHz dual-mode cell phone—CDMA digital and analog operation Qualcomm 160×92 1900MHz singlemode PCS mobile phone, supporting CDMA digital operation only Sony, rechargeable lithium ion batteries. Jog Dial control, Memory Stick Support Sony 16-bit screen Sony, rechargeable lithium ion batteries. Jog Dial control, Memory Stick Support FSTN with .34mm. OEM device based on the Palm V handheld Built-in scanner Ruggedized device with built-in scanner Built-in scanner and Spectrum 24 wireless radio network interface CompactFlash Type I/II slot. Improved audio
KEY CPU TYPES DB: Motorola Dragonball chip, officially called the Motorola MC68328 chip.
Types of Applications
11
EZ: Motorola Dragonball EZ chip, officially called the Motorola MC68EZ328. VZ: Motorola Dragonball VZ chip, officially called the Motorola MC68VZ328. FSTN = Film compensative Super Twisted Numatic display. TFT = Thin Film Transistor display.
Figure 1.3: Palm-based devices now come in a variety of shapes and colors.
Types of Applications As a developer, you have two basic choices when you are building Palm applications: traditional GUI-based applications, or Web clipping programs, which are similar to small Web pages. You may also want to create a conduit for your program that runs on a desktop computer and is used for syncing information between the desktop and Palm PDA. We will discuss Palm conduits in the section “Conduits,” later in this chapter.
Traditional Applications Traditional GUI applications that run on Palm OS–based devices are generally event-driven programs. Users do not exit these applications, which generally run one at a time. Instead, a Palm user will simply stop one application and launch another. There is a great deal of interactivity between Palm applications. For instance, if you use the built-in Find program to search your PDA, it actually runs every program on the system and searches their respective databases for the keyword you are looking for. Similar to a standard EXE file on a Windows-based PC, Palm applications are also compiled into what is known as a Palm Resource File (PRC) before
12
Chapter 1: Introduction to the Palm Pilot
they are downloaded to the PDA. The single PRC file can run on any Palm devices from any manufacturer. In this book we will look at several development tools that are available for creating Palm programs. Available Integrated Development Environments (IDE) range from popular languages like Visual Basic and Java to the traditional Palm development languages C and C++. There are also several Rapid Application Development (RAD) tools such as Satellite Forms that are available for Palm PDAs. Currently, the most commonly used language for Palm development is C or C++. Depending on the development tools you choose, your PRC file may require a runtime to be present. This is similar to Visual Basic on a Windows-based PC, which requires the Visual Basic runtime DLL to be present in order to execute. This is one of the things you have to deal with when using RAD tools, which generally require more space and run more slowly. This is the trade-off for increased development speed. Depending on your program and intended audience, this may not be a problem, but it is something to consider. The RAD tools are generally fee-based but Palm does provide a free SDK for users that choose C or C++. Along with the header files for C development, Palm provides some basic documentation and tools for the development process. Later chapters in this book will give you greater details on several IDEs and will also walk you through the creation of complete applications with each of them.
Web Clipping Applications Some individuals, especially those with a Web background, may wish to create Web clipping applications instead of traditional GUI programs. A Web clipping program is a set of HTML-like pages that have been compressed. The compressed files, which are similar to a ZIP file on a desktop, are changed into a Palm Query Application (PQA) at compile-time and downloaded to a Palm device when requested by a user. When the user of the device fills out the forms and then clicks a Send button, the clipping application sends a request to a Palm.net proxy server, which in turn translates it into an HTTP request, which is then forwarded to a company’s Web site. Many times, the Web site is running a CGI script that will generate the page which is then relayed back to the Palm.net proxy server, compressed for the Palm, and then downloaded to the device.
Types of Applications
13
The creation of a Web clipping program is similar to creating standard HTML Web pages but, because of the small screen, the design is a little different. You begin by creating your HTML pages, and then run them through the free Web Clipping Application Builder to create a PQA file that is downloaded to the PDA. The Web Clipping application itself runs inside the Web Clipping Application Viewer in the Palm organizer. When tapped, the pages and graphics of the application are rendered on the screen of the Palm organizer by the Web Clipping Application Viewer. The PQA files are most commonly viewed on devices that have wireless Internet connections, such as the Palm VII or an OmniSky modem–equipped device. If you would like to evaluate current offerings, you can visit http://www.palm.com/ wireless/apps/ to view hundreds of popular web clipping applications.
Conduits When you synchronize your Palm PDA to a desktop computer, it uses a process known as HotSync. To programmatically access the HotSync technology, you need to create a conduit, which is a type of plug-in to HotSync that runs when you press the HotSync button on a PDA’s handheld cradle which is visible in Figure 1.4. The only job of a conduit is to synchronize data between the application on the desktop and the application on the handheld.
Figure 1.4: A Palm OS–based device in a cradle ready for HotSync.
14
Chapter 1: Introduction to the Palm Pilot
The HotSync software automatically provides basic backup functions for every program on a Palm device. If this is the only type of functionality you need, the process is very simple and only requires you to change a single bit in the handheld database. This indicates to HotSync that the data needs to be backed up. This is the most basic use for HotSync technology, which can be much more involved. For example, if you have created a database that keeps track of every CD that you own, you might want to have the ability to enter data on your Palm PDA and then move it into a different database on the desktop. You would use a conduit for the process of moving the data to the desktop and converting it as necessary. A conduit, like the Palm applications themselves, can be written in one of many development environments. Popular choices include Visual Basic, Java, or Visual C++. A Palm Conduit Development Kit (CDK) is available from Palm (http://www.palmos.com/dev/tech/conduits/) and provides a very generic conduit that can be customized for your use. There are also several companies that provide third-party solutions that make the development of conduits a much easier task.
New Features in Palm OS 4 This section of the book will introduce you to some of the new features available in Palm OS 4. There is an in-depth overview available at http://www.palm.com, but this information will cover some of the new features that are important to you as a software developer.
Secondary Storage In an effort to offer a variety of options for secondary storage devices, version 4.0 of the Palm OS has introduced a Virtual File System (VFS) Application Programmers Interface (API). The API is compatible with any Sony Clié device since OS 3.5, or with any other device since version 4.0. This API is similar to the traditional file systems you encounter on desktop machines with the ability to create, open, read, and write files to the secondary storage card. NOTE Although we have not covered it yet (we’ll look at it in detail in Chapter 2), Palm provides an emulator (called POSE) that runs on your PC for developers to use to debug and test their applications without the need to download them continually to a PDA. Version 3.1 of the emulator allows you to emulate the secondary storage devices as well. Lastly, you can also directly access and manipulate the data on the secondary storage devices from the desktop via HotSync and conduit APIs.
New Features in Palm OS 4
15
Telephony Another new feature in OS 4.0 is the addition of a telephony manager that offers the ability to independently communicate directly with a phone using a unified API which handles phone book management, instant messaging (via SMS), and basic voice features. There are drivers available for specific phones like the Handspring Springboard–inspired phone visible in Figure 1.5 and generic drivers to interface with GSM phones. OS 4.0 also includes an Exchange Library that enables you to use SMS as a transport.
Figure 1.5: The Handspring Springboard module turns the Handspring into a cell phone.
Bluetooth Bluetooth has been receiving a great deal of attention in the media and from developers. While Bluetooth is not an intrinsic part of OS 4.0, the OS is Bluetooth-aware. This means that when Bluetooth libraries are installed, the device will automatically understand what to do with them.
Web Clipping Improvements Previous versions of the Web Clipping Application Viewer and the Web Clipping Proxy server did not offer support for color. Now in version 4.0 you can have interfaces that display colors using the standard “Web safe” palette as a set of officially supported colors. Any color outside of the standard palette will be converted to the closest match available in this palette.
16
Chapter 1: Introduction to the Palm Pilot
Another nice feature implemented for Web clipping applications is the introduction of cookies. The cookie jar resides on the device with a default size limit of 50KB. Cookies are automatically deleted when the cookie jar is full or when they have reached an expiration date. They are also automatically deleted if they were session-dependent. The size of a single cookie is limited to 4KB. There are also many new tags and attributes to add more functionality and fix earlier problems. There are also a few more items worth mentioning. First, Palm OS 4.0 devices now have the ability to wirelessly download binary files. You also have the ability to offer a horizontal scrollbar, which is a welcome addition for wider content.
Direct Color Palm OS 4.0 supports 24-bit color. In addition, each pixel’s red, green, and blue (RGB) components can be directly and individually selected. Current devices such as the Palm m505 or the Handspring Prism offer only 16-bit color, but the devices will take care of adjusting to the closest available match. Unless you specifically need the increased colors, you should continue to use the older APIs, as they offer the best compatibility for old and new devices. These APIs are completely compatible with those introduced in OS 3.5 on the Handspring devices.
Figure 1.6: Better color screens will make applications and games more enjoyable.
What’s Next
17
Tool Improvements in the Software Developers Kit (SDK) Perhaps one of the most useful features that has been introduced is the ability of Constructor (available in the Palm SDK) to open and edit resources of a PRC file. This allows you to localize the text in an application without needing to recompile it. The Palm OS Emulator (POSE) has also been upgraded. Although there are several new features, the new error messages are probably the most useful. Any error messages that are reported back during execution contain greater detail and generally more information. The newest version of the emulator is always available from the Palm developer’s Web site at http://www.palmos.com/dev/tech/tools/emulator/.
Review In this chapter, you looked at the history of the Palm OS and were introduced to its strengths and weaknesses. We also discussed the current hardware offerings available from several Palm manufacturers, including Palm, Sony, and Handspring. You were introduced to the two basic types of applications we can develop for a Palm device; Web clipping or traditional GUIbased programs. Lastly, we went through some of the new features that are available to a developer in Palm OS 4.0.
What’s Next In the next chapter, we’ll expound on this information by taking an indepth look at the wide range of SDKs available for Palm OS devices. These tools include the traditional Palm SDK that is based on C/C++, and RAD tools like Satellite Forms. The chapter will provide a quick overview of the tools and will look at some of their strengths and weaknesses. Subsequent chapters will provide more in-depth information on some of the tools as we begin to build applications.
2 Overview of Palm OS Development Tools Now that we have looked at some of the basics of Palm OS devices, we’ll focus our attention to developing programs for the platform. With that in mind, this chapter will serve as an overview to the development tool options that are available for Palm devices, and will look at the strengths and weaknesses of each of them. One of the great things about developing software for the Palm platform is the wide range of tools that are available. They encompass everything from traditional C and C++ tools to RAD tools such as Satellite Forms or AppForge. While most of the development tools are very good, they tend to excel at very distinct types of applications. For instance, PDA Toolbox, which will be covered in later chapters, is great for database development, but is probably not the best choice for number crunching.
20
Chapter 2: Overview of Palm OS Development Tools
Palm SDK Traditionally, Palm PDA’s applications were developed with the SDK available directly from Palm. The SDK, which is still available today, is currently in release 4.0 and is based upon the C/C++ programming languages. If you are interested in this SDK, you can download it from the Palm developer site at www.palmos.com/dev/tech/tools/. If you choose the Palm SDK, it requires a third-party compiler. At this time, there are two compilers that are directly supported: CodeWarrior and PRC-Tools, which is based on the GCC compiler. Although we’ll use CodeWarrior later in this book to develop applications, we’ll look at both of these compilers in Chapter 14 when we look at developing applications using C.
CodeWarrior For several years, CodeWarrior was the only supported compiler available for the Palm OS, and it is still probably the most popular development tool for the platform. It runs on Windows 95/98/NT or Mac OS and integrates seamlessly with the Palm SDK. CodeWarrior is a commercial package from Metrowerks, and is a typical commercial development environment, similar to other C++ IDEs. One of the reasons it is so popular is because the vast majority of sample code in the Palm SDK requires CodeWarrior (it can be seen in Figure 2.1) to compile, and many books cover it as well. Although it is a commercial application that costs money, there is a Lite version available for free from www.palmos.com/dev/tech/tools/cw/. The free version does have limitations but it will give you an idea of the features and functionality CodeWarrior provides.
PRC-Tools
21
Figure 2.1: CodeWarrior in action.
PRC-Tools PRC-Tools is a complete GCC-based compiler tool for building Palm OS applications in C or C++. It is free software and is supported by Palm. Currently, PRC-Tools runs on 32-bit Windows and Linux. Although there have been frequent rumors about a Macintosh port, it does not appear on the official PRC-Tools site at http://sourceforge.net/projects/prc-tools/. PRC-Tools is a complete toolkit for the development of Palm applications. Unless you have experience with command-line compilers, you may want to get one of the IDEs that are available such as the PilotMAG, which can be seen in Figure 2.2. Otherwise, you may have trouble with the command-line options. The IDEs, which have varying costs, are available from the following locations:
22
Chapter 2: Overview of Palm OS Development Tools
• Falch.Net: http://www.falch.net/IDE/ • VFDIDE: http://www.vfdide.com/ • PilotMAG: http://users.cg.yu/montesoft/
Figure 2.2: An IDE such as PilotMAG makes PRC-Tools much easier to use.
On-Device C Development Tools Along with the IDEs that run on the desktop, there are two additional options for creating C applications. Instead of using an IDE, PocketC and OnboardC consist of a compiler that allows you to write your code directly on the device using the text-based memo editor that is built in to the Palm OS. This allows you to write applications and compile them directly on the device. PocketC, which also has an IDE for Windows-based PCs that can be also be seen in Figure 2.3, is available from Orbworks (www.orbworks.com), and OnboardC can be located at www.individeo.net/OnBoardC.html.
Java
23
Figure 2.3: PocketC also has an IDE for Windows-based PCs.
Java In past years, Palm programs were written using C, but as the popularity of the devices has expanded, many third-party development tools have been released. In this section, we’ll look at the Java tools that are available for Palm OS devices. There are several SDKs available that provide a Java Virtual Machine (JVM), but because a JVM generally takes up a relatively large amount of space and requires processing power, the JVMs that are available use only a subset of Java.
VisualAge Micro Edition IBM has released VisualAge Micro Edition, a Java development environment for the Palm. It is based on IBM’s VisualAge for Java product and runs on Windows and Linux. The IDE generates Java bytecode, which is interpreted by IBM’s traditional-style JVM. The JVM takes up 150KB on the Palm. The “Individual Package,” which does most everything you’d want, is free. There’s also a “Collaborative Package” that adds a code repository and version control for $100 per developer.
24
Chapter 2: Overview of Palm OS Development Tools
Sun’s Java 2 It would make sense that one of the proponents of Java would have something available for the Palm OS. Unfortunately, Sun (http://www.sun.com) has been a little slower than most would have liked in releasing a commercial IDE for Palm OS development and we are continuing to wait for one. There is a package called Java 2 Micro Edition (J2ME) with one configuration called Mobile Information Device Profile (MIDP). MIDP includes a highly optimized version of the JVM that Sun calls the KVM. The KVM and MIDP libraries together account for as much as 160KB. It’s available for free from Sun for research and development; a commercial licensing arrangement is negotiated on a case-by-case basis. There are a multitude of rumors as it relates to Sun, but it remains to be seen if Sun will ever release a commercial IDE.
Waba Currently, Waba (http://www.waba.com) is by far the best version of Java available for the Palm OS. It has been freely released under the GPL license and is a subset of Sun’s Java that lets you use standard Java development environments. This is a very interesting project that allows you to create applications that run on the Palm, Windows CE–based devices, or any OS that has a JVM. At this time, the runtime is only 73KB. Another group of developers has released a new environment called SuperWaba. They have extended the traditional Waba package by adding PocketPC support, a Java AppletViewer, and a GUI builder called VisualWaba, an example of which can be seen in Figure 2.4.
Basic Languages
25
Figure 2.4: VisualWaba is a new GUI for SuperWaba. It’s safe to say that Java will play an important role in the future of application development for the Palm OS. There are currently several packages that are available for developing Java applications, and which of the tools you choose will depend on the implementation that best suits your individual needs. At this time, the only thing certain is that the tools will continue to evolve and change even more in the future.
Basic Languages The BASIC programming language, which includes the standard BASIC language tools like QBasic along with newer versions such as Visual Basic or REALbasic, is the most popular language in the world. It shouldn’t come as a surprise that there are several BASIC-related development tools for the Palm OS, the first of which was Ron Nicholson’s HotPaw Basic. HotPaw Basic, which was previously known as CbasPad, is a small BASIC interpreter for the Palm. It has support for the Palm API. One of the problems with HotPaw Basic is the lack of a runtime. In order to use your programs, the owner of the device would need to buy HotPaw Basic for himself or herself. Therefore, this is probably an environment that is best left to those who are experimenting or developing applications for their own use.
26
Chapter 2: Overview of Palm OS Development Tools
NS Basic Another very successful tool is NS Basic (http://www.nsbasic.com). It is a commercial product that will probably remind most of Visual Basic (see Figure 2.5 for comparison), as it includes a full GUI builder, debugger, and Windows-based IDE. The package generates Palm PRC files that need access to a separate 77KB runtime file to be executed. The runtime is royalty-free for this program. NS Basic has continued to evolve into one of the best BASIC language tools available for the Palm OS.
Figure 2.5: NS Basic’s IDE looks similar to Visual Basic.
AppForge While NS Basic looks similar to Visual Basic, AppForge (http:// www.appforge.com) is Visual Basic, albeit with a new set of controls that are specific to Palm OS–based devices. It’s an add-on that adds controls, called Ingots, which replace the standard VB controls in the IDE and on the device. You can see the slight changes to the IDE in Figure 2.6. Of the BASIC language tools, this one probably has the most chance for commercial development success, as users of Visual Basic will find it very easy to move into the Palm platform. One of the most interesting aspects of AppForge is its ability to create executables that run on both the Palm and Windows OS with a single executable. They look exactly like a Palm PRC file and even include the standard 160×160 screen. The runtime, which is
Building Database Applications
27
about 300KB, may be the largest runtime of any third-party Palm development tool. However, this may not be a big problem as PDAs are continuing to increase the amount of memory they offer, and Palm has licensed AppForge for possible inclusion in future versions of the OS itself. We’ll look at AppForge in more detail in the next chapter, and will build several applications with it later in the book.
Figure 2.6: The AppForge Ingots displayed within the Visual Basic IDE.
Building Database Applications The Palm device is ideal as a data collection tool. It offers great battery life, is small enough to carry around, and excels at looking up or storing data. Fortunately, there are several development tools that have been created to take advantage of these characteristics.
Satellite Forms Satellite Forms was one of the first RAD tools available for the Palm OS and is still one of the best. Available from PumaTech (www.pumatech.com), it is a complete forms/database designer that has a tremendous number of features. The IDE can be seen in Figure 2.7 and includes an event-based, VB-like scripting language that makes it more powerful than the products mentioned later in this section. It also includes an SDK so C programmers can extend its usefulness as needed. We’ll develop several applications with Satellite Forms later in this book.
28
Chapter 2: Overview of Palm OS Development Tools
Figure 2.7: Although classified as a database program, Satellite Forms can be used for many types of applications.
Pendragon Forms Pendragon Forms, available at http://www.pendragon-software.com, is more of a data collection program than a complete database application. It allows you to create an Access database on a Windows machine, and by defining the database on the Palm device, it allows you to collect data on the Palm. When a hot sync is performed, it allows the data to be synchronized in both directions. Unfortunately, it includes runtime fees that can be very costly depending on how many applications you want to distribute.
IBM DB2 Everyplace IBM’s DB2 Everyplace is an SQL-based relational database for the Palm that is offered in Personal and Enterprise editions. It is available at http://www-4.ibm.com/software/data/db2/everyplace/ and comes complete with a Personal Application Builder that you can use to develop the applications that run on the Palm, or you can use one of the C-based tools like CodeWarrior or PRC-Tools. Additionally, it supports IBM’s VisualAge Micro Edition.
Building Database Applications
29
While programming is similar for both versions, there are some distinct differences that may affect your choices between the Personal or Enterprise editions. While there are many differences, the most important is the fact that the Enterprise edition ships with Sync Server, which lets you sync your data to and from a DB2-networked database. This package can get very expensive, while the Personal edition is more useful for basic data collection programs with its limited synchronization capabilities. The Personal edition includes the Personal Application Builder, a Palm runtime, and is very inexpensive. It doesn’t include any of the sync options of the Enterprise edition but it is a low-cost way to get started working with IBM DB2 Everyplace.
FileMaker Mobile Users of the PC- and Mac-based FileMaker database programs will find the FileMaker Mobile solution to be a welcome addition to their development needs. Most of the databases that work with the Palm utilize Microsoft Access or another similar database. FileMaker Mobile is an add-on package that includes the ability to synchronize between a desktop database and a Palm OS–based device. You can find additional information about this program at http://www.filemaker.com/products/mbl_home.html.
PDA Toolbox PDA Toolbox (http://www.pdatoolbox.com) is one of the most interesting development tools for the Palm OS. As you can see in Figure 2.8, it features an easy-to-use Windows OS–based IDE that supports a form-based development process using drag and drop for the placement of buttons and database fields. It is probably the easiest database tool to use and has an enormous number of features. You can have up to 64 forms in a single application, and the PRC files produced by PDA Toolbox do not require any type of runtime, are royalty free, and can utilize multiple databases in a single application. We’ll be using PDA Toolbox later in the book for the development of a couple applications.
30
Chapter 2: Overview of Palm OS Development Tools
Figure 2.8: Combining the easiest to use database program with a low price makes PDA Toolbox an excellent choice for beginners.
Working with Spreadsheets and Flat File Databases Along with these larger database applications that provide many features, there are several applications that have functions similar to spreadsheets or flat file databases. They have various features and include the following: • QuickSheet: An Excel-compatible spreadsheet • Jfile, MobileDB, ThinkDB: Flat file databases • TinySheet: Spreadsheet
Miscellaneous Tools There are a few miscellaneous Palm OS development tools that don’t fit nicely into one of the categories that we’ve looked at so far. With that in mind, we’ll list some of them with a sentence or two of basic information.
Assembly Language Tools If you like low-level programming, you’ll be happy with the Palm assembler called Pila. There’s also a disassembler called PilDis, which runs under Windows. PilDis can label Palm OS API trap calls with the name of the API.
PRC Editing Tools
31
CASL CASL is a high-level cross-platform language that looks similar to Pascal. It has a Windows-based IDE that can be seen in Figure 2.9 and is similar in nature to NS Basic. CASL requires a runtime file to be shipped with any software you develop.
Figure 2.9: The CASL IDE is similar to that of NS Basic.
PRC Editing Tools PRC editing tools enable developers to effectively view or even extract resources from compiled Palm PRC files. For a developer, these tools have several uses, such as the ability to alter text information in an already compiled program. You could even use them to extract a bitmap file that you used in a previous program. The following tools extract resources or otherwise alter palm PRC files: • Prc2Pilrc extracts all the resources from a PRC file. • PTools is a resource and database viewer for .PRC, .PDB, and .BIN files that display forms and bitmaps. The source code is free, as is the application. • Prc2Bin breaks a PRC file down to its constituent resources.
32
Chapter 2: Overview of Palm OS Development Tools
Python While it is in the early stages of development, Pippy, a port of Python to the Palm OS, is actually semi-functional. There are some features that are missing but many of them are due to the Palm OS itself and not the port.
Forth Quartus Forth is similar to PocketC in that it uses source code from MemoPad or DOC files and compiles it into machine code. It’s an excellent port of the Forth language and anyone interested should take a look at it.
Scheme Another good port is LispMe, a free Scheme compiler for the Palm OS. It’s a basic implementation and as such, is probably limited to trying out ideas instead of complete development projects.
Smalltalk Pocket Smalltalk and Squeak are Windows-based Smalltalk compilers that generate PRC files. Squeak requires virtual machines for execution while Pocket Smalltalk compiles to a standalone PRC.
Pascal There is a Pascal development environment that is going to be released soon. For Delphi programmers this should be welcome news. Pocket Studio is currently in beta and provides a very well-done IDE. Delphi and Pascal fans alike should pay close attention to the future of this one.
What’s Next In this chapter, we looked at a number of development tools that are available for the Palm OS. You can often determine the popularity of a platform by the number of third-party tools that have been created, as is the case with these SDKs. In the next chapter, we’ll look more closely at Satellite Forms, the development tool from PumaTech. Once you are comfortable with the IDE, we’ll move on to building your first Palm application.
3 POSE—The Palm OS Emulator The Palm OS Emulator, or POSE as it is commonly known, is a software tool that emulates the hardware of the various models of Palm OS–based devices. Because the number of devices that exist continues to increase, an emulator can prove to be invaluable for writing, testing, and debugging applications, especially for devices that you do not always have at your disposal. The POSE application can be seen in Figure 3.1. Versions are available for Windows, Mac OS, and Unix computers and the source code is available through an open source license. It was originally based on the Copilot software that was contributed to by various developers (although Greg Hewgill was primarily responsible for its creation). The emulator is constantly evolving and Palm has recently added many new features such as enhanced debugging support.
36
Chapter 3: POSE—The Palm OS Emulator
Figure 3.1: The Palm OS Emulator being executed on a Windows desktop. As a Palm OS developer, you should obtain the most recent emulation software from Palm at http://www.palmos.com/dev/tech/tools/emulator/ because it is constantly updating it. In order to maximize your benefits, Palm offers a complete developers’ program that’s basic format is free. You should consider subscribing to this program as it gives you access to an enormous amount of Palm OS data and developer tools such as POSE and the ROMs, which will be discussed in greater detail in the next section. For program details, visit the Palm Alliance program at http://www.palmos.com/alliance/join/.
Using POSE POSE works by using ROMs from various Palm devices. Simply put, a ROM contains the interworkings of the Palm device. This includes everything that POSE needs to emulate the hardware of the device including the Palm OS. ROMs allow you to change the emulated system from one to another; by doing so, you can test your application with several devices, including those that you don’t own. There are also “debug” ROMs that are available from Palm that allow extra error checking and various debugging features.
Using POSE
37
The emulator offers complete support for skins so that when you change a ROM to emulate a system, if there is a skin available, it will also be displayed. Figure 3.2 displays multiple instances of the emulator running different ROMs and displaying different skins. Installation of the emulator, ROMs, and skins will be covered later in the chapter.
Figure 3.2: POSE allows you to emulate many types of devices. POSE does not include the ROM images that are necessary for its execution. Instead, it can be thought of as a virtual computer without an operating system. In order to emulate the hardware, you will need to obtain ROM images for the devices you wish to test. For example, if you would like to emulate a Palm m100, you would need the Palm m100 ROM. Additionally, if you would like to test a Handspring Visor Deluxe, you’d need a ROM and skin for it. There are basically two ways that you can legally obtain ROM images. First, you can upload the ROM images from devices you own. However, this approach limits you to the few devices that you have at your disposal. Furthermore, the ROMs obtained this way are standard ROMs without advanced debugging features. If you have a USB-enabled device (most new hardware includes only USB), you will be out of luck because the upload program only supports devices linked to the computer via a serial port at this time. The process involved in uploading ROMs will be detailed later in the chapter.
38
Chapter 3: POSE—The Palm OS Emulator
The other option, and the preferred method, is to join one of the various developer programs that have been created by Palm OS device manufacturers. For example, the Palm OS Developers’ Program located at http:// www.palmos.com/dev/programs/pdp/ is free to join. To join, you simply fill out a straightforward questionnaire. There is a complete list of these manufacturer programs available in Appendix A of this book. Once you join one or all of the developer programs, you will have access to downloadable ROMs for all the available Palm devices. In the case of Palm’s Developers’ Program, you will instantly have access to ROMs for every Palm device imaginable, from the venerable Palm III to the newer devices like the m505. There are two basic types of ROM image files: debug and non-debug versions. ROMs transferred from a device (and non-debug ROM image files that are available for download) are designed to catch and handle errors that occur when a program executes. After all, you wouldn’t want a Palm that constantly crashes every time it encounters an error. On the other hand, debug ROMs are nearly the exact opposite. They are extremely important to developers because they reveal programming errors and techniques that may not work in current or future versions of the Palm OS. Palm recommends that developers use debug ROMs to develop software for the public. However, you’ll see in later chapters that you can’t always use debug ROMs because certain development tools will have problems utilizing them.
Setting Up POSE Installing POSE is rather easy, even though it does not come with a standard type of installation program. Therefore, we will look at the installation process on a typical Windows-based PC (Mac and Unix installations are similar enough that it shouldn’t be a problem for users to follow along). The first step is to obtain the POSE emulator. If you haven’t already done so, you should download the most up-to-date version that is currently available from www.palmos.com/dev/tech/tools/emulator/. Again, this software is free to developers. Once you have downloaded the version appropriate to your OS (in our examples we’ll be using the Windows version), you should decompress it to a suitable directory. When you decompress the files, they should be placed in a folder called “Palm” to store your various projects and a subfolder within it called “POSE Emulator” for the emulator. Figure 3.3 displays a directory listing with the files unzipped to the above referenced names.
Obtaining ROMs
39
Figure 3.3: You should unzip the downloaded emulator to the specific directory on your PC. The next step is to download and install the various skins that will be used by POSE to display various hardware devices. It’s important to understand that the skins will not affect the actual emulation, but they do make POSE look like the system it is attempting to emulate. Palm, Handspring, and other device manufacturers typically offer skins for their hardware, and again, you can refer to Appendix A to locate these skins. Once you have downloaded the file(s), unzip them to a location close to your ROMs and other POSE files. For example, you can unzip them to a folder called “Skins” located in the Emulator folder created in the previous step. The emulator will automatically look through these skins once they are in the folder. NOTE The terms folder and directory are often used interchangeably throughout this book. This is not meant to confuse you; both terms are appropriate.
Obtaining ROMs POSE needs to have a minimum of one ROM before it can begin emulating Palm devices for you. As we discussed earlier, you can obtain the ROMs either from the device manufacturers or by uploading the ROM from your Palm OS device.
40
Chapter 3: POSE—The Palm OS Emulator
Let’s look at the more difficult of the two: Transferring the ROM from a device to the emulator. This process requires the use of a serial connection (not a USB connection), and also requires that nothing has been installed on the device that could have altered its ROM image. For instance, Flashpro, which allows you to back up your device to flash memory, may alter the ROM file, so you wouldn’t want to use the ROM from a device that has Flashpro installed. Uploading the ROM takes only a few simple steps: 1. Make sure the HotSync software has been installed and that it is working with your device. The installation and testing of your device are covered in the respective manufacturer’s literature. 2. Connect the device to a PC that has the emulator installed on it. 3. Transfer a file called ROM Transfer.prc from the POSE installation directory to the device. If you don’t know the process, typically you can simply double-click the file in Windows and an Install Tool window will appear similar to Figure 3.4. From the Install Tool window, you can select Done.
Figure 3.4: The Palm Install Tool window allows you to install prc files on your devices. 4. Perform a HotSync to install the file. 5. Once installed, you will find the program on the Palm device. If you execute it, it will display a message similar to Figure 3.5.
Obtaining ROMs
41
Figure 3.5: A message will be displayed when you execute the prc transfer program. 6. Run the Emulator.exe file that is in the POSE Emulator folder on your computer. When you run it, a window will appear similar to Figure 3.6. Select Download ROM from the window. 7. The Transfer ROM window is displayed. Verify that the Serial Port and connection speed are appropriate for your device. 8. Select Begin Transfer on the Palm device after making sure that the Palm settings match those found on the PC.
Figure 3.6: POSE will display a message similar to this upon execution. 9. Select Begin on the PC. 10. After some uploading time, and if all of the settings were correct, you will have a ROM file available in your POSE directory. You should move this file, which will have an extension “.rom”, to a ROM subfolder within the POSE Emulator folder. If you have problems transferring the ROM, verify that you followed these steps and consult the documentation for any specific errors.
42
Chapter 3: POSE—The Palm OS Emulator
Again, you should make every effort to obtain ROM images from the Palm device manufacturers instead of uploading your own. If you download the images from one of the sites, you should unzip and copy them to the POSE Emulator directory inside the ROM subdirectory. Now, the following steps, which involve selecting a ROM and running the emulator, are identical regardless of the process used to obtain them.
Using POSE If you have any POSE windows open, you need to close them. Now, with POSE installed correctly and a ROM image available, the next step is to execute POSE. It will display the Palm OS Emulator window, which you may already be familiar with from the previous step. From this window, select New. The New Session window appears, similar to the one that can be seen in Figure 3.7.
Figure 3.7: The Palm OS Emulator Window is displayed immediately on execution. This window allows you to set various items such as Skin, ROM File, and RAM Size. In our example, we’ll look at the emulation of an old Palm III. You can set POSE appropriately for your ROM file. Click on the ROM File drop-down and then choose Other. A standard dialog box will appear. From this box, you should navigate to the appropriate folder and select the ROM file which is called palmos33-en-iii.rom. This is the ROM image for a Palm III with OS version 3.3. Again, your ROM image might be different. When you open the ROM, you are returned to the New Session window. Once there, choose your device, skin type, and RAM size. For a Palm III, here are the appropriate selections: Device: Palm III Skin: Standard-English RAM Size: 2048K You can see all of these setting in Figure 3.8.
Using POSE
43
Figure 3.8: The settings for a Palm III. Once the settings have been made, click the OK button. This will display the POSE emulator, and if everything has gone correctly, it should appear similar to Figure 3.9.
Figure 3.9: POSE settings are complete and it is running. The major functions of POSE will be looked at when we need them. At this point, we will save the session so that you don’t have to go through this entire process to simply execute the emulator. First, you should right-click on the emulator and choose Save As from the pop-up menu. Next, give your session a name such as “PalmIII33” and then click Save. You can save this file to any folder you would prefer. Once saved, you can use it to quickly open your Palm III emulator settings again by doubleclicking the PalmIII33.psf file in Windows.
44
Chapter 3: POSE—The Palm OS Emulator
Loading an Application into POSE Loading and executing an application with POSE is very simple. You can use the Install command to load applications or databases directly into the current emulation session. You can begin by right-clicking on the POSE screen. A pop-up menu will appear, from which you can choose Install Application/Database. This will open a standard file dialog box where you can choose the Palm application (PRC), Palm query application (PQA), or database (PDB) that you would like to install. The file is immediately loaded and if another creator ID exists for that file, the old one is deleted. You can execute the application after it has been installed by doubleclicking it with the mouse.
Conclusion The POSE emulator is one of the most important applications available to Palm developers. Instead of purchasing 10 or more devices to test your programs, you can use this emulator, which adequately emulates Palm OS devices. It is an invaluable piece of software for testing and debugging the applications you will create later in the book. You should keep in mind that testing an application with POSE should only be used as a guide during development. Where possible, you should test any application you plan to distribute on the real devices.
4 Basics of Satellite Forms The first development environment we’ll look at in-depth is Satellite Forms from Puma Technologies (www.pumatech.com). It offers a complete Integrated Development Environment (IDE) which enables you to create forms and database tables, as well as write code in a scripting language. This chapter will discuss Satellite Forms in detail. Topics covered include the Integrated Development Environment (known as the App Designer) as well as the basics of forms and controls and connecting to data. If you’d like to follow along with the next few chapters, you should download the demo version from the Puma Technology Web site.
48
Chapter 4: Basics of Satellite Forms
The App Designer (IDE) The first area we’ll focus on is the App Designer or IDE. It is similar to many Windows-based programs and, more specifically, Windows-based development tools. This application enables you to design the forms and database tables that are used in your Palm application. The App Designer, which can be seen in Figure 4.1, has five basic elements, which include the Menu Bar, Toolbars, Contents Window, Status Bar, and Workspace.
Figure 4.1: App Designer has five basic elements. When Satellite Forms is opened, a blank desktop is displayed. The toolbars at the top of the App Designer display icons that enable you to perform common tasks. There is also a menu bar that contains four options: File, View, Handheld, and Help. There is a Content window on the left of the screen and a workspace area to the right of it. The Content window displays the contents of the current application in a tree view, which allows you to navigate the application in a quick and easy manner. The current application name is also present in the title bar. To continue on with the chapter, you need to start a new application. You should click the New Project button from the toolbar or select File, New from the File menu. When a new project is started, a blank form is created automatically that is similar to the one shown in Figure 4.2.
Setting Application Properties
49
Figure 4.2: App Designer with a new project started.
Setting Application Properties A Palm OS –based application that is created in Satellite Forms has several properties that need to be set. To access the properties, you need to select Project Properties from the Edit menu. This process displays the Application Property Dialog Box which can be seen in Figure 4.3.
Figure 4.3: The Application Property dialog box.
50
Chapter 4: Basics of Satellite Forms
The following list details the individual properties that need to be set in the Properties dialog box: • Name of Application: The name of the application that you are creating. • Initial Form: If you have multiple forms, you can select the form that should be displayed when the application is started. • Creator ID: Every Palm executable requires a unique Creator ID that allows it to be separated in the OS and doesn’t conflict with any other application on the device. • Desktop DB Format: Format of the desktop database (Access or dBase). • Device DB Format: Format of Palm device database. • Application Icon: Bitmap used for the application icon. • Version: Major and Minor revision numbers for an application. • Miscellaneous: Several additional options for setting various features. Of these properties, the Creator ID is the most interesting because it is a feature unique to the Palm OS. Every Palm application needs a unique ID that can be obtained from Palm at www.palm.com. While developing an application, you can choose to use one of the built-in Puma Technology reserved IDs that range from “SMS0” to “SMS9”. Just be sure to remember that the ID needs to be changed before you distribute your final program, because the Puma reserved IDs are for testing purposes only.
Built-In Components You may have noticed the many components that became available when you started the new application in the previous step. The following list details these components and what they are used for: • Title Control: Displays a title across the top of the form or page. • Text Control: Displays ”static” text; in other words, text that cannot be changed or edited from the handheld. • Edit Control: Displays and allows editing of text. • Paragraph Control: Displays information in a manner similar to the edit control on multiple lines.
Built-In Components
51
• Check Box Control: Allows one or more items to be “selected” from a set of check boxes. • Radio Button Control: Allows only one item to be “selected” from a set of radio buttons. • Button Control: Allows an action to be executed. For example, clicking a button on a form may cause a jump to another form. • List Box Control: Displays the contents of the form’s linked table in tabular format. • Drop List Control: Opens a drop list of items, of which one can be selected. • Lookup Control: Displays data from a lookup table. • Ink Control: Allows a user to collect signatures or make sketches on the handheld’s screen. • Bitmap Control: Allows a bitmap image such as a company logo to be pasted into a form. • Graffiti Shift Indicator Control: Places an “indicator” graphic on the handheld’s screen that shows the shift status of the Graffiti handwriting recognizer. This control will display different symbols depending on whether Graffiti is in lowercase, shifted, or caps lock mode. • Auto Stamp Control: Automatically enters a date or time stamp in a table column. This stamp can also be viewed on a form by inserting an edit control linked to the same data source as the auto stamp control. • Custom Control: Inserts an SFX control in a form. This button is only active if an SFX extension has been added to the application. To use the controls in your application, you must place them on a form. You do this by clicking a control in the toolbar. The control will be automatically placed on the form, where you can move or resize it using the handles which are displayed in Figure 4.4. Like the application itself, the individual controls have properties that can be set. To access these properties, you can utilize the Content window that is seen in Figure 4.5. First, locate the name of the control in the Content window and right-click on it with your mouse.
52
Chapter 4: Basics of Satellite Forms
Figure 4.4: Handles are used to resize and position controls.
Figure: 4.5: Right-clicking the Content window should display a pop-up menu. Next, you should click the Properties option from the pop-up menu. A dialog box (an example of one is displayed in Figure 4.6) is displayed that you
Database Connectivity
53
can use to change the properties of the control. Depending on the type of control, you will have different properties available.
Figure 4.6: The Properties window for a control. We’ll look at the controls and this process in more depth when we use the controls to develop an application in the next chapter.
Database Connectivity Although Satellite Forms can be used for many types of applications, its strongest feature is the database connectivity it offers. We’ll begin this section by looking at the basics of relational databases and proceed to look at the way Satellite Forms can use them.
Basics of Relational Databases Satellite Forms stores data in a relational database using tables. Simply put, relational databases store data in objects called tables. Each table contains a specific set of data. The data can be any type of information; for example, you can have two tables that are called Movies and Actors. Tables are arranged similarly to a spreadsheet with rows and columns. The Movies table could contain columns for name, date of release, and so on. Each row, or record, of the Actors table contains information about an individual actor. What separates a relational database from a spreadsheet is the way one column relates to another. In our example, the Movies table could store information about movies and the actors that appear in them. However, by storing an actor’s name directly in the Movies table, we would be forced to store it multiple times if an actor happened to appear in several movies.
54
Chapter 4: Basics of Satellite Forms
Without relational databases, this would be the only option. Instead, we can create a reference (called a foreign key) to the corresponding record of the Movies table. This would save a tremendous amount of space and would offer much greater flexibility. For instance, if you had an actor that changed his name, you could simply update it a single time and it would be changed in every movie in which he appeared. Once the tables have been designed, a Graphical User Interface is developed that enables end-users to enter and manipulate data in the tables through a set of controls and forms. Developers with experience using PC tools like Microsoft Access or Visual Basic should already have an understanding of the way that relational database tools work and will have an easy time getting used to the Satellite Forms implementation.
Review In this chapter, we looked at the basics of Satellite Forms including the App Designer, which is where the vast majority of your work will occur. We also looked at the controls that are included with Satellite Forms and what they’re used for. Lastly, we discussed relational databases. In the next chapter, we’ll use the information you learned and expand upon it to build your first Satellite Forms application.
5 Your First Palm Application In the previous chapter, we covered the basics of Satellite Forms, including an overview of the IDE and some basic information about the standard controls that ship with Satellite Forms. This chapter will serve to further our understanding of Satellite Forms, and perhaps more importantly, we’ll build our first Palm application in this chapter. The program will be the standard “Hello World” application, which can be seen in Figure 5.1. After building the application, we’ll look at the process of downloading and testing the POSE emulator and directly on a Palm device.
58
Chapter 5: Your First Palm Application
Figure 5.1: A standard “Hello World” program will be the first application we create in Satellite Forms.
Building Your First Application As you saw in the previous chapter, Satellite Forms is a rapid application development (RAD) tool that enables you to create projects graphically by drawing the GUI, applying properties, and writing some basic code. It is the simple design of Satellite Forms that makes it so popular with developers who are used to complicated tools like Visual Basic or Delphi. With its support for databases, Satellite Forms is ideally suited for the design and development of business applications. Although it excels in many areas, Satellite Forms’ strongest point is its ability to create a rather sophisticated application in a relatively short amount of time. This is particularly evident when the development process is compared to a C++ application created with the standard Palm SDK. However, although the development time of an application is much shorter, there is a trade-off in the execution speed of comparable applications developed with Satellite Forms versus ones created with the Palm SDK. Without a doubt, the Palm SDK will produce a much faster application than one created in Satellite Forms, although this isn’t usually a big problem unless you are interested in creating high-performance games or graphics. Therefore, Satellite Forms should be used mainly as a business and database development tool, areas that are its strong points.
The Satellite Forms Development Process To begin working on a new application, open the Satellite Forms App Designer and create a new project. The project will be unnamed at the start
Building Your First Application
59
and a form, which will serve as the GUI when the program is executed, will be created by default. As you can see in Figure 5.2, the form is the correct size for the Palm OS screen and is empty, so it can be left without changes at the moment. Eventually, it will contain the controls and display data that will be presented to the user so that they can interact with the program and enter appropriate information.
Figure 5.2: A blank form is available when a new application is created. In order to create the GUI, we need to place some controls on the empty form. For many applications, the development of a GUI might involve the creation of several trial layouts. With the limited display size of a Palm OS screen, this is an imperative step in the development of applications. You are limited in screen real estate by the relatively small size of the Palm device, so utilizing a well-planned and -designed GUI is often the most important step in the development process, and can be the difference between an easy development cycle and one that is unnecessarily difficult. In our current example, however, spending time on this matter would be counterproductive because the GUI will only contain one button control and one text control, placed in a manner similar to Figure 5.3.
60
Chapter 5: Your First Palm Application
Figure 5.3: Our first Palm program has a very simple GUI. Because there are only a single button control and a single text control in our application, you can simply place them on the form at this time. To do so, click on the respective buttons in the toolbar and the controls will appear on the form. Next, drag and resize them so that they resemble the layout shown in Figure 5.4.
Figure 5.4: Your controls should look similar to this figure. In the previous chapter, we learned that you can set the properties of a control by right-clicking on the control and selecting Control Properties from the pop-up menu that appears. The controls have some basic properties that are identical, while other properties are for specific needs. The text control and button control need a few properties altered. First, alter the text control so that its properties resemble those in Figure 5.5.
Building Your First Application
61
Figure 5.5: The properties of the text control. Before moving on to the button control properties, we’ll look at the text control in more detail. You may wonder why we didn’t simply alter the text property of the control to read “Hello World”, as this would have completed the application in a single step. Instead, we placed an “X” inside the property (it is only used as a placeholder so that you can see the text control on the form). While we could have placed “Hello World” into the property and it would have worked for this simple application, we are interested in learning how we can alter the properties of the controls using simple programming events called scripts. For our example, we’d like to change the text from an “X” to “Hello World” when the button is clicked. The next step is to change the properties of the button control to look like Figure 5.6.
Figure 5.6: Sample properties for the button control.
62
Chapter 5: Your First Palm Application
The use of an application’s properties is nothing new; we have already looked at this in Chapter 3. Once the properties of the controls have been changed, the next step is to set the properties of the application itself. Like the control properties, you can easily set the project application properties. Select Edit, Project Properties, and then set the properties so that they are like Figure 5.7.
Figure 5.7: The application properties should be similar to this. You’ll notice that we left the Initial Form set to Form 1, as it’s the only form we have in this example. The Initial Form setting is useful for applications that contain multiple forms, allowing a developer to display a particular form when the application is first opened. We will leave the Creator ID as it is set by default along with the Database drop-downs, which assign particular types of database formats. The Creator ID is something that is particularly important to Palm developers. Every Palm OS application requires a unique four-character Creator ID. You can search for and register an available ID by visiting http://dev.palmos.com/creatorid/. The other Options can also be left to their original settings, and the Options all set to their original settings as they had little or no effect on our application. The only item we changed was the Name of Application field to read “Hello World”. This would be a good time to save your first project. If you select Save As from the File menu, the Save As dialog box will appear.
Satellite Forms Scripts
63
From this dialog box, change to a directory of your choice, or create a custom directory for the project (such as c:\Palm\Projects\SatelliteForms\). Next, change the filename to read “SF Hello World” and then click the Save button.
Satellite Forms Scripts Satellite Forms scripts are small programs written using a custom language very similar to Visual Basic. The scripts are event-driven. That is, they are programs that respond to certain actions (or events) that occur in the program such as a button being clicked. In our example, we want to change the text property of the text control to “Hello World” when the button control is clicked. In order to create the script, we need to let Satellite Forms know that we want it to occur when the button is clicked. First, double-click the button control (or right-click on it and select Properties from the pop-up menu). The properties window is displayed; choose the Edit button that is located directly beneath the Action when Clicked text box (which should read “None” at this time). The properties window can be seen in Figure 5.8.
Figure 5.8: The properties window allows us to set up scripts. When you click the Edit button, the Control Action and Filters window is displayed. From the Action Type drop-down list, we need to select Run Script. This window can be seen in Figure 5.9 with the selection already made.
64
Chapter 5: Your First Palm Application
Figure 5.9: The “Run Script” option should be selected. Our next step is to click the Edit Script button, which will place us for the first time in the Satellite Forms application scripts editor. We only need to change a single property in this script, which will be executed whenever the button is clicked. Therefore, this script will be a single line which reads as follows: Text1.Caption = “Hello World”
You can enter the line into the application scripts editor and then close the editor. If you are familiar with the Visual Basic language, this will look very familiar to you. This line simply means to take the text control caption property (text1.caption) and make it equal to the text information “Hello World”. Later examples will allow us to look at the programming language that is included with Satellite Forms in more detail. At this time, you can close the application scripts editor and save your project again. In the next section, we’ll look at downloading the application to POSE or an actual Palm OS device so that you can test its functionality.
HotSyncing with POSE While we covered the basic installation of POSE in Chapter 3, there are some specific setup requirements and issues that you’ll encounter when using POSE with Satellite Forms. Let’s take a detailed look at these special instructions that will ultimately make developing with Satellite Forms a much easier process. First, start POSE and open a non-debug ROM file. These are the types of ROMs available if you upload your own or if you have downloaded Visor, Palm, or other ROMs. If you have downloaded a set of ROMs, you can
HotSyncing with POSE
65
differentiate debug ROMs from the non-debug ROMs by their names. For instance, a debug Palm IIIx ROM would be named “Palm OS 3.1 IIIx dbg.rom” while the non-debug version would be “Palm OS 3.1 IIIx.rom”. If you cannot remember the required steps for setting up or opening POSE, refer to Chapter 3 for this information. Once POSE is up and running, right-click it and a pop-up menu will appear similar to Figure 5.10.
Figure 5.10: POSE displays a pop-up menu when right-clicked. From the menu, select Settings, Properties. The Properties window is displayed and can be seen in Figure 5.11.
Figure 5.11: This window allows us to set several POSE properties. You need to select the “Redirect NebLib calls to host TCP/IP” check box if it is not already checked. Enter your name or another description under the HotSync User Name field. The next step is to open HotSync inside the emulator. The HotSync icon should be immediately visible inside the emulator
66
Chapter 5: Your First Palm Application
as can be seen in Figure 5.12. If it is not, you should restart the emulator and select the application icon to display it.
Figure 5.12: Selecting the HotSync icon is the next step. Once HotSync has been selected, the POSE emulator should now look like Figure 5.13.
Figure 5.13: The HotSync welcome window is displayed. The menu button, which is the lower-left silk-screen button on the emulator, should be clicked next. It will display a menu that looks similar to Figure 5.14, and from this menu, we can select Modem Sync Prefs.
HotSyncing with POSE
67
Figure 5.14: The menu allows us to select Modem Sync Preferences. Select Network from the screen and click the OK button. The Modem Sync screen is displayed and can be seen in Figure 5.15.
Figure 5.15: This screen allows you to select an Internet service provider. Next, click Select Service. From the resulting screen, you can simply click Done, because for our example the service itself doesn’t matter. Click the POSE menu button (again, it’s at the lower left of the silk-screen surface), and you will see the menu shown in Figure 5.16. Select Primary PC Setup from the menu.
68
Chapter 5: Your First Palm Application
Figure 5.16: Select Primary PC Setup from this menu. You should enter as much information as possible into the Primary PC Setup screen, a sample of which can be seen in Figure 5.17. If you don’t know your IP address (Primary PC Address), you should enter 127.0.0.1 into the field. The subnet mask is an optional field, as is the name. Click OK when you have entered as much of the information into the fields as possible. In the lower- right portion of your screen is the Windows system tray, which should contain a HotSync icon in it. Right-click on the icon and select Network if it is not checked. Next, you should right-click the icon again, but this time select Setup.
Figure 5.17: The Primary PC Setup window allows you to assign an IP address.
HotSyncing with POSE
69
When you click Setup, a window will be displayed similar to Figure 5.18.
Figure 5.18: The HotSync setup has tabs located near the top of the window. From the tabs located at the top of the screen, select Network. Once the Network tab is selected, if there are any names listed in the box which is visible in Figure 5.19, we need to select them.
Figure 5.19: We need to select the users that appear in this list. Click the OK button once you have selected the names. That’s the end of the process. To see if everything is set up correctly, we need to choose the HotSync icon in POSE. It will display the HotSync window, from which you can click the large icon (the one with the phone) in the center of the screen (see Figure 5.13). If you have users created, you will be presented with a window that displays user names as shown in Figure 5.20. Otherwise, you will need to create a new user name; you can use “POSE” or another descriptive name that you choose.
70
Chapter 5: Your First Palm Application
NOTE If your machine doesn’t have a permanent IP address, a Network dialer will appear when you try to HotSync. It doesn’t affect the actual process but can be an aggravation.
Figure 5.20: You need to select a user from this screen. If everything is set up correctly, you should see the progress of the HotSync, and when it’s finished a button will appear that needs to be clicked to reset POSE. When the emulator finishes the reset, you will find the normal setup options for a Palm device. If you click the application button, you will see a list of applications that now includes a Satellite Forms icon. You can use this icon to choose a specific Satellite Forms application for execution. The last thing we need to do before downloading our application to POSE is change the debugging option. If you do not change this setting, you will become inundated with debug errors when you try to run Satellite Forms. You will have to click the Continue button on the error message several times before you will eventually be allowed to test the application. To change this debug option, you should right-click on POSE, which will display a menu similar to Figure 5.10. From the menu, select Settings, Debugging. The Debug Options window is displayed with all items selected by default. You should deselect all of the options. Figure 5.21 displays the menu as it should appear after you deselect it.
Figure 5.21: Everything should be deselected.
Downloading to Satellite Forms
71
This would be a great time to save the session settings so that you can open the session specifically for use with Satellite Forms. You can right-click POSE and choose Save As from the menu. Give it a name that you’ll remember such as “SatForms Palm III”. Later, when you create specific sessions for other development tools or other ROMs, you can immediately distinguish between them.
Downloading to Satellite Forms We’re now ready to download the project to POSE. First, if you have closed Satellite Forms, you need to reopen the “Hello World” project we saved earlier in the chapter. The next step is to click Handheld, Download App & Tables. The Download Application to Handheld window, which can be seen in Figure 5.22, is displayed.
Figure 5.22: Download Application to Handheld is displayed. The next step is to click the HotSync button in POSE; this displays the HotSync window. Next, click the icon in the middle of the POSE screen that has an image of a phone on its left side. If everything worked correctly, you should see a message letting you know that HotSync finished and there shouldn’t be any errors. The next step is to click the Application icon from the silk screen area of POSE. If you do not see a Satellite Forms application displayed, you can try to manually upload the Satellite Forms SDK PRC file, and then perform another HotSync. If you do see an icon, you can skip over the next three paragraphs; otherwise continue following the steps to manually add the Satellite Forms SDK PRC to POSE. To do this, open Windows Explorer by right-clicking the Start button and then selecting Explore from the pop-up menu. Using Explorer, visit the Satellite Forms Bin directory, which will be at c:\program files\satellite forms\bin if you used the default installation settings. The Satellite Forms portion of the directory may be slightly different depending on the version you are using. For instance, if you are using Satellite Forms 4 Enterprise Edition, the directory would be c:\program files\satellite forms ee\bin.
72
Chapter 5: Your First Palm Application
Once you are in the directory, you need to double-click the icon that reads something similar to “SF40SDK.PRC”. When you double-click the file, a window pops up similar to Figure 5.23.
Figure 5.23: The Install Tool allows you to install PRC files to POSE. Click Add and from the dialog box choose the file named SDDI_PalmDB.pdb from the same directory where the PRC file was located. Click the Done button and then perform the POSE HotSync again. This should have uploaded the Satellite Forms SDK runtime. If you are not automatically instructed to perform a reset, you should right-click POSE and select Reset from the pop-up menu. Once it has finished the reset, you should click the Application silk screen button and then look for the Satellite Forms icon. If it’s not visible, refer to the section called “Troubleshooting POSE with Satellite Forms,” later in this chapter. Otherwise, you should select Handheld, Download App & Table again within Satellite Forms and then perform another HotSync within POSE. To run your application, you should click the Satellite Forms icon in POSE. A list of Satellite Forms applications will be present. You can choose the project we just uploaded, which should read “Hello World”. The POSE display should look similar to Figure 5.24. If you click the “Change Text” button, the caption property of the Text1 control will be changed to read “Hello World”. If everything is now working with POSE, you should save the session again. Otherwise, if you are having problems, you should look at the next section for a few more options.
Troubleshooting POSE with Satellite Forms
73
Figure 5.24: The Hello World application running in POSE.
Troubleshooting POSE with Satellite Forms POSE is normally a very reliable application, but it often has problems with Satellite Forms. While it’s impossible to place blame specifically on POSE or Satellite Forms, there are a few issues that you may encounter. We’ll look at a few of those issues here and look at what we can do to make your experiences as easy as possible. The first thing you should do when using POSE with Satellite Forms is make certain to use a non-debug ROM. It’s worth repeating, as the debug ROMs will work sometimes and other times they fail miserably. Additionally, the last step mentioned in the previous installation process was to deselect all debug options. You should always do this whenever you change ROMs. In fact, if you take the time to set up a particular ROM for use with Satellite Forms, you would be well served to take the time to save it. If you seem to be having HotSync problems, there are a couple of additional ways that we can download projects to POSE. First, you could use a null serial cable between multiple COM ports on your PC and then set the emulator to use COM 2. We won’t look at this in great detail because there is specific information in the Satellite Forms documentation and Web site that offers step by step installation instructions. There is one last option that you can use to download your projects to POSE. First, open Explorer by right-clicking the Start button and then selecting Explore from the pop-up menu. Next, open POSE using a nondebug ROM with all debug options deselected. Using Explorer, visit the Satellite Forms Bin directory.
74
Chapter 5: Your First Palm Application
There are two files that need to be uploaded from the BIN directory: SF40SDK.PRC and SDDI_PalmDB.PDB. To upload them, you can highlight them and then drag them onto the emulator. They will be installed immediately. Next, you should perform a reset of the device by right-clicking on POSE and then selecting Reset. After the reset, click the Application silk screen button, and then you should see the Satellite Forms icon. The next step is to choose Handheld, Download App & Table from within Satellite Forms. When the Download App & Table dialog box appears, click the Abort button. After clicking the Abort button, you should open Windows Explorer by right-clicking the Start button and then choosing Explore. Go to the directory that your application was saved in and you should find a file named something similar to ESMSF0000$Chapter5.PDB. You can click and drag this file onto POSE and then execute Satellite Forms, choosing Hello World from the list of applications. You should see something like Figure 5.24.
Downloading to a Live Device If you would rather download to an actual Palm OS device, the process is much easier. You simply choose Handheld, Download App & Tables in Satellite Forms and then perform a HotSync with your device. It will be available to test on your device and you can run it in the same manner as you can in POSE. The rest of the samples in the book will utilize POSE, as it offers debugging features and the ability to test applications on multiple devices. If you would prefer, however, feel free to use a device if you have access to one.
Conclusion Additional functionality needs to be included to make this a truly useful program, but you can see how powerful Satellite Forms really is. Obviously, our sample application is a very simple example program that only displays “Hello World” on a Palm screen. However, it has allowed us to look at several key Satellite Forms areas such as script writing, placing controls on the form, and downloading Satellite Forms to POSE or a device.
6 Satellite Forms Database Applications In the last chapter, we developed our first Satellite Forms application. Although it was extremely simple, it allowed us to look at the way a Satellite Form application is constructed. We created a GUI with some of the built-in controls and then set properties for the controls. We also created a simple programming script that altered the caption property of the text control to read “Hello World” when the button was clicked. In this chapter, we’ll expand upon our Satellite Forms knowledge and build a database application, a sample of which can be seen in Figure 6.1. It will be used to store data about a video collection including information such as title, type, classification, year produced, cost, rating, and notes.
78
Chapter 6: Satellite Forms Database Applications
Figure 6.1: The application we’ll build in this chapter running on a Palm device.
Creating the Forms The GUI for this application is going to be much more involved than the “Hello World” application we built in the previous chapter. In addition to the obvious increase in the amount of information we’ll be displaying, we’ll also use multiple forms and several controls that we have utilized up to this point. The first form will be used as an opening splash screen and the second will be used to enter, edit, or find movie information. To begin, we need to open Satellite Forms and create a new application by selecting File, New Project. When the project is started, an empty form will be available. As you can see in Figure 6.2, the empty form is named Form 1 by default.
Figure 6.2: Form 1 is created when you start a new project.
Creating the Forms
79
We can change the caption of the form by double-clicking it, which displays its properties window. Change the properties of Form 1 to reflect those seen in Figure 6.3.
Figure 6.3: We need to change the properties of the form. Next, click the OK button on the properties window to apply the changes you have made. This form will be used to display a sort of splash screen for our application. While we could use a text control and display simple text information when the application is started, Satellite Forms gives us access to a bitmap control for displaying bitmap images. This will give the application a much more professional look. The bitmap control allows a bitmap to be placed on your form, but you cannot assign it like other controls. First, you need to create the bitmap using your favorite graphics editor. The size should be 160×160 or smaller to accommodate the standard Palm OS screen. In addition to size, the bitmap should also be black and white. Once you have finished, save your bitmap and then select the entire image. Copy the bitmap to the Windows clipboard by using the image editor’s menus or using the Ctrl-C key combination. Once the image has been copied to the Windows clipboard, switch back to Satellite Forms. Select the Bitmap Control toolbar button. You may have noticed that this button was not available earlier. This is because you are only allowed to use it when Satellite Forms finds an appropriate bitmap on the clipboard. When you select the control, it will automatically paste the bitmap onto the form. This can be seen in Figure 6.4. You can then manipulate it like any other control by dragging it into position or double-clicking the bitmap to open its properties dialog and set the position.
80
Chapter 6: Satellite Forms Database Applications
Figure 6.4: Selecting the bitmap control automatically pastes the image from the clipboard. Now that we have the bitmap on our form, you should position it if you need to. For instance, if the size of your bitmap is less than 160×160, you may want to center it in the form. At this point, if we were to run the application, the bitmap would be displayed but the application would not really do anything in addition to that. We need to instruct the program to move on to another form, but first we must create the form. Select Edit, Insert Form to create a new form. We also need to alter the properties of the form like we did to the first form. The only property we need to alter for this form is the name property, which should be changed to “frmEntry”.
Navigating the Forms Now that the form is available, the next step is to return to frmOpening so that we can add a button control. The button control will be used to move forward to the next form when it is clicked. You can add the button control and position it so that it is similar to Figure 6.5. NOTE You may have noticed that the forms were both named with a prefix of “frm”. This type of naming convention is known as Hungarian notation and is used by many developers for naming components and variables in a project. Appendix C contains information about common naming conventions and how to utilize them in your projects.
Creating the Forms
81
Figure 6.5: The new button control will allow you to navigate to frmEntry. The next step is to set some properties for the control. Double-click the button control to display the properties window. You should alter the properties so that they are consistent with Figure 6.6.
Figure 6.6: The button control should have these properties. Next, we need to instruct the button to open frmEntry when it has been clicked. We can accomplish this by clicking the Edit button located beneath Action when Clicked and then choosing Jump To Form from the drop-down list that appears. We also need to select the form that will be opened by choosing the Target Form from the drop-down menu. Figure 6.7 displays this information.
82
Chapter 6: Satellite Forms Database Applications
Figure 6.7: The target form needs to be set. Click OK and then OK again to apply the changes we’ve made. This form is now complete with the exception of the script that will display the Continue button. Select View, Show Scripts to open the Script Editor. On the left, you will see a list of Forms and their associated scripts. Click the plus sign (+) located next to frmOpening. Next, double-click AfterOpen. This will create a blank script that will be executed after the form is loaded. In the script window, enter the following lines into the editor: Dim X For X = 1 to 10000 Next X btnContinue.Visible = True
The first line, Dim X, declares a variable named X to be used as a counter. Next, we set up a For…Next loop that will count from 1 to 10,000. This loop only acts as a slight delay so that the button isn’t displayed immediately. Once the counting has finished, the program moves on to set the Visible property of btnContinue to “True”. This will display the button and allow the user to click the button which, in turn, will open frmEntry.
Creating a Palm Database Using Satellite Forms Creating a database in Satellite Forms is a fairly intuitive process. Before we look at the actual steps involved in Satellite Forms database creation, it’s important to have a basic understanding of databases. Similar to a spreadsheet, a database is simply a collection of related information that
Creating a Palm Database Using Satellite Forms
83
contains rows and columns that are known as records and fields. A database field is a piece of information that is composed of smaller pieces of data. For example, a field could be a name, address, or phone number which is composed of smaller pieces of data, which in this case would be letters or numbers. On the other hand, a record is a group of these fields that encompass a collection of data. In the example we mentioned for fields, the record would be the name, address, and phone number of a given entry. Lastly, you can think of a table similarly to a spreadsheet in that it contains the fields and records. There are two basic types of databases: flat-file databases and relational databases. Flat file databases use a single table at a time, while relational databases can work with two or more tables simultaneously. Flat file databases are very simple to use but much less powerful than their relational counterparts. Simply put, relational databases let you relate tables or even multiple database files by using information that is common. For example, if you decide to track salespeople and the sales they make, you can put them each in a separate table and relate them because it is the salespeople that actually complete the sales. It is this idea of relating, or linking as it is commonly called, that makes a relational database so different from a flat file database. Satellite Forms uses the relational approach, while a standard Palm database does not, and after completing this section, you will see why Satellite Forms is so popular among database programmers. The first step in creating a database in Satellite Forms is to create tables that will store the database information.
Creating Tables in the Database Select Edit, Insert Table to open the Table window. As you can see in Figure 6.8, the table defaults to a name of Table 1 and an initial column labeled COL_A. We begin by changing the name of the table to MovieTable. The next step will be to double-click the “COL_A” table column, which will open the Edit Column window. You can edit the window contents as follows: Name: TITLE Data Type: Character Width: 100
84
Chapter 6: Satellite Forms Database Applications
Figure 6.8: The Table window allows us an easy way to create databases for our application. This sets the column for the title of our movies, which will use character data that has a maximum length of 100 characters. When you are finished, click the OK button. The next step will be to add the second column of the table. Click the New button and then enter the following information that will hold our Movie Type information: Name: TYPE Data Type: Character Width: 50 After clicking OK, the table should look similar to Figure 6.9.
Figure 6.9: The first two columns in MovieTable.
Creating a Palm Database Using Satellite Forms
85
If your table looks like Figure 6.9, you can continue to enter the other columns. Otherwise, you should repeat the previous steps to see where you went wrong. These are the final columns that make up the MovieTable: Column Name: CLASS Data Type: Character Width: 50 Column Name: STATUS Data Type: Character Width: 50 Column Name: YEAR Data Type: Character Width: 4 Column Name: COST Data Type: Numeric Width: 4 Column Name: RATING Data Type: Numeric Width: 1 Column Name: NOTES Data Type: Character Width: 200 After entering this information, verify that the MovieTable looks like Figure 6.10. If it does not, please change any column that doesn’t match.
Creating Additional Tables Now that you understand the process, we are going to create three additional tables that will store data for drop-down entries into the previous table. For instance, instead of manually entering a value into an edit control to be stored in the Rating column from the MovieTable, we can create a drop-list control that retrieves values 1 through 5 from a Table named RatingTable. If this isn’t clear at this time, you needn’t worry; we’ll look at this in more detail as we construct the GUI for frmEntry. Before moving on, you should understand that the Rating in our database is a numeric value
86
Chapter 6: Satellite Forms Database Applications
that rates the quality of a movie, and not the voluntary system sponsored by the Motion Picture Association of America that rates the intended age group that should view a movie (such as PG, G, R).
Figure 6.10: MovieTable should look like this when finished. Here are the tables and the information that need to be created: Table: ClassTable Column Name: CLASS Data Type: Character Width: 50 Table: RatingTable Column Name: RATING Data Type: Numeric Width: 1 Table: TypeTable Column Name: TYPE Data Type: Character Width: 50 It’s important to note that the data types and widths of the above columns must match the columns we created for the MovieTable. Once you have finished creating the three tables, they should look like Figure 6.11. You will also need to create the data that will appear in the drop-down list. This is accomplished by selecting the Editor tab from the three tables and
Creating a Palm Database Using Satellite Forms
87
then entering data into the fields. You can see the required entries in Figure 6.12; the information should be entered at this time.
Figure 6.11: Your three tables should match these.
Figure 6.12: This data will be available later in the drop-down list controls.
88
Chapter 6: Satellite Forms Database Applications
Creating the GUI The next step is to create our GUI. If it isn’t displayed, open frmEntry by clicking it in the Projects Content window located on the left side of the screen. Next, we need to add an edit control and text control to the form. Edit the properties of the text control’s name to read “Name”. You can do this by double-clicking the control to display its properties window, changing the Name of Control to “Name”, and then clicking the OK button. Next, double-click the form in an empty area to display its properties window. You need to assign the form to link to MovieTable. You can see the required change in Figure 6.13.
Figure 6.13: MovieTable needs to be linked to frmEntry. Now we can assign the controls on the form to a specific database table. Begin by double-clicking the edit control to display its properties. Change the fields so that they match Figure 6.14.
Figure 6.14: The edit control will be assigned to the Title column in MovieTable.
Creating the GUI
89
You can position the two controls so that they appear similar to Figure 6.15.
Figure 6.15: Our GUI begins to take shape. You can see that the text control acts as a sort of label to identify the edit control to the user who will be entering data into the form. With this in mind, create seven additional text controls, alter their name properties, and place them on the form so that they are in approximately the same position as those in Figure 6.16.
Figure 6.16: The text controls act as labels for the other controls. The next step is to create the additional controls that will be used for data entry. We’ll begin by creating our first drop-down list control; drag the control next to the “Type” text control on the form. You should also resize it so that it begins just to the right of the text control and ends near the right
90
Chapter 6: Satellite Forms Database Applications
side of the form. Next, double-click it to display its properties. We are going to set the List Contents for this control along with the Column name as well. These changes are reflected in Figure 6.17.
Figure 6.17: The properties should be changed to look like this window. Now that you have created a drop-down list, you can add two more dropdown lists to the form and place them next to the Class and Rating text controls. You can also change their properties to look like Figure 6.18 and Figure 6.19.
Figure 6.18: The properties for the Class text control.
Creating the GUI
91
Figure 6.19: Rating is the last drop-down list control for our project. frmEntry should now appear similar to Figure 6.20.
Figure 6.20: We need to add a few additional elements to finish the GUI. Our next step is to add four edit controls to the form, placing them next to the remaining text controls. They should be renamed and assigned to the data columns shown in Table 6.1. Table 6.1: Data Columns for the Edit Controls Name
Form’s Data Column
eStatus eYear eCost eNotes
STATUS YEAR COST NOTES
92
Chapter 6: Satellite Forms Database Applications
As you can see in Figure 6.21, our GUI is nearly completed, but we still need to create buttons for navigational purposes.
Figure 6.21: The GUI is finished with the exception of navigational buttons.
Adding Control Buttons to Our Forms We need to create four button controls to navigate the database in our project. The buttons will allow the user to move to the previous record, delete the record, create a new record, or move to the next record. With most development tools, this would take some programming work, but not with Satellite Forms. We will simply place four buttons on the form, rename them, set their name properties, and assign an “action when clicked” event to occur. To begin, place four buttons on the form along its bottom edge. Next, change the properties of the buttons as indicated in Table 6.2. Table 6.2: Properties for the Button Controls Name
Text
Action When Clicked
btnPrevious btnDelete btnNew btnNext
Previous Delete New Next
Go to Prev. Record Delete Record Create Record Go to Next Record
The form is now finished and should look like Figure 6.22. The last step in our application is to change the project properties so that we can name the project something that will differentiate it on the device or emulator. Choose Edit, Project Properties and then change the fields so that they are identical to those seen in Figure 6.23.
Testing the Application
93
Figure 6.22: Our GUI is now finished.
Figure 6.23: The Project Properties need to be altered.
Testing the Application You should now save the application to a directory that you’ll remember by using the File, Save menu. After you have saved it, the next step will be to open POSE (or if you are using an actual Palm device, the steps will be nearly identical). If you saved your session when you last used POSE, it will automatically load the session and you’ll be ready to download the project. Otherwise, you must open the saved session so that POSE will already
94
Chapter 6: Satellite Forms Database Applications
have the Satellite Forms SDK PRC file on it. The figures in this section will use a Palm V for display purposes, but it doesn’t matter which ROM you are using. The next step is to select Handheld, Download App & Table from within Satellite Forms. As you can see in Figure 6.24, a window will appear instructing you to perform a HotSync. Click the HotSync button in POSE (or on your device) which will download the application and the database tables.
Figure 6.24: The Download Application to Handheld window will instruct you to do a HotSync. After the HotSync, you should run Satellite Forms. A list of available Satellite Forms applications should appear, an example of which can be seen in Figure 6.25.
Figure 6.25: Satellite Forms displays a list of available applications. When you choose MovieDatabase from the list, a window will appear with our opening screen. The command button will not appear immediately, but given a short period of time, it will appear as we had hoped. You can see this in Figures 6.26 and 6.27.
Testing the Application
95
Figure 6.26: The button does not appear initially.
Figure 6.27: After a short period of time, the button is visible. If you press the Continue button, you will be presented with a screen that looks identical to our GUI. You should check the drop-down list controls and all of the edit controls to see if they are working. Additionally, you should enter some data into the fields to test them. The final application appears in Figure 6.28.
96
Chapter 6: Satellite Forms Database Applications
Figure 6.28: The entry screen running in POSE.
Conclusion In this chapter, we created our first Palm database program and along the way learned how Satellite Forms allows us to create tables that can be used for drop-down list controls. You could improve this application by creating a look-up form so that you can quickly find the data you are interested in. In the next chapter, we’ll look at this type of process when we create a program that will store dates, times, and signatures for the purposes of billing.
7 Advanced Satellite Forms Database Development In the previous chapter, we developed our first Satellite Forms database application. We are going to use this chapter to introduce you to several new database features. As in previous examples, we’ll begin with the creation of a GUI with some of the built-in controls and then set properties for the controls. The program we’ll construct in this chapter will be a Time & Billing program that will track the time spent at a customer’s location with details such as date, time, and a customer signature being stored in a database. We’ll also learn how to create a “Look Up” form, which can be seen in Figure 7.1, that will allow us to list the jobs completed by customer name.
100
Chapter 7: Advanced Satellite Forms Database Development
Figure 7.1: The Look Up form will allow us to display information pertaining to a particular customer.
Creating the Forms The GUI for this application will be similar to the one in the Movie Database. We are going to have an opening screen and a data entry screen. Additionally, we’ll create a form that will be used to look up the data for a customer. The data will be listed so that it looks something like a spreadsheet. To begin, we need to open Satellite Forms and create a new project. We can change the caption of the default form by double-clicking it, which displays its properties window. Change the properties of Form 1 to reflect those seen in Figure 7.2.
Figure 7.2: We need to change the properties of the form.
Creating Tables for the Application
101
Next, click the OK button on the properties window to apply the changes you have made. This form will be used to display a splash screen for the application. Create a bitmap in your favorite editor and then copy it to the Clipboard. Next, select the Bitmap Control button from the Satellite Forms toolbar. Once you select the control, it will automatically paste the bitmap onto the form. You should center the control on the form. The next step is to create a new button control and place it on the form. The caption property needs to be set to a blank value (nothing in the box). This will allow us to place the button over the entire bitmap so that whenever the user clicks the bitmap, it will open the next form. Select Edit, Insert Form to create a new form. We need to alter the properties of this form like we did to the first form. The only property we need to alter for this form is the name property, which should be changed to “frmTime”. Before moving on, we’ll also create a form called “frmFind” using the same process. This form will be used to search through the data. Now, return to frmOpen and then open the properties for the button control. Resize it so that it covers the entire form and then change the “Action When Clicked” event to open the frmTime form. You can now close frmOpen and if you closed frmTime when you were working on the other forms, you can open it again.
Creating Tables for the Application Select Edit, Insert Table to open the Table window. We begin by changing the name of the table to TimeBill. The next step will be to double-click the Col_A table column; this will open the Edit Column window. Edit the window contents as follows: Name: CUSTOMER Data Type: Character Width: 50 The next step will be to add the additional columns of the table. Click the New button and then enter the following information into separate column entries: Column Name: DATE Data Type: DATE Width: 10
102
Chapter 7: Advanced Satellite Forms Database Development
Column Name: TIMEBEGIN Data Type: Time Width: 11 Column Name: TIMEEND Data Type: Time Width: 11 Column Name: SIGNATURE Data Type: Ink Width: 10 Most of this should look familiar to you. However, the ink data type is something new. It will allow us to draw an image on the screen and then store the image information in the SIGNATURE column of the table.
Creating the frmTime GUI The next step is to create the GUI for frmTime, but first, we need to assign frmTime to link to the TimeBill table. You can assign frmTime to the TimeBill table by double-clicking the form and then changing the dropdown list in the form’s properties window. Once the table is set, we need to add four edit controls to the form with the following properties: Name: eCustomer Column in Form’s Table: CUSTOMER Name: eDate Column in Form’s Table: DATE Name: eBegin Column in Form’s Table: TIMEBEGIN Name: eTimeEnd Column in Form’s Table: TIMEEND
Creating the frmTime GUI
103
You should place the controls so that they are in approximately the same position as those found in Figure 7.3. The order, from top to bottom, is the same order as the previous list. You’ll also notice that the figure contains a heading that says “Time & Billing”. This is a type of control called the Title control. You should place one on your form at this time. It will automatically be displayed at the top of the form and you can alter it to read “Time & Billing” by double-clicking on the control and editing its caption.
Figure 7.3: The form with the edit controls in place. With the edit controls in place, we can now create text controls to label them. Create these text controls so that they appear like Figure 7.4. Before we create our navigation buttons, we need to create an ink control that will be used to draw on the screen. Use the following properties for the control: Name: Ink1 Column in Form’s Table: SIGNATURE You should place the control on the form similar to Figure 7.5.
104
Chapter 7: Advanced Satellite Forms Database Development
Figure 7.4: The labels are now in place.
Figure 7.5: The ink control will be used for capturing the signature.
Database Navigation We need to create four button controls to navigate the database in our project. The buttons will enable the user to move to the previous record, delete the record, create a new record, or move to the next record. You can place them along the top edge of the form using the following properties: Table 7.1: Navigation Buttons Name
Text
Action When Clicked
btnPrevious btnDelete btnNew btnNext
Goto Prev. Record Delete Record Create Record Goto Next Record
The form should now look like Figure 7.6.
Database Navigation
105
Figure 7.6: The data navigation buttons are now in place. Now, we need to create two more buttons and place them next to the eBegin edit control and eTimeEnd edit control. The buttons should be created as follows: Table 7.2: Buttons That Execute Scripts Name
Text
Action When Clicked
btnBeginTime btnEndTime
In Out
Run Script Run Script
The scripts we need to create are both rather easy. We want to click btnBeginTime to automatically enter the current time into eBegin edit control. Likewise, btnEndTime should enter information into the eTimeEnd edit control. To enter the btnBeginTime script, first open the properties window of the button by double-clicking on it. Next, click the Edit button located beneath Action When Clicked and then click the Edit Script button in the Control Actions and Filters window. Once inside the script editor, enter this line: eBegin=SysTimeToTime(GetSysTime)
The line simply sets the eBegin edit control equal to the current system time (GetSysTime), but first it converts the internal time to a format we can understand (SysTimeToTime). Do this same procedure for btnEndTime as well, assigning eTimeEnd to the time value. The line is as follows: eTimeEnd=SysTimeToTime(GetSysTime)
The form is nearly complete, and with btnBeginTime and btnEndTime in place, it should appear as Figure 7.7.
106
Chapter 7: Advanced Satellite Forms Database Development
Figure 7.7: We are almost finished with this form. The form should work now for entering data and navigating data, but we are going to add the ability to search through the data and display it in a spreadsheet-like fashion. If you remember from earlier, we already created a form called frmFind for such purposes. We need to create a button control to open this form. It should be placed at the top of the frmTime form with the properties that can be found in Figure 7.8.
Figure 7.8: btnFind will be used to open frmFind. The frmTime form is now finished and should look like Figure 7.9.
Building the Search Form
107
Figure 7.9: frmTime is now finished.
Building the Search Form We will now focus our attention on frmFind. We’ll begin by adding several controls to the form and setting their properties as follows: Control Type: Title Control Caption: Customer Look Up Control Type: Text Control Caption: Customer Control Type: Drop List Name: dlCustomers Control Type: List Box Control Type: Button Control Caption: Exit You should arrange the controls so that they are something like Figure 7.10. The first step is to verify that the properties of the drop-down list control are consistent with Figure 7.11. If they are not, you can make the necessary changes.
108
Chapter 7: Advanced Satellite Forms Database Development
Figure 7.10: The GUI is completed with these five controls.
Figure 7.11: Properties of the drop list control should be set according to this figure. Once you have verified the drop list control properties, you should proceed to set up the form to use the TimeBill table as the linked table. This can be set by double-clicking the form and then selecting the table from the properties window using the Linked Table drop down. Now that the form has a linked table, we need to set some properties for the list box control. We need to add three categories to the Display Columns. If you double-click the list box control, its properties window will be displayed. It can be seen in Figure 7.12.
Building the Search Form
109
Figure 7.12: The list box control properties are displayed when you doubleclick it. The next step is to click the Add button in the properties window. This will display the Edit Column window, which can be seen in Figure 7.13. This window will enable you to select columns from the linked table. In this window, you should select DATE from the Column drop-down list.
Figure 7.13: The Edit Column window enables you to choose columns to display. After selecting DATE, click the OK button. This will take you back to the properties window, from which you should add entries for TimeBegin and TimeEnd. The properties window, which is now finished, should look like Figure 7.14. Once you have added the columns, you can click the Edit button from the properties window. This will open the Control Action and Filters window. You should click the Filters Tab at the top of the window. It will look something like Figure 7.15.
110
Chapter 7: Advanced Satellite Forms Database Development
Figure 7.14: The properties window with all three entries.
Figure 7.15: This tab allows us to filter the data in the table. Click the Add button to create a new filter. Alter the properties to match Figure 7.16. Click OK when the Create New Filter window has all of the correct entries. The filter sets the ListBox to display items that match the drop list control. The last step is to set the properties of btnFind. We need to set it to open frmTime when it is clicked. To do so, double-click the button and then click the Edit button located beneath Action When Clicked. Set the Action Type to “Jump to Form” and the target form to frmTime. Additionally, we need to set a filter for this button. Click the Filters tab and then check the Discard Existing Filters box.
Building the Search Form
111
Figure 7.16: These are the correct settings for the Create New Filter window. Before you save the application, you should set the name property to “Time&Billing” to differentiate it from other Satellite Forms applications. Select Edit, Project Properties to display the properties window. You can also make other changes here, such as setting the initial form. You can see all of the changes in Figure 7.17.
Figure 7.17: The properties for the application can be set in the Project Properties window.
112
Chapter 7: Advanced Satellite Forms Database Development
You can now save the project by choosing File, Save. Like the other projects, you should save it to some place you’ll easily remember.
Testing the Application After you have saved the application, the next step will be to open POSE (or if you are using an actual Palm device, the steps will be nearly identical). If you saved your session when you last used POSE, POSE will automatically load it and you’ll be ready to download the project. Otherwise, you must go through the process of adding the SDK PRC to the emulator. The figures in this section will use a Palm V for display purposes, but it doesn’t matter which ROM you are using. The next step is to select Handheld, Download App & Table from within Satellite Forms. Perform the HotSync and then run Satellite Forms on the emulator or device. A list of available Satellite Forms applications should appear, from which you can choose “Time&Billing”. Once you open Time&Billing, you will see frmOpen, which can be seen in Figure 7.18.
Figure 7.18: Click the form to continue testing program execution. The billing screen appears, where you can enter information into the program. You should enter several test cases to see how they function and to see if everything works correctly. Lastly, you should test the capabilities of the Find button that, once clicked, should display the Customer Look Up form that can be seen in Figure 7.19.
Testing the Application
113
Figure 7.19: The Customer Look Up form appears when the Find button is clicked. At first execution, all of the program data is displayed in the list box. You cannot differentiate between the entries because it only lists the dates and times. If you click the drop-list control, you will see a list of the customers you entered into the program. Select one, and the list box control will be altered to reflect only the entries for a given customer. You can see an example in Figure 7.20.
Figure 7.20: The data can be sorted based on the drop list control.
114
Chapter 7: Advanced Satellite Forms Database Development
Integrating with a Desktop Database As you’ve seen, the Satellite Forms App Designer enables you to create applications which consist of forms and data tables. Once complete, you can download these applications to the Palm OS device. Many times, this will be the end of the development cycle. This is true if you are developing an application that doesn’t collect data (such as a game or presentation), or if the data you collect is only needed on the Palm device itself. On the other hand, and probably in the vast majority of cases dealing with the Palm, the applications you create will usually need to share their collected data with a desktop. This is often the case, as the Palm is ideal as a data collection device, and if you use it to collect data while away from the office, you often need to use the data on a PC. Satellite Forms makes sharing data a relatively simple process through the use of its HotSync Extension ActiveX Control (ActiveX controls are sometimes referred to as OLE or custom controls). The control can be used by many Database Management Systems (DBMS) that support 32-bit ActiveX controls. Most popular DBMS products like Lotus Approach or Microsoft Access support the use of ActiveX controls. If your particular DBMS does not support ActiveX controls, you can use a dynamic link library (DLL) that is also supplied with Satellite Forms. Because you can use the ActiveX control with many different tools, we’ll take a general look at how it is used instead of looking specifically at a single DBMS. Before we look at the steps, it’s important to understand that the data tables saved by Satellite Forms–based applications use dBase 5 or Access 2000 formats. Therefore, you can use any DBMS that can access these formats. The first step is to extract information from the database, and place it into the intermediate tables that are automatically created by App Designer whenever you create an application that uses tables. Next, you transfer the information in these tables to the Palm device. This information can then be viewed, edited, or otherwise manipulated by your Palm program. Later, you can copy the tables on the device back into the tables created by the application. Once the intermediate tables contain the data, you can use the DBMS of your choice to merge the information. It is the job of the desktop DBMS to handle the merging of the information.
Conclusion
115
As an example, the following steps detail the use of Access 2000 to link to the intermediate tables created by Satellite Forms: 1. Open Access 2000 and on the File menu, choose Get External Data, and select Link Tables. 2. Select “dBase 5 (*.dbf)” in the Files of Type box. 3. Locate the intermediate table files created by App Designer for your application, select one of them, and then click Link. 4. Because App Designer does not create Index files, you can select Cancel in the Select Index Files dialog box. 5. You can repeat steps 1 through 4 to include all of the intermediate tables created by App Designer for your application.
Conclusion In this chapter, we created our third and final Satellite Forms application. The application stores names, dates, times, and signatures for the purpose of billing, and includes the ability to look up specific customer information. In the next chapter, we will look at AppForge, the second development tool we’ll use.
8 Introduction to AppForge: Visual Basic for the Palm OS AppForge is one of the most exciting new tools to be released for Palm OS development. AppForge is an add-on to Microsoft’s Visual Basic 6.0, enabling VB programmers to take advantage of their skills without the need to learn a new programming language or another IDE. There is a free evaluation version of AppForge, currently in release 2, from the AppForge Web site at http://www.appforge.com. If you wish to follow along with the samples, you will need to take the time to download it.
118
Chapter 8: Introduction to AppForge: Visual Basic for the Palm OS
AppForge provides the most well-rounded development tool for the Palm OS, and although Palm owns most of the handheld market, there are competitors. AppForge already supports the Pocket PC and is planning to offer developers the ability to develop applications for RIM, EPOC, and Linux, among others.
Installing AppForge To use AppForge you must have Visual Basic version 6 with service pack 4 or higher. Once you have VB installed and operating on your PC, you need to install AppForge. The installation process is very simple; therefore, we’ll skip over these minor steps and focus our attention on how AppForge is used within the Visual Basic IDE. NOTE Although it is currently available for VB 6, AppForge has been built on the Visual Studio framework and is planning to upgrade to .NET sometime in the future.
The Visual Basic IDE Because AppForge utilizes the Visual Basic IDE, it’s important to have at least a basic understanding of the traditional VB IDE. We’ll begin by looking at the standard IDE and the built-in or intrinsic VB controls like the Text Box, List Box, and Command Buttons. We’ll also look at the AppForge customized versions of the controls called Ingots. The VB IDE may be the single biggest reason for its vast popularity. It provides everything you need to create Windows-based applications in an easy to use and learn GUI. When you start Visual Basic, assuming you have installed AppForge, you will be presented with an opening screen that will appear very much like Figure 8.1. If you have used VB before, you will notice a new type of project called an AppForge project. You will be creating these types of projects in this book, so this option is the only one we’ll concern ourselves with. The AppForge project will automatically set up everything in VB to create a Palm OS–based application. As you can see in Figure 8.2, once you have selected an AppForge project, the Visual Basic IDE is simply a collection of menus, windows, and toolbars that comprise a GUI.
The Visual Basic IDE
Figure 8.1: The New Project Window is displayed when Visual Basic is started.
Figure 8.2: The Visual Basic IDE.
119
120
Chapter 8: Introduction to AppForge: Visual Basic for the Palm OS
Primary IDE Menus As you can see in Figure 8.3, the Visual Basic IDE contains a menu bar and title bar that appear very similar to most Windows applications. The title bar serves as a quick reminder of what you are doing inside the IDE and displays the name of the current project. The menu bar provides functions that you would expect from any standard Windows application, like a File menu for loading and saving projects. You shouldn’t be overly concerned with these at this time because we’ll look at the options that are important to us as we need them. Menu and toolbars
Figure 8.3: The menu and toolbars are like most Windows programs.
The Toolbars The standard toolbar, which is displayed in Figure 8.4, is consistent with other Windows applications. It provides shortcuts to many of the commonly used functions provided by Visual Basic. To add or remove any of the toolbars, you can right-click on the menu bar, or you can select Toolbars from the View menu.
The Toolbars
121
Standard toolbar
Figure 8.4: Toolbars provide shortcuts to many of the common functions.
Individual Toolbars The individual toolbars include the Debug, Edit, and Form toolbars. You can use the Debug toolbar for resolving errors in your program. It provides shortcuts to commands that are found in the Debug menu. In Figure 8.5, you will find the Edit toolbar, which can be useful when you’re editing code because it enables you to set breakpoints and bookmarks. Like the Debug toolbar, the Edit toolbar also contains commands that are shortcuts to the commands in a menu, this time the Edit menu.
The Form Editor Toolbar In Figure 8.6, you can see the Form Editor toolbar that includes most of the commands in the Format menu. It has limited use and is beneficial only when you’re arranging controls on a form’s surface. Depending on your personal preferences, you can choose to display or hide the toolbars, because the functions they provide are generally available in menu options. Several factors, such as the size and resolution of your display, may make their use impractical.
122
Chapter 8: Introduction to AppForge: Visual Basic for the Palm OS
Edit toolbar
Figure 8.5: The Edit toolbar offers a variety of time saving features. Form Editor toolbar
Figure 8.6: The Form Editor gives you quick access to form editing functions.
Primary IDE Windows
123
Primary IDE Windows In addition to the menus and toolbars, there are several windows that you need to become familiar with in order to gain a basic understanding of the Visual Basic IDE. The Form window displays the basic building blocks of Visual Basic applications. The Toolbox window displays some of the built-in Visual Basic controls. You can set properties for the components and forms with the Properties window. Lastly, the Project Explorer displays the objects that make up the project you are working on. You can position and view the forms with the Form Layout window.
The Toolbox In Figure 8.7, you can see the window that you will become familiar with the quickest; it provides access to all of the controls that reside within the Visual Basic runtime itself. These controls, know as intrinsic controls, cannot be removed from the Toolbox and include the following options. We’ll begin by looking at the list of standard controls and then follow that list up with the controls that are installed with AppForge and used for Palm OS development.
Toolbox
Figure 8.7: Intrinsic controls and third-party ActiveX controls are displayed in the Toolbox.
124
Chapter 8: Introduction to AppForge: Visual Basic for the Palm OS
The following are standard VB controls: • Pointer: The pointer is the only item on the Toolbox that isn’t a control. You can use it to select controls that have already been placed on a form. • PictureBox: You use the PictureBox to display images in several different graphics formats such as BMP, GIF, and JPEG, among others. • Label: The Label control is used to display text information that does not need to be edited by an end user. It’s often displayed next to additional controls, in order to label their use. • TextBox: You use TextBox controls for user input. It may be the most widely used control. • Frame: A Frame control is typically used for containing other controls and dividing the GUI. Controls placed within the frame cannot be displayed outside of it, and if the frame is moved on the form, the controls are moved with it. • CommandButton: Much like the TextBox, CommandButtons are used for input on almost every frame. They are used as standard buttons for input like OK or Cancel. • CheckBox: If you need the ability to select True/False or Yes/No, the CheckBox control is the correct control. • OptionButton: The OptionButton is similar to the CheckBox in that it offers the ability to select an option. However, an OptionButton is most often used when a group of options exist and only one item can be selected. All additional items are deselected when a choice is made. • ListBox: This control contains a list of items, enabling an end user to select one or more items. • ComboBox: ComboBox controls are similar to a ListBox, but they only provide support for a single selection. • Scrollbars: The HScrollBar and VScrollBar controls let you create scrollbars, but are used infrequently because many controls provide the ability to display their own scrollbars. • Timer: The Timer control is an oddity when compared to other controls in that it isn’t displayed at runtime. It’s used to provide timed functions for certain events. • DriveListBox, DirListBox, FileListBox: These controls can be used individually but many times are used together to provide dialog boxes that display the contents of drives, directories, and files.
Primary IDE Windows
125
• Shape, Line: The Shape and Line controls are used to display lines, rectangles, circles, and ovals on forms. • Image: You can think of the Image control as a lighter version of the PictureBox control. • Data: The Data control is a component that enables you to connect one or more controls on a form to fields in a database. • OLE: The OLE (Object Linking and Embedding) control can host windows belonging to other executable programs. Along with the standard controls, there are additional controls, known as ActiveX controls (sometimes referred to as OCX controls or OLE custom controls) that are displayed in the Toolbox. They provide additional functionality and can be added to the Toolbox for use in a project. These components are provided by many third-party companies (including the AppForge controls that are displayed automatically when you create an AppForge project) or may have been provided by Visual Basic itself. Many times, these controls provide a greater set of functions that makes them much more powerful than the intrinsic controls. The following list details the AppForge controls, which are the only controls that can be used for a Palm project and are displayed within the Toolbox when an AppForge project is created: • AFTextBox: Same principle as its VB counterpart. • AFComboBox: Used to read textual input and/or prompt the user to select an item from a menu. • AFListBox: Can display a list of varying size and content; the user can select one or more of the items in the list box to provide input. • AFGrid: AFGrid is used to display text in a spreadsheet-like control from which the user can select one or more grid elements to provide input. • AFLabel: Used like the standard VB label control. • AFGraphicButton: Provides standard Button options but can display a picture instead of a shape. • AFButton: Similar to the VB CommandButton control. • AFCheckBox: Provides a True/False option for the user. • AFRadioButton: Provides the option of selecting exactly one item from a list of items.
126
Chapter 8: Introduction to AppForge: Visual Basic for the Palm OS
• AFGraphic: Displays graphics on the screen—you can use the AppForge Graphic Converter to create a proprietary .rgx image or you can use .jpg images. • AFShape: Draw rectangles, squares, circles, and ovals. • AFFilmstrip: Used to animate a series of graphics on the screen. • AFMovie: Displays a movie on the screen after it has been converted from AVI to RMV. • AFHScrollBar: Places a horizontal scrollbar on the form. • AFVScrollBar: Places a vertical scrollbar on the form. • AFSlider: This control allows visible input or output based on a sliding scale. • AFTone: Plays simple musical tones. • AFScanner: Provides scanning of barcodes in a variety of formats. • AFSerial: Sends and receives data through a serial port. • AFInetHTTP: Used to connect to the Internet. • AFSignatureCapture: Reads signatures, which are stored as String data, for user input. • AFClientSocket: Provides a variety of functions for performing socketbased communication. • AFTimer: Like the standard Timer, it is used to execute code at intervals. NOTE There are several versions of AppForge, including the Professional Edition which contains the most Ingots. Depending on your version, you may not have all of the Ingots that are listed above. The Professional Edition includes the AFSlider, AFMovie, AFClientSocket, AFHScrollbar, AFVScrollbar, and AFScanner Ingots that are not available in other editions. Also, it offers additional connectivity support for databases and wireless Internet.
The Form Window To develop in Visual Basic, you use forms to place your controls. The forms you work with are displayed inside the Form Designer window, a window in which you can place and manipulate controls.
Primary IDE Windows
127
The Code Window Every form has a Code window, which can be seen in Figure 8.8. The Code window is where you place the code for your program. It can be opened in a variety of ways, such as double-clicking on a form or choosing Code from the View menu.
Code window
Figure 8.8: Visual Basic code is placed in the Code window.
The Project Explorer You can see the Project Explorer, a window that is provided to help you manage projects, in Figure 8.9. The Project Explorer is a hierarchical treebranch structure that displays projects at the top of the tree. The components that make up a project, such as forms, descend from the tree, thus making navigation quick and easy; you can simply double-click on the part of the project you would like to work on. The Project Explorer also provides additional functions such as the ability to add new forms, which can be accomplished by right-clicking on an open area of the Project Explorer window and selecting Add from the pop-up menu.
128
Chapter 8: Introduction to AppForge: Visual Basic for the Palm OS
Project Explorer
Figure 8.9: The Project Explorer is extremely helpful in managing a project.
The Properties Window The Properties Window is used for the configuration of the controls you place on a form as well as the form itself. All of the standard Visual Basic controls have properties, and the majority of ActiveX controls do as well. As you can see in Figure 8.10, the window displays the available properties for an individual control or the forms that they are placed on. These properties can be changed as you design an application, or you can alter them in code.
Form Layout Window The Form Layout Window is visible in Figure 8.11. Its only purpose is to enable you to set the position of forms when they are being executed during runtime. This doesn’t really come into account for Palm OS development, so we don’t really need to look at this any further.
Primary IDE Windows
129
Properties window
Figure 8.10: The Properties window enables you to adjust properties for many Visual Basic objects.
Form Layout window
Figure 8.11: The Form Layout Window enables you to set the position of forms.
130
Chapter 8: Introduction to AppForge: Visual Basic for the Palm OS
AppForge-Specific Menu and Toolbars Along with the AppForge controls, there are also AppForge-specific menus and toolbars that become available in the IDE after the installation completes. These menus and toolbars contain the options that you will use most often for Palm development. The menus and toolbars offer basically the same functions, including • Database Converter: The AppForge Database Converter converts Microsoft Access Database tables to the Palm Database (.PDB) format, and can generate a Visual Basic code module for the database, which provides an interface for accessing and modifying the Palm Database. • PDB Database Viewer: Displays the internal schema and data records in the Palm database file. It also displays a number of other useful pieces of information, including the internal database name, CreatorID, and TypeID of the database, as well as the number of records in the database. • Font Converter: Converts TrueType fonts (TTF) into AppForge fonts (CMF). • Font Viewer: The AppForge Font Viewer displays the properties and characters for AppForge Fonts. • Graphic Converter: Converts bitmap files (BMP) into AppForge graphic files (RGX). • Graphic Viewer: Allows you to view AppForge graphic files (RGX). • Movie Converter: Converts AVI movies to AppForge movie files (RMV). • Movie Viewer: Allows you to view RMV movies. • Universal Conduit Configuration: Configures a conduit for your application. • Compile and Validate: Compiles and checks code for error. • Deploy to Device: Uploads a compiled project to a handheld device. • AppForge Settings: The settings for an AppForge project. • Open Project: Opens AppForge projects. • Zoom Level: Opens a Zoom Window that allows you to view your forms in a larger format.
Review
131
Review AppForge is a product that does an admirable job of integrating into the Visual Basic IDE. It is one of the easiest to use all-around development tools available for the Palm, especially for developers who are already experienced with Visual Basic. In the next chapter, we’ll build our first AppForge project, a calculator.
9 Beginning AppForge Programming: A Calculator Example It’s very easy to build math-related programs with AppForge and, in this chapter, we’ll explore a couple of built-in functions for math including the Tan trigonometry function. We’ll also look at how we can convert text data entered into a TextBox into a number so that we can perform mathematical functions like add, subtract, multiply, and divide.
134
Chapter 9: Beginning AppForge Programming: A Calculator Example
Creating the Project As with most projects, there are several ways we can write code for a simple calculator. We could create individual Buttons that, when clicked, could change the value in a TextBox. If you have used VB before, you understand that it is an event-driven programming language. For instance, if a button is clicked (or tapped on the Palm), an event is raised. For a Button control, it would be the Button_Click event. It is inside this event where we will create our code so that when the button is clicked, it will execute the steps we need for our program. As you can see, the problem with using a single button for every number is that it would require a tremendous number of events to be created and thus a large amount of code. Instead, a better approach would be to create an array of buttons and utilize the index of the button to determine which button was being clicked. NOTE In this and subsequent chapters related to AppForge, we’ll only use the third-party AppForge Ingots in our projects. For example, if we are placing a button on a form, you can assume that it is an AppForge Button Ingot rather than the built-in VB Command Button.
Creating a GUI You can begin this project by creating a New AppForge project in Visual Basic. The next step is to create an array of AppForge Button Ingots. You should begin by creating the first Button Ingot and placing it on the form. It should look similar to Figure 9.1. This button will then be copied and pasted several times to create each of the buttons. Before proceeding with the next step, you should set the button properties as follows: Name: cmdNumber Caption: 1 Height: 19 Width: 22 The next step is to copy and paste the button several times onto the form. You can do this by clicking the button and then selecting the Ctrl key and the C key simultaneously. You can then use the paste shortcut of Ctrl-V to paste it. When you do the paste, you should see a message similar to Figure 9.2. The message is asking if you would like to create a control array, which is exactly what we want to do, so you should click the Yes button.
Creating a GUI
135
Figure 9.1: The first button is placed on the form.
Figure 9.2: The control array is created when you click Yes at this prompt.
136
Chapter 9: Beginning AppForge Programming: A Calculator Example
You can continue pasting the buttons until you have enough for buttons 1 through 9 and 0. You will then need to individually set their caption properties as follows: Button(Index)
Caption
cmdButton(0)
1
cmdButton(1)
2
cmdButton(2)
3
cmdButton(3)
4
cmdButton(4)
5
cmdButton(5)
6
cmdButton(6)
7
cmdButton(7)
8
cmdButton(8)
9
cmdButton(9)
0
If you are unfamiliar with setting a property, it is actually a very simple process. You begin by clicking the Ingot you would like to set the properties for. Once selected, you can set a property by locating the property in the Properties window. Once you have the properties set, arrange the buttons so that they are similar to Figure 9.3. There are a few additional Buttons that need to be created. Their names and captions should be set as follows: Name
Caption
cmdMultiply
X
cmdAdd
+
cmdSubtract
-
cmdDivide
/
cmdClear
CLS
cmdDecimal
.
cmdPlusNeg
+/-
cmdTan
Tan
cmdCalculate
=
Creating a GUI
137
Figure 9.3: The finished array of Button Ingots. You can set the widths and heights of these buttons to be the same as the earlier buttons, and they should be placed at locations similar to those shown in Figure 9.4. You’ll notice that the only button that is a different width is the cmdTan button, and that is just to take up some space in the GUI.
Figure 9.4: The latest buttons also on the form.
138
Chapter 9: Beginning AppForge Programming: A Calculator Example
We need a place to capture the data as it is entered and to also display it on the form. We’ll use TextBoxes for this, so the next step is to place three TextBoxes on the form. At this time, you can just place the TextBoxes on the form above the cmdNumber Buttons. Their properties can be set as follows: Name
Caption
Width
Height
txtBoxA
blank
148
19
txtBoxB
blank
148
19
txtAnswer
blank
148
19
After you set their properties, you can place them directly on top of each other. We’ll only display one of them at a time, so this works very well. Figure 9.5 displays the final GUI for the application. At this time, the GUI has been completed. We are now ready to take a look at adding code logic for the project.
Figure 9.5: The final GUI for our application.
Handling GUI Events
139
Handling GUI Events As was previously mentioned, in order to program in VB, you need to utilize event-based programming. For our program, we can begin with the cmdNumber_Click event that will occur when any of the array of buttons is clicked. An integer value called the Index is passed to the Sub Procedure, which will allow us to determine which button was actually clicked. If you double-click one of the cmdNumber buttons you placed on the form, the Code Window will be opened and the following Sub Procedure will be created automatically: Private Sub cmdNumber_Click(Index As Integer) End Sub
You will notice the Index value that is passed to it. Before we can use the index to determine the value, we must first determine if the value is supposed to be placed in txtBoxA or txtBoxB. For this, we will create a String variable called Box which will be used to store either “A” or “B”. We can then check this value to see which box is currently selected. You can enter the following line into the Code Window above the Sub Procedure that was previously created: Dim Box As String
The next step is to create the Form_Load event where we will initially set the Box variable to “A”. The Form_Load event is executed when the form is loaded at runtime. It’s a great place to give initial values or properties to components as well. Along with the Box variable, txtBoxA, txtBoxB, and txtAnswer can be set to “ “ and the visible properties of several components can be set to False so that they will not be seen upon execution. Private Sub Form_Load() Box = “A” txtBoxA.Text = “” txtBoxB.Text = “” txtAnswer.Text = “” txtBoxB.Visible = False txtAnswer.Visible = False txtFunction.Visible = False txtAnswer.Visible = False End Sub
Now that we have initialized the Box variable, we can use it to test which TextBox (txtBoxA or txtBoxB) the number should be entered into. We will
140
Chapter 9: Beginning AppForge Programming: A Calculator Example
take the Index value and then add 1 to it to determine the correct value to enter into the TextBox. Adding a 1 to the Index is required because cmdNumber(0) is actually the number 1. The following code can be entered into the cmdNumber_Click event: Private Sub cmdNumber_Click(Index As Integer) If Box = “A” Then txtBoxA.Text = txtBoxA & (Index + 1) Else txtBoxB.Text = txtBoxB & (Index + 1) End If End Sub
At this time, most of the numbers would work correctly. However, if you clicked 0, a value of 10 (Index of 9 + 1) would be added to the TextBox. Therefore, we need to use another If…Then loop to check if the Index is equal to 9, and if so, we will change the value to -1 so that when 1 is added to it, it will be a 0. There is a single If…Then statement added to the cmdNumber_Click event that handles the situation: Private Sub cmdNumber_Click(Index As Integer) If Index = 9 Then Index = -1 ‘ Handle 0 If Box = “A” Then txtBoxA.Text = txtBoxA & (Index + 1) Else txtBoxB.Text = txtBoxB & (Index + 1) End If End Sub
Supporting Negative Values Now that the values are being placed in the appropriate TextBoxes, we need to add the positive or negative toggle function that is associated with cmdPlusNeg. We can use the same check of the Box variable to decide which TextBox should be used. We then use a variable, which is created in the procedure and called dblTemp, that will temporarily store the value of the appropriate TextBox. Then, we assign dblTemp equal to a negative of itself, thereby adding the toggle function to the program. Lastly, we need to set the TextBox equal to the toggled dblTemp value. This is the code: Private Sub cmdPlusNeg_Click() Dim dblTemp As Double If Box = “A” Then If txtBoxA.Text <> “” Then dblTemp = CDbl(txtBoxA.Text) dblTemp = -(dblTemp)
Add, Subtract, Multiply, and Divide
141
txtBoxA.Text = Str(dblTemp) End If Else If txtBoxB.Text <> “” Then dblTemp = CDbl(txtBoxB.Text) dblTemp = -(dblTemp) txtBoxB.Text = Str(dblTemp) End If End If End Sub
Working with Decimal Values The decimal point might be the easiest item to deal with in the entire program. You can simply add a “.” to the currently selected TextBox. The following code is all that is necessary for this step: Private Sub cmdDecimal_Click() If Box = “A” Then txtBoxA.Text = txtBoxA & “.” Else txtBoxB.Text = txtBoxB & “.” End If End Sub
TAN Function The next step is to add functions that will enable the calculation of a tangent. The value that is generated by these functions will be placed in one of the TextBoxes so again, we must determine which TextBox (txtBoxA or txtBoxB) this value should be calculated from. Like the previous steps, we’ll use the Box variable to do this: Private Sub cmdTan_Click() If Box = “A” Then If txtBoxA.Text <> “” Then txtBoxA.Text = Str(Tan(CLng(txtBoxA.Text))) Else If txtBoxB.Text <> “” Then txtBoxB.Text = Str(Tan(CLng(txtBoxB.Text))) End If End Sub
Add, Subtract, Multiply, and Divide To add, subtract, multiply, or divide the numbers in txtBoxA and txtBoxB, we first need to check if txtBoxA has a value in it. If it does, then the Box variable is set to “B” and the txtFunction variable is set to the appropriate
142
Chapter 9: Beginning AppForge Programming: A Calculator Example
function (that is, “-”, “+”, “/”, “*”). Once one of the function buttons has been clicked, txtBoxA is hidden and txtBoxB is displayed. The procedures for adding, subtracting, multiplying, and dividing are complete as follows: Private Sub cmdSubtract_Click() If txtBoxA.Text <> “” Then txtFunction.Text = “-” txtBoxB.Visible = True txtBoxA.Visible = False txtBoxB.SetFocus Box = “B” End If End Sub Private Sub cmdMultiply_Click() If txtBoxA.Text <> “” Then txtFunction.Text = “X” txtBoxB.Visible = True txtBoxA.Visible = False txtBoxB.SetFocus Box = “B” End If End Sub Private Sub cmdDivide_Click() If txtBoxA.Text <> “” Then txtFunction.Text = “/” txtBoxB.Visible = True txtBoxA.Visible = False txtBoxB.SetFocus Box = “B” End If End Sub Private Sub cmdAdd_Click() If txtBoxA.Text <> “” Then txtFunction.Text = “+” txtBoxB.Visible = True txtBoxA.Visible = False txtBoxB.SetFocus Box = “B” End If End Sub
Calculating the Result
143
Calculating the Result The next step is to actually calculate the result of the function using the values in txtBoxA and txtBoxB. The calculation occurs when cmdCalculate is clicked. This procedure will check to see which command is currently selected and then set txtAnswer to the calculated value, but first it must convert txtBoxA and txtBoxB to Doubles by using CDbl. Then, once the calculation has been made, it will set txtBoxA equal to txtAnswer. txtBoxA will then be displayed and txtBoxB will be hidden. Additionally, Box will be set to “A” so that it can again receive input. The following code accomplishes the necessary steps: Private Sub cmdCalculate_Click() If txtFunction.Text = “+” Then txtAnswer.Text = CDbl(txtBoxA.Text) + CDbl(txtBoxB.Text) End If If txtFunction.Text = “-” Then txtAnswer.Text = CDbl(txtBoxA.Text) - CDbl(txtBoxB.Text) End If If txtFunction.Text = “X” Then txtAnswer.Text = CDbl(txtBoxA.Text) * CDbl(txtBoxB.Text) End If If txtFunction.Text = “/” Then txtAnswer.Text = CDbl(txtBoxA.Text) / CDbl(txtBoxB.Text) End If txtBoxA.Text = txtAnswer.Text txtBoxA.Visible = True txtBoxA.SetFocus txtBoxB.Visible = False txtBoxB.Text = “” Box = “A” End Sub
The final steps in the program are to create the procedures that will clear the TextBoxes. Here are the finished procedures, which can be added to the program: Private Sub cmdClear_Click() txtBoxA.Text = “” txtBoxB.Text = “” txtBoxA.Visible = True Box = “A” End Sub
144
Chapter 9: Beginning AppForge Programming: A Calculator Example
Testing the Application One of the best features that AppForge provides is the capability to test the application from within the VB IDE without the need for an emulator or device. You can simply run it like any VB application and test the program functions. Testing inside the VB IDE does not guarantee success on a Palm device, but is a way to test the overall functions of your application. You should always make certain to test your final programs on the Palm emulator (covered in Chapter 3) or an actual device by compiling it inside VB and then copying both the Booster runtime and the Palm executable to them. If you wish, you can quickly check this application inside the VB IDE to see if it looks similar to Figure 9.6.
Figure 9.6: The final application as executed within VB. If you would like, you can also use POSE to test the functionality of the program. This is an easy process. First, choose Compile and Validate from the AppForge menu. Next, choose Deploy to Palm OS from the AppForge menu. This will generate the PRC file for the application and install it to Hotsync “Install” directory, which is typically something like C:\Palm\Install or C:\Program Files\Palm\Install. You can open POSE and drag the PRC file onto it. This will install the application, but you still need to add the AppForge Runtime to the emulator before you can execute it.
Review
145
Next, you should obtain the AppForge Booster Runtime from http://www.appforge.com/booster.html. After you download and install it, you need to copy all of the PRC files from C:\Program Files\ AppForge\Platforms\PalmOS\TargetImage. This will copy all of the required files for the runtime. After they are installed, you can simply execute the application like any standard Palm program. Figure 9.7 displays the application running in POSE.
Figure 9.7: The application being executed in POSE.
Review Creating math-related programs is a strong point of AppForge. It’s very easy to do the calculations, and the design of the forms is very intuitive. In this application, we used the Trig function TAN along with standard math calculations like multiplication and division. Lastly, you were introduced to the command array that we effectively used for the calculator buttons. In the next chapter, we’ll design another AppForge application, this time a database application that will track basic inventory.
10 Database Programming with AppForge In this chapter, we’re going to create a second AppForge project, this time one that works as a basic inventory program. The program will utilize the database features in AppForge to store the data which will be collected when the program is executed on the Palm device. We’ll use an Access Database in this example because a Palm Database has the same basic structure as an Access table. AppForge provides a Database Converter that converts an Access table to a PDB. Each field’s type is converted to a corresponding Palm Database field type and is then ready to use in your application.
148
Chapter 10: Database Programming with AppForge
Constructing the GUI Like the calculator from the previous chapter, the first step in this application is to create the basic layout of a GUI. To begin, create a new AppForge project and place several AppForge Label Ingots on the 160 × 160 form that was created by default. When you place the first Ingot on the form, you will be asked to save the project before continuing. Save the project in an empty directory of your choice. The directory is important because it will also be used later to store the database files. The project needs two labels with the following captions: Item and Quantity. The next step in the project is to create two Text Box Ingots and set their properties as follows: txtItem and txtQuantity. The Ingots will be used to display information contained in a database, and should have their respective captions set to nothing. It’s not really completely important where the Ingots are displayed, but they should be something like Figure 10.1.
Figure 10.1: The basic layout of the program is beginning to take shape. Lastly, we need to create six Button Ingots that will be used to perform a variety of input options. Create the buttons with the following properties:
Constructing the GUI
Button Name
Caption
btnDelete
Delete
btnSave
Save
btnBack
<-
btnNext
->
btnNew
New
btnExit
X
149
Lastly, we need to create another Label Ingot named lblRecordDisplay. You also need to place a label directly to the left of lblRecordDisplay and set its caption to “Records” (its name doesn’t matter). The final GUI should look something like Figure 10.2.
Figure 10.2: The final GUI for our application.
Designing the Database Our next step is the development of a database on the Windows desktop. Using Access 97, Access 2000, or the Visual Basic Visual Data Manager Add-In, you can create a database with the following fields:
150
Chapter 10: Database Programming with AppForge
Field
Type
Description
Item
Text
The item data.
Quantity
Integer
Store the quantity of items.
If you are using the VB Visual Data Manager, you will begin by selecting it from Add-ins, Visual Data Manager. The main interface is displayed on execution. From this window, which is visible in Figure 10.3, you can select File, New, Microsoft Access, Version 7.0 MDB. Give it a name of Inv.MDB and place it in the directory you created earlier for the project.
Figure 10.3: Visual Data Manager is an easy way to create a simple database. The next step is to right-click the Database Window and select New Table from the pop-up menu. The window that is displayed can be seen in Figure 10.4. Enter a name of Inventory for the Table Name and then click the Add Field button to enter the following fields: Field Name
Size
Type
Item
10
Text
Quantity
Long
Now click the Close button and then close out of Visual Database Manager.
Constructing the GUI
151
Figure 10.4: The next step is to create a new Table. After the Access database is completed, the next step is to convert it for use with AppForge by using the AppForge Database Converter. You can start the database converter by selecting it from the AppForge Menu within Visual Basic. Once you open it, you can select the Inv.MDB file we created earlier and then select Inventory from the Table menu. In order to differentiate between databases, two unique identifiers are assigned to each database. The Creator ID and Type are user-defined values that identify a database. The Creator ID is a unique identifier for a Palm OS application and is required by Palm. Palm allows you to freely register a Creator ID for a distributed application. You can visit the site which allows you to look up and register Creator IDs at http://www.palmos.com/dev/tech/palmos/ creatorid/. The Creator ID for a database should be the same as the application that accesses it. This ensures that the database will be deleted if the application is deleted. In most cases the Type should be set to DATA. If one application accesses multiple databases, the Creator ID and the Type should be the same for each database. For this example, you can use “SF10” for the Creator, but remember, if you have an application on your Palm device that already uses this ID, it can cause considerable troubles. You can use the standard “DATA” value for the Type field. Click the Convert button, which will convert the database to a
152
Chapter 10: Database Programming with AppForge
PDB. Next, a window will be displayed that will ask you if you wish to create the BAS file that accesses the database. You should choose Yes. The resulting Code Module can be added to the AppForge project by selecting Add Module from the Project menu in VB. Make sure you keep all of the files in the same directory that the project was created in.
Creating the Code The module we added to the project contains all the necessary code for directly accessing the Palm database, leaving us responsible for adding the appropriate code in the Visual Basic events. When the AppForge Button Ingots are clicked, an event is raised. Using these events, it’s easy to add records, navigate the existing records, or delete records. We’ll begin with the creation of a new record, which will occur when btnNew is clicked. We begin by opening the Code Window to create a variable called NewRecord. The variable should be of type Boolean; that is, it will hold a yes/no, true/false, or 1/0 value. Inside the btnNew_Click event, we begin by setting the NewRecord variable to True. Next, we set txtItem and txtQuantity to “”. We’ll be setting the TextBoxes to “” for several occasions, and with that in mind, we will create a new procedure called ClearDisplay that will set them. Then we call the procedure as needed. The following procedures are finished: Private NewRecord As Boolean Private Sub btnNew_Click() NewRecord = True ClearDisplay End Sub Private Sub ClearDisplay() txtQuantity.Text = “” txtItem.Text = “” End Sub
Next, we will handle the forward and back (-> and <-) buttons. The code is nearly identical for both items and is listed as follows: Private Sub btnBack_Click() PDBMovePrev dbInv DisplayInfo End Sub Private Sub btnNext_Click() PDBMoveNext dbInv DisplayInfo End Sub
Creating the Code
153
The next item we will look at is the btnDelete code. Again, it will use the ClearDisplay sub procedure and the NewRecord variable. It will check to see if there is a record, and if so, delete it. Here is the code: Private Sub btnDelete_Click() If NewRecord Then ClearDisplay NewRecord = False DisplayInfo ElseIf PDBNumRecords(dbInv) > 0 Then PDBDeleteRecord dbInv DisplayInfo Else MsgBox “No records to delete” End If End Sub
Before moving on, we will look at the Form_Load event. In this event, we will check to see if the database exists and, if not, we will create a new one. We’ll also move to the first record in the database. Here is the code we need: Private Sub Form_Load() If OpenInvDatabase = False Then ‘Create the database if we can’t open it #If APPFORGE Then dbInv = PDBCreateDatabase(“Inv”, Inv_TypeID, Inv_CreatorID) #Else dbInv = PDBCreateDatabase(App.Path & “\Inv”, Inv_TypeID, Inv_CreatorID) #End If PDBCreateTable dbInv, “Inventory”, “Name String, Signature String” End If PDBMoveFirst dbInv DisplayInfo End Sub Private Sub DisplayInfo() Dim MyRecord As tInvRecord If PDBNumRecords(dbInv) > 0 Then NewRecord = False ReadInvRecord MyRecord txtItem.Text = MyRecord.Item txtQuantity.Text = MyRecord.Quantity
154
Chapter 10: Database Programming with AppForge
lblRecordDisplay.Caption = CStr(PDBCurrentIndex(dbInv) + 1) + “ of “ ➥ + CStr(PDBNumRecords(dbInv)) Else NewRecord = True lblRecordDisplay.Caption = “0 of 0” ClearDisplay End If End Sub
At the end of the Form_Load event, it calls the DisplayInfo sub procedure. This procedure, which is listed above, contains the code which actually displays the information on the screen. We only have two buttons to deal with. The first is btnSave, which will save the database record you currently have displayed, and btnExit, which will cause the program to end. The following procedures finish the application: Private Sub btnSave_Click() Dim MyRecord As tInvRecord If NewRecord Then PDBCreateRecordBySchema dbInv End If MyRecord.Item = txtItem.Text MyRecord.Quantity = txtQuantity.Text PDBEditRecord dbInv WriteInvRecord MyRecord PDBUpdateRecord dbInv DisplayInfo End Sub Private Sub btnExit_Click() Unload Me End Sub
Review In the last two chapters, we’ve looked at a few of the many AppForge features. In this latest example, we created a database program that stored and retrieved information from a Palm database, which had been converted from an Access database using the AppForge database converter. In the next chapter, we’ll again look at AppForge, but this time, we’ll look at a few of the multimedia capabilities it provides, such as animation and graphics.
11 Using Additional AppForge Ingots In this chapter we’ll develop a Slot Machine using standard AppForge Ingots and random numbers. This will be a very simple implementation of a slot machine that will show you how to use several features in AppForge. It will use three Label Ingots that will display random numbers when an AppForge button is clicked. You will begin the game with $500 and will be required to place a minimum of a $1 bet on every game. The application will check the values of the Ingots to determine if there are any matches. If there are at least two matches, the game will double the bet amount and add it to your money; otherwise, it will subtract the value from your money. Many times, a slot machine can use pictures or other items for its interface. While we could use pictures like apples and oranges, we will instead use values of 1 to 9. The label Ingots will display these values, which will be calculated using the built-in random number generator. We will simulate a spinning number by creating a sub procedure that will delay the other functions in the game for a given time frame which, in our case, will be two seconds. During this two-second period, the number will be randomly changed, giving the appearance of a spinning dial.
158
Chapter 11: Using Additional AppForge Ingots
We will begin by creating a new AppForge project. There will be a default form that is created. On this form, we will add a Label Ingot called lblSlot. You can set its properties as follows: Name
Caption
Width
Height
lblSlot
1
13
22
The next step is to copy and paste lblSlot, creating a control array. As they are pasted, they should be arranged on the form like Figure 11.1 with their captions being 1, 2, and 3 respectively.
Figure 11.1: Label Ingots will display the results and will be used to calculate wins or losses. We need to add a Button Ingot to the form that will be used to start the random number generation. Change the button caption to Spin. We also need to add a Label Ingot to the form called lblWin and set its caption to 500. It will be used to store the money you amassed during the game. Lastly, we need to add a TextBox Ingot to the form so that we can enter your bets. Change its name to txtBet and set its caption to 0. Once you have finished with the creation of the Ingots, you should arrange them on the form so that they are similar to Figure 11.2.
Using Additional AppForge Ingots
159
Figure 11.2: The GUI for our game is nearly finished. The last step needed is to add Label Ingots so that you can determine what lblWin and txtBet are used for. Figure 11.3 displays our final GUI.
Figure 11.3: After you add Label Ingots, the GUI is complete.
160
Chapter 11: Using Additional AppForge Ingots
Creating the Illusion of Spinning The first step in writing the code deals with handling the spinning of the slot machine. We have a cmdSpin Button Ingot that is already on the form, so we know that the spinning will occur when the button is clicked. We also know that we’ll use random numbers to assign values to the lblSlot control array. To begin, we need to create a variable that will be used throughout the program for counting: Dim intNum As Integer
Next, we focus our attention on the cmdSpin_Click event. Inside this event procedure, we will place the code necessary to create our spin. First, we need to set the enabled property of the button to false so that it cannot be clicked repeatedly. Next, we need to check txtBet to see if it is greater than or equal to 1. If it is less, we will not allow the spin, because a minimum bet of 1 is required. A Message Box will be displayed to inform the user that they need to increase their bet or, if it is a valid amount, the procedure will continue on to the next step, which is a loop that counts from 0 to 2. Those values correspond to the three labels in the control array. We could simply go through the process to assign values to the label controls, but it would happen very quickly and would not simulate a spinning movement. Therefore, we need to add some code to accomplish this. We will create a sub procedure called Delay that will have an integer value passed to it. The sub procedure will cause the program to delay, and while doing so, will assign a series of random numbers to the appropriate label Ingot. The following code represents the Delay procedure and the code required for the cmdSpin_Click procedure: Private Sub Delay(ByVal sngSecondsToBeDelayed As Single) Dim sngStartTime As Single sngStartTime = Timer Do While ((Timer - sngStartTime) < sngSecondsToBeDelayed) DoEvents Randomize lblSlot(intNum).Caption = Int(Rnd * 9) + 1 Loop End Sub Private Sub cmdSpin_Click() cmdSpin.Enabled = False If CInt(txtBet.Text) < 1 Then MsgBox “You need to bet at least $1”, vbOKOnly cmdSpin.Enabled = True
Review
161
Exit Sub End If For intNum = 0 To 2 Delay 2 Randomize lblSlot(intNum).Caption = Int(Rnd * 9) + 1 Next intNum CheckIt End Sub
In the preceding code, near the end of the cmdSpin_Click is a call to CheckIt, a procedure that we have yet to create. It is within this procedure that we’ll check to see if the values of the labels are equal to one another, and if at least two of them are equal, we’ll double the value of the wager and add it to the score. Otherwise, the value of the bet should be subtracted from the winnings. This procedure is rather easy to create and is listed below: Private Sub CheckIt() Dim Compute As Integer If lblSlot(0).Caption = lblSlot(1).Caption Or lblSlot(1).Caption = ➥ lblSlot(2).Caption Or lblSlot(0).Caption = lblSlot(2).Caption Then lblWin.Caption = Str(CInt(lblWin.Caption) + (2 * CInt(txtBet.Text))) Else lblWin.Caption = Str(CInt(lblWin.Caption) - CInt(txtBet.Text)) End If cmdSpin.Enabled = True End Sub
Review The slot machine uses a number of features from previous applications, including control arrays. It also introduces you to a way that you can create a procedure to delay execution of a program, which is used in this example to simulate the slot machine spinning. This is the final example with AppForge, and as you have seen, it is a very powerful tool. It enables VB programmers to take advantage of their existing skills, and might be the most well-rounded RAD tool available for the Palm OS. Additionally, it already has runtime capabilities for the PocketPC, and with future versions for Linux and other handheld devices, this product will simply become a more usable tool. In the next chapter, we’ll begin looking at PDA Toolbox, an easy to use database development tool.
12 Introduction to PDA Toolbox In this chapter, we’ll look at another development tool called PDA Toolbox. It is probably the easiest to use Palm OS development tool available today. Although it can be used for simple games, PDA Toolbox really excels at the creation of database applications. In order to use it, you need only construct a user interface for your program. PDA Toolbox takes care of the rest! PDA Toolbox is based on a freeware project called PalmFactory. The original developer, Brad Goodman, started the project, and once the development began to slow, a user of the application, Paul Prejean, purchased the rights to the project. The name of the application was changed to PDA Toolbox and a new Web site was created for it at http://www.pdatoolbox.com. Like most good development tools, it has continued to evolve by adding new features, many of which have been requested by the user base. The current version of PDA Toolbox at the time of this writing is 4.2, which includes an IDE that runs on Windows OS.
164
Chapter 12: Introduction to PDA Toolbox
The PDA Toolbox GUI When PDA Toolbox is started, a screen, similar to Figure 12.1, will be displayed and a blank project will automatically be created. Like many software development tools, the main screen consists of a Menu Bar across the top with familiar items like Open and Save. There are also several toolbars that are displayed by default. A Project Window, which shows the forms for the project, is also displayed on startup and enables you to change the project name, owner ID, Icon, and Backup bit.
Figure 12.1: The PDA Toolbox GUI as displayed on startup.
Menus PDA Toolbox menus enable you to access standard Windows operations like Open and Close from drop-down boxes that are located at the top of the IDE. There are several individual menus, the first of which, the File menu, can be seen in Figure 12.2. This menu enables you to load and save your PDA Toolbox application files and contains typical options like Open and Save. There is nothing in the menu that needs explanation; therefore, we’ll change focus to the other menus.
The PDA Toolbox GUI
165
Figure 12.2: The File Menu has common functions like Open and Save. The Edit Menu contains functions like Copy, Paste, and Delete. The following list details the functions in the Edit menu: • Cut: Removes all selected items and places them on the clipboard. • Copy: Copies items to the clipboard. • Paste: Places copies from clipboard onto form. • Delete: Deletes selected objects. • Duplicate: Makes instant copies of objects. The View Menu enables you to configure the main screen of your PDA Toolbox workspace. It enables you to hide or show the toolbars and status bar. The Insert Menu enables you to place objects on the PDA Toolbox forms, and the Windows menu enables you to move back and forth among projects. Lastly, there is a Help menu that provides items like ”Tip of the day” and Help files.
Toolbars The toolbars in PDA Toolbox, all of which can be seen in Figure 12.3, enable you to quickly access many of the functions that are located in the menus. The names of the toolbars sometimes represent the menu items that can be found. For example, the File Toolbar provides shortcuts to the File Menu and contains Open, Save, and Print icons. Many times, depending on what
166
Chapter 12: Introduction to PDA Toolbox
you are doing, the toolbar icons might be unavailable because the function would not be useful in the situation. For example, if you don’t have a project open, the save option would be disabled.
Figure 12.3: The Toolbars offer quick access to many useful functions. The Form Tools Toolbar enables you to insert new forms and change options for existing forms. It contains the following icons: • Project Properties: Bring up the Project Properties window. • Edit Form Properties: Allows you to edit the properties of form. • Insert Forms: Inserts a new form into PDA Toolbox project. • Edit Databases: Currently not supported in version 4.2. • Generate: Generates a Palm PRC file. One of the most important toolbars is the Field Tools Toolbar. It is available whenever a form is active and enables you to add components to the PDA Toolbox forms. Once they are available on the form, you can modify their size or move them around the form. It contains a complete set of tools including • Label: Inserts a new label into the form. • Field: Inserts a field onto the form, which can be linked to database tables and is used to store or retrieve information. • Pushbutton: Inserts a pushbutton onto the form, which has several standard options like Jump to Form, Navigate Records, or Insert Records, to name a few. • Radio Button: Adds a radio button to the form. Only a single button from a group can be selected, making it an excellent choice for option screens. • Checkbox: The Checkbox has a value of only True or False. • Pop-up List: Inserts a pop-up list into the current form. This can be used as a field, enabling the user to select from the items in the list. The list contents can be a static list defined at design time, or can be pulled from a database table.
Review
167
• Table: Tables allow you to view information from several records of a database simultaneously. • Digital Ink: A graphic drawing object that is available only in the registered version of PDA Toolbox. • Shift Indicator: Displays shift status on the screen, or can be used to indicate draw or erase options for Digital Ink fields. The next toolbar, the Alignment Toolbar, provides functions that align objects on a form in several different ways. To align them, you must first select several multiple objects. Once selected, you have several options: • Align Left: Aligns the left edge of the selected objects. • Align Right: Aligns the right edge of the selected objects. • Align Horizontal Center: Centers selected objects. • Evenly Space Vertically: Spaces the selected objects evenly down the screen. • Align Object Top Edge: Aligns the top of the selected objects. • Align Object Bottom Edge: Aligns the bottoms of the selected objects. • Align Objects at Vertical Center Points: Centers objects vertically. • Evenly Space Objects Horizontally: Evenly spaces objects across the screen. The last toolbar, Icon Drawing, contains tools that enable you to draw icons for your application. There are several tools, such as • Pencil: Draw a pixel at a time wherever your mouse moves. • Square: Draw a square or rectangle. • Oval: Draw ovals and circles. • Line: Draw straight lines. • Centered Square: Draw a square centered on a point.
Review PDA Toolbox is probably the easiest Palm development tool available. While it can be used to build several types of applications, it is primarily a database/form builder. In the next chapter, we’ll take a look at PDA Toolbox, using many of its tools to build a complete database application.
13 The Travel Database Application In the previous chapter, we looked at the basics of PDA Toolbox, learning about the IDE and the various controls it provides. In this chapter, we’ll use what we learned in the previous chapter to build a complete Travel database that will enable you to store the date and time of a trip, store some notes about the trip, and draw maps or diagrams related to the trip.
170
Chapter 13: The Travel Database Application
Creating the Project When you start PDA Toolbox, a blank project is created automatically at startup. If you already had PDA Toolbox open, you could start a new project by selecting New from the File menu. Either way, the Project Properties Window is displayed and can be seen in Figure 13.1.
Figure 13.1: The Project Properties window is available on startup. The window provides quick access to several items that we need to set, including the following list: Application Name: TravelData OwnerID: TEST About Info: Travel Data Backup Bit: Checked 30 Day Demo: Unchecked You can see this information selected in Figure 13.2. Once you set the appropriate information, you should save your project to C:\PDAToolbox\traveldata.pfa by choosing Save As from the File menu. The next step is to create an Icon for the project. You can access the built-in Icon editor by clicking the Edit button that is located to the right of the Application Icon on the Project Properties Window. We won’t spend a great deal of time going over the tools. It’s sufficient to say that the tools work like most basic bitmap editors and include, from left to right, a Pencil, Rectangle, Circle, Line, and Centered Rectangle. The left mouse button will draw a solid color while the right mouse button will draw white. You can see a sample icon that was drawn for the project in Figure 13.3.
Creating the Project
171
Figure 13.2: The Project Properties options.
Figure 13.3: A simple icon for the application. Once you are finished drawing an icon, you can simply close the window to return to the IDE.
Create a Form The next step is to create a form. Click Form in the Insert menu. Once the form is created, many of the buttons on the Forms Toolbar will become active. Next, click the Edit Form Properties button. It will display the Form Properties Window, where we can enter information about the form and the database: Form Name: TravelData Primary Database Form: Checked Use Default Values: Unchecked
172
Chapter 13: The Travel Database Application
Database Name: TravelDataInfo Type: DATA Creator: ABC1 Main Form: Check if this form is used to edit the data record You can quickly verify this information by comparing it to Figure 13.4.
Figure 13.4: The Form Properties with selections. Click the OK button to close the window.
Adding Components The next step in our application is to add components to the form. The components will display data and allow users to enter data into the application. We’ll begin by placing five labels on the form. You can click the Label control in the Field Tools Toolbar and this will place a single label on the form. Continue doing so until you have five labels, and then set their properties as follows (you can double-click any control to display the property editor): FieldID
Field Text
lbl1
Location:
lbl2
Depart:
lbl3
Return:
lbl4
Notes:
lbl5
Map:
They should be roughly positioned as shown in Figure 13.5.
Creating the Project
173
Figure 13.5: The labels positioned on the form. We need to add several edit components to the form as well: FieldID
Field Type
locT
Text
datd
Date
datr
Date
txtN
Text
You can use Figure 13.6 for placement.
Figure 13.6: The placement of the edit controls. The next step is to add a Digital Ink control to the form with a Field ID of pic1. You can place it by looking at Figure 13.7.
174
Chapter 13: The Travel Database Application
Figure 13.7: The position of the Digital Ink control. The last controls that need to be added to the form are five button controls. You can set the properties as you place them on the form: Button Text
Button Action
NEW
Create New Record
DEL
Delete Current Record
<-
Go To Previous Record
->
Go To Next Record
CLR
Clear All Fields
The buttons are placed along the bottom of the form. You can use Figure 13.8 as a quick guide.
Figure 13.8: The buttons should be aligned. You should save the program and then choose File, Generate Application. You should name the PRC file TravelData.PRC and then click Save. This will create the Palm PRC file which can then be executed on a Palm device or POSE emulator. Figure 13.9 displays the program executing in POSE.
Synchronizing Data with the Desktop
175
Figure 13.9: TravelData.PRC being executed.
Synchronizing Data with the Desktop There are several ways that you can view or edit PDA Toolbox data on a desktop computer. The first method that comes to mind is the creation of a custom conduit. This will obviously work very well but is typically a very involved process. When you are using a tool like PDA Toolbox, which is probably the easiest of all Palm development tools, this might not be the best method. There is an excellent alternative for PDA Toolbox applications called PDB Explorer. You can obtain it for free at http:// llusoft.hypermart.net/. If you want to follow along with this part of the chapter, you can download and install it. PDB Explorer isa program that quickly allows you to edit, sort, export, import, or filter PDA Toolbox data. There is a simple tutorial included with the installation package and you should take the time to go through it. Although it does not walk you through the process, it does provide a fairly good overview of the application. After you enter data into the Travel application, perform a HotSync. Then, when you open a database for the first time with PDB Explorer, you will get a window to set up your fields (see Figure 13.10). You can rename the fields or change the type of fields if you need to, but in our case, the defaults are okay. If you decide to change the names, keep in mind that you are limited to 4 characters.
176
Chapter 13: The Travel Database Application
Figure 13.10: The first step in importing a PDA Toolbox database. Once you have set up the fields, the database is opened and you can work with your data. Using PDB Explorer is similar to using a spreadsheet. You can drag columns to resize them or change their positions. You can add new records, delete records, or change records. The text fields are visible like they are in the Palm software, but the Digital Ink field is not. Instead of seeing the drawing, you will see a placeholder. You can double-click the placeholder to see the drawing (see Figure 13.11).
Figure 13.11: Digital Ink field displayed in PDB Explorer. You can see how easy it is to work with PDB Explorer. Once you have edited the data, you can save it and then move it back to the Palm where it can be used. While PDB Explorer has many features, you might find a situation where it would be beneficial to have the data in an application like Access or Excel. PDB Explorer can export data to a CSV file which can be imported into many popular applications, including Microsoft Office programs.
Chapter Review
177
Chapter Review In this chapter, we used PDA Toolbox to create an application, and in doing so, you can see why it is the easiest tool to use for the creation of simple databases. PDA Toolbox is limited to the functions that are built in, as it does not offer any type of programming or scripting language. However, for creating data entry applications, it would be difficult to find a program that is easier to use. In the next chapter, we’ll turn our attention to CodeWarrior and the Palm SDK.
14 CodeWarrior for Palm OS Thus far, we have looked at a variety of development tools that were created to make the job of a programmer as easy as possible. Until these tools were developed, the only development tool available for the Palm OS was CodeWarrior, which is still the development tool of choice for many Palm OS programmers. CodeWarrior integrates flawlessly with the Palm OS SDK and uses the C or C++ programming languages. It consists of an IDE and complete set of tools including compilers, linkers, and resource managers. This chapter will provide you with some basic information about CodeWarrior 8 (we’ll often call this CW8) and will serve as a reference for Chapter 15, where we will develop an application. You can obtain a demo version from the Metroworks Web site at http://www.metrowerks.com/ contact/secure/palmdemo/.
180
Chapter 14: CodeWarrior for Palm OS
Installation CodeWarrior 8 works with both Mac and Windows so you need to install the version that is appropriate for your development system. The installation process is straightforward and can be completed without any surprises. The only item that is important to remember is the path that you use for installation. For instance, if you install it to D:\ABC123, it is much harder to remember than an installation at C:\CW8.
Running CodeWarrior After the installation, you can run CodeWarrior by double-clicking its icon. You will be presented with a window that appears similar to many of the tools you have been using throughout the book.
Alternatives to CodeWarrior Although CodeWarrior is the official development tool for the Palm OS, it isn’t the only C or C++ development tool for Palm devices. The GNU C/C++ compiler, GCC, can also be used, and it’s free. It is a command-line tool, so if you are used to IDEs it probably will require a great deal of time to get used to, although there are third-party IDEs available such as Falch (www.falch.net) and VFDIDE (www.vfdide.com). GCC will not be discussed further in this book, but you can find information about it from the Palm Web site at http://www.palmos.com/dev/tech/tools/gcc/.
Setting Up an Application After installing and starting CW8, look at the basics of creating an application. The first step is to open the IDE and then select New from the File menu. A dialog box will appear that looks similar to Figure 14.1. From the New window, you need to select Palm OS Application Stationery from the project list. Next, you need to create a name for the project by typing it in the Project name field. You can use the name “Project1” or another of your own choosing. It is advisable to create a series of directories in a common location on the hard drive. You can create such an area by designating it in the location field. A good example would be to use something like C:\Projects\Project1. When you have everything set to your liking, click the OK button and you will be presented with another dialog box, with options similar to Figure 14.2. This dialog will give you a list of the available stationery, which in the
Setting Up an Application
181
case of Palm OS development will include C++, C, and multi-segment C/C++ development. You should choose Palm OS C++ App stationery and then click the OK button. CodeWarrior will begin creating the application for you and place it in the designated directory.
Figure 14.1: The New dialog allows you to create a new Palm OS project.
Figure 14.2: The next option enables you to select the type of stationery used to create the program. As you can see in Figure 14.3, the IDE now contains a project window that enables you to quickly access everything in the project. It contains a few folders that can be expanded to view the contents. At this time, your project should contain three folders that include a C++ source file, user interface resources, and a runtime library. You can access any of this information by expanding the individual folders. Once you have
182
Chapter 14: CodeWarrior for Palm OS
expanded one of them, it will display the information that is located within it. For example, if you would like to look at the basic C++ code that was generated, you can simply click the “+” sign next to the Source folder and then double-click the Starter.cpp file, which displays the code in a text editor.
Figure 14.3: The Project window enables you to access the components that make up an application. We’re really not interested in exactly what is occurring at this time; instead we are going to build the application in CodeWarrior so that you can test what has been created for us. To build the application, you need to select Make from the Project menu, which will bring up a window that shows you the build status. Once it has finished, the window closes and the project is now ready to be executed.
Running the Application Now that the program is ready to run, you have several options for executing it. First, you can copy the PRC file that was created and manually run it with the Palm emulator or on a device. This will work like any standard type of Palm application. Another option, and perhaps an easier method, is to use CodeWarrior to automatically download, install, and run the application for you. To do this, we need to configure CodeWarrior to use POSE. Select Preferences from the Edit menu which opens the IDE Preferences window that can be seen in Figure 14.4. From the IDE Preferences Panel on the left side of the window, you should select Palm Debugger Settings. The Target Type drop-down should be set to Palm OS Emulator. The next step is to set the location of the emulator by clicking the Choose button and then locating the Palm emulator EXE file in the directory that you used for its installation. You also need to select the Launch Emulator checkbox and then click the OK button.
Running the Application
183
Figure 14.4: The IDE Preferences. To test the application, you can now simply select Run from the Project Menu, or press Ctrl-F5. This will automatically execute the program in POSE; an example of this program can be seen in Figure 14.5. If you wish to debug the application, the emulator and CodeWarrior can work together. Instead of choosing Run from the Project Menu, you can choose Debug, or press F5. If you receive an error message that says something like “the emulator is not started” when you do either of these, you should save your project and restart CW8. It will open POSE for you automatically and then you can use either of the options for running the program.
Figure 14.5: The program is being executed in POSE.
184
Chapter 14: CodeWarrior for Palm OS
The Stationery that is built in to CW8 is very good, but if you find yourself developing the same types of applications over and over, you can easily create your own custom Stationery. Simply create the basic framework for your application and then save it to the Stationery Folder in the CW8 installation directory. Then, whenever you start a new project, it will be available as a template.
Changing the Application While testing the application, you may notice that the menu option in the program displays the default information supplied by the CW8 Stationery. We can change this very easily by changing a few properties and using Constructor, the CW8 tool that is used to create user interfaces, forms, and dialogs. We should also modify the Creator ID, which you are already familiar with from previous chapters. We’ll begin by changing the Creator ID for the application. You begin by selecting Starter-Debug settings from the Edit menu, which opens a window like Figure 14.6. On the left side of the window, you will find an option that says PalmRez Post Linker. When you find the option and click on it, you will find the Creator ID, which by default is STRT. This is the default CW8 value, so we need to change it to something like STR1 (don’t forget that if you plan to distribute the program, you should get your own Creator ID at http://www.palmos.com/dev/tech/palmos/creatorid). This will keep the application separate from others on the device. When you have changed it, you need to click the OK button.
Figure 14.6: The Starter-Debug Settings window allows you to set the Creator ID.
Changing the Application
185
Creating a Name Creating a name for your application is a little more involved. Again, you begin by opening the Starter-Debug window from the Edit menu. In the left pane, you need to select Target Settings. This will change the display in the right pane, which should now have a Target Name text field. Change this name to the intended name for your application. For our example, you can use Project1. Next, you need to select the 68K Target setting from the left pane, and change the name of the temporary file. You can change it to Project1.tmp for our example. Lastly, you need to select PalmRez Post Linker from the left pane and change the Mac Resource Files value to Project1.tmp and the Output File to Project1.prc. It may look familiar to you, as this is where we changed the Creator ID in an earlier step. After you have made these changes, click the OK button, and it is probably a good idea to save the project.
Changing Display Name and Icon The last step we have is to change the name and icon that are displayed when the program is transferred to the emulator or a device. We’ll use Constructor for this. To open Constructor, click the “+” item next to the Resources folder in the project window, and then double-click the Starter.rsrc file. The Constructor window will open and should look like Figure 14.7.
Figure 14.7: The Constructor window is used to change resources.
186
Chapter 14: CodeWarrior for Palm OS
In the bottom-left window, you will find an Application Icon Name entry, which needs to be changed to Project1. Next, from the upper-left window, select App Icon Families. There will be two settings, one for small icons and one for large icons. You can double-click the Large Icons (1, 2, and 8-bit) option which will display another window similar to Figure 14.8.
Figure 14.8: The icon information displayed in Constructor. You need to edit the icons for all of the color values by clicking the Edit button for each of them. In other words, you have to create three icons so that the correct icon can be displayed properly on all devices. When you click on the Edit button, it will bring up a simple icon editor similar to Figure 14.9.
Figure 14.9: The icon editor enables you to create icons for your application.
Chapter Review
187
You can simply close the icon editor window when you are finished editing an icon. After you have created all three icons (choose any shape you’d like, or you can leave them as is), the last thing you need to do is save the resources by choosing Save from the File menu in Constructor. After you save it, you can close Constructor and then rebuild your project by choosing Make from the Project menu. Next, save the project and try running it on POSE to test your new icon. You can see an example in Figure 14.10.
Figure 14.10: An example of the changed icon.
Chapter Review In this chapter we have covered the basics of CodeWarrior 8 and used it to build a complete, albeit simple, Palm application. We looked at the CW8 Stationery, which makes it very easy to build a basic framework for a Palm application, and also learned how to set up POSE to work alongside CW8. Lastly, we looked at Constructor and how it is used to alter the resources for an application. In the next chapter, we’ll add some additional information to the program that will enable a user to draw to the screen, and a Button that will erase the screen and then redraw it.
15 Creating Applications with CodeWarrior In this chapter, we’ll build on the information we learned in the previous chapter to build an application that responds to the click of a button and also to pen input. It doesn’t do a great deal, but it will serve as a good introduction to programming with CodeWarrior. And since the Palm OS SDK is filled with information about databases and other types of programming, this will allow you to learn some of the basics before moving on to the database coverage in the documentation available in the SDK. We’ll continue to use the basic application we began in Chapter 14.
190
Chapter 15: Creating Applications with CodeWarrior
Overview of New Application There are several changes we need to make to this application, including changes to the user interface. With the GUI in mind, we’ll begin by opening the previous application and then double-clicking the starter.rsrc file to open Constructor. Next, we’ll double-click Main in the Forms category that is located in the left pane. This will open a window similar to Figure 15.1.
Figure 15.1: The Main form for our application displayed in Constructor. The next step is to add a Button to the form. Unlike the other development tools we’ve seen in this book, the tools that are used to make up an interface are not visible when you open a form to edit. Instead, CW8 requires you to select Catalog from the Windows menu, which displays a window that should look like Figure 15.2.
Overview of New Application
191
Figure 15.2: The Catalog contains various components we can use to make up a GUI. The following list details the various components (called interface items in CW8) available in the Catalog: • Button: Triggers an action after the item is depressed then released within the button’s bounds. • Checkbox: Toggles on and off when tapped. • Feedback Slider Control: Displays a data value inside of a range of values. • Field: Accepts and displays user entry for text information. • Form Bitmap: A placeholder for a bitmap resource. • Gadget: A placeholder for an application-defined user interface item. • Graffiti Shift Indicator: Displays the Graffiti shift indicator for punctuation, symbol, and so on. • Graphic Button: Uses a graphic image to act as a button. • Graphic Push Button: Allows a graphic image to act as a push button. • Graphic Repeating Button: Allows graphic image to act as a repeating button. • Label: Displays text information that cannot be edited by a user. • List: Presents a box to the user containing a list of choices.
192
Chapter 15: Creating Applications with CodeWarrior
• Popup Trigger: Shows the selection from a pop-up list and lets the user display an associated pop-up to change the selection. • Push Button: The user can choose only one push button within a group of push buttons. • Repeating Button: Starts a continuous action that occurs while the button is depressed. • Scrollbar: Allows the user to control which portion of a list or table is displayed. • Selector Trigger: Shows a setting and allows a user to display an associated dialog box to change the setting. • Slider Control: Allows the user to specify a data value within a range of values. • Table: Displays a two-dimensional array of information. From the Catalog, choose the button interface item and drag it onto the form. You should position it so that it looks something like Figure 15.3.
Figure 15.3: The button has been placed on the form. If the button is not selected, you should single-click on it, which will display a list of properties in the left pane of the Layout window. You need to set the properties of the button as follows: Object Identifier: Clear Label: Clear
Writing Some Code
193
Next, you need to single-click the form and then change the title property to “Project 1a EZDraw!”. Close the form layout window and then doubleclick the About form in the left pane. We need to change the various components of the About window so that they reflect the new application. First, change the uppermost label to read “Project 1A EZDraw!”. Again, this is changed by selecting the label with the mouse and then using the properties of the item. Set the middle label to read “A CodeWarrior Application” and the final label can be left as is. Close the window and then Save from the File menu. You can then close Constructor.
Writing Some Code The next step is to write some code. Double-click Starter.cpp from the project properties window. This will open the code editor, which can be seen in Figure 15.4, so that we can change and add some code. If you have never worked with C or C++, it may look confusing at first glance. However, if you look closely, you will see that it works very much like the other programming languages we used in the book.
Figure 15.4: The code editor is used to write and edit C code. Standard C programs start in the Main procedure. The Palm uses a slightly altered version of this called PilotMain (you will see PilotMain if you scroll to the bottom of the editor). We are not going to spend a great deal of time on the theories and ideas behind C code as there are many resources for this (not to mention that the ideas would take volumes to cover adequately). When CodeWarrior creates your application, it actually
194
Chapter 15: Creating Applications with CodeWarrior
inserts its own startup code at the beginning of the application that accomplishes runtime initialization before calling any of your code. The startup code will then call “your” entry point, the PilotMain function. UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags );
The three parameters are as follows: • cmd is the launch code that identifies how the application was started and what it is being asked to do • cmdPBP is a pointer to a launch code parameter block—depends on the launch code • launchFlags is a set of bit flags that provide additional information about the application’s startup The return value is an error code, with a value of zero indicating that the program ran without error. A non-zero value, usually one of the system error codes, is returned if an error occurs.
Application Launching There are several ways an application can be launched on a Palm OS device. First, the user can press one of the buttons on a Palm device. The user could also select an application’s icon from the application launcher, or select the Find operation to perform a global search across all installed applications. Also, the system can wake an application when a timer expires. In reality, there are actually four basic ways a program can be launched: normal, subcall, initializing, and notification. In some of the variations there are important restrictions on what your application can do, which is why the launch code is important. THE NORMAL LAUNCH A normal launch occurs when the application is launched from the application launcher or by pressing one of the device’s buttons. If there is a running application, it is asked to quit. When it does, the new application is started. The launch code passed to PilotMain is sysAppLaunchCmdNormalLaunch, which you would check for like this: UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags ) { Err errorCode = 0; if( cmd == sysAppLaunchCmdNormalLaunch ){ // normal running of application } return errorCode; }
Writing Some Code
195
We basically are just checking the value of the cmd value to see if it is equal to sysAppLaunchCmdNormalLaunch. If it is, it continues on. Otherwise, it returns an error code. For our example, we’ll simply use the options that were created with the stationery, but when you are creating your own programs, this information is important.
AppHandleEvent The Palm Stationery created an event handler for our application. Listed below, you will see the code for this: static Boolean AppHandleEvent(EventPtr eventP) { UInt16 formId; FormPtr frmP; if (eventP->eType == frmLoadEvent) { // Load the form resource. formId = eventP->data.frmLoad.formID; frmP = FrmInitForm(formId); FrmSetActiveForm(frmP); // Set the event handler for the form. The handler of the currently // active form is called by FrmHandleEvent each time it receives // an event. switch (formId) { case MainForm: FrmSetEventHandler(frmP, MainFormHandleEvent); break;
//
default: ErrFatalDisplay(“Invalid Form Load Event”); break; } return true; } return false;
}
Basically, for our application, we need to use AppHandleEvent to test if the pen is down, and if it is, we need to draw a pixel on the screen. Otherwise, the application should simply continue executing. In C code, this will
196
Chapter 15: Creating Applications with CodeWarrior
handle this aspect of the application (you don’t need to enter anything in the code editor at this time; we’ll do it all at once later in the chapter): if (eventP->eType == penDownEvent) { do { PenGetPoint (&x, &y, &penDown); WinDrawPixel(x,y); } while (penDown); handled = true; }
The other thing we need to handle is the clicking of the Clear button. It’s very simple to erase the contents of the window and then redraw it so that the button is displayed again on the screen: if (eventP->data.ctlEnter.controlID == MainClearButton) { frm=FrmGetActiveForm(); WinEraseWindow(); FrmDrawForm(frm); handled = true; }
The complete AppHandleEvent is listed as follows: static Boolean AppHandleEvent(EventPtr eventP) { UInt16 formId; FormPtr frmP; Boolean handled = false; Int16 x,y; Boolean penDown = false; FormPtr frm; if (eventP->eType == penDownEvent) { do { PenGetPoint (&x, &y, &penDown); WinDrawPixel(x,y); } while (penDown);
Writing Some Code
197
handled = true; } if (eventP->data.ctlEnter.controlID == MainClearButton) { frm=FrmGetActiveForm(); WinEraseWindow(); FrmDrawForm(frm); handled = true; } if (eventP->eType == frmLoadEvent) { // Load the form resource. formId = eventP->data.frmLoad.formID; frmP = FrmInitForm(formId); FrmSetActiveForm(frmP); // Set the event handler for the form. The handler of the currently // active form is called by FrmHandleEvent each time it recs. an // event. switch (formId) { case MainForm: FrmSetEventHandler(frmP, MainFormHandleEvent); break;
//
default: ErrFatalDisplay(“Invalid Form Load Event”); break; } return true; } return false;
}
You can close the code editor and save the project by choosing Save As from the File menu. Next, choose Make from the Project menu (or hit F7) and then choose Run from the same menu (or press Ctrl-F5). You can see our example program being executed in POSE in Figure 15.5.
198
Chapter 15: Creating Applications with CodeWarrior
Figure 15.5: A tic-tac-toe game being played in our example.
Chapter Review In this chapter, we built an application in CodeWarrior for drawing on the Palm OS device screen. We used Constructor for creating a GUI, and then some basic C language code to do the drawing and erasing for the application. In the next chapter, we’ll look at Java programming for the Palm OS.
16 Java Virtual Machines for the Palm OS The final two chapters of this book will focus on Java programming for the Palm OS. The Java platform is rapidly expanding in the enterprise, with technologies like servlets, Enterprise JavaBeans, and JDBC (Java Database Connectivity). On the Palm OS, Java is beginning to mature after a relatively slow start. In the first of the two chapters, we’ll look at the available Palm OS Virtual Machines, giving some basic details about each of them. In the final chapter, we’ll use Waba, one of the available Virtual Machines (VMs), to create a Palm application.
202
Chapter 16: Java Virtual Machines for the Palm OS
The Choices Developing Java applications on the Palm OS is becoming a more attractive option for many developers. The open source Waba/SuperWaba, KVM, Kawt, and J9 virtual machines are all very interesting projects that can be used with varying degrees of success. They each offer strengths and weaknesses as they contain only a subset of the full JVM. This chapter looks at several of the available Palm JVMs, but it cannot be considered a complete list. There are several new tools just getting underway, and because some of them are open source, they are sure to spawn the development of even more tools.
Sun’s KVM Perhaps the most widely publicized, the Kilobyte Virtual Machine (KVM) was given its name because its memory footprint can be measured in kilobytes rather than the megabytes required by the standard JVM. Having been developed strictly for smaller devices and the smaller memories they provide, there are several items that have been left out, including reflection, JNI, and custom classloaders. Because of the stringent memory requirements, the functionality of the KVM is but a subset of the full JVM. You can get a full breakdown of what is and is not supported from the Javasoft site, but notable omissions include reflection, JNI, and custom classloaders, as well as an altered security mechanism. Interestingly, at this time, Sun has two separate configurations of the libraries for PDA types of devices: the CLDC and CDC. The CDC was developed for devices more powerful than a Palm, so we won’t really spend any time looking at it. On the other hand, the CLDC can be used by everything from cellular phones to full-featured PDAs. According to Sun documentation, the CLDC is ideally suitable for devices with 16/32-bit RISC/CISC microprocessors/controllers, and with as little as 160KB of total memory available. The virtual machine and libraries consume 128KB by themselves. You can find additional information and downloads at the KVM and CLDC Web site located at http://java.sun.com/products/cldc/.
Kawt Kawt is an implementation of the Abstract Window Toolkit for the KVM. Kawt offers an API set that is much more familiar to an experienced Java programmer. For example, Button, Panel, Label, TextField, and other AWT classes are all available along with several custom classes that give developers access to GIF and several more features. Unfortunately, database access is a problem with Kawt because of a problem with Palm’s HotSync during synchronization. Kawt makes it much easier for Palm developers to
The Choices
203
create Palm applications, but the database problems may limit its usefulness. You can find additional information and downloads form the Kawt Web site at http://www.kawt.de.
IBM’s J9 IBM has long been working on its VM, called J9. One of the nicest features of J9 is the support provided by Visual Age Micro Edition (VAME), a complete development tool that offers full access to the Palm API, although Java developers will need some time to get used to the calls, as it only provides wrapping of the C methods of the Palm API. Basically, this amounts to a developer needing to have an understanding of the Palm API and the arguments for the methods, which isn’t necessarily a big problem, but if you are a Java programmer without C experience, this could make things more difficult. VAME comes with several examples that are well thought out and provide details on their construction. You can find additional information and downloads from http://www.embedded.oti.com.
Waba/SuperWaba Waba is a development tool that was started by a few individuals. As the tool gained momentum and started attracting attention, the developers opened up the source, which prompted the development of several ports to other operating systems (like Linux, DOS, and Windows CE) and the creation of new tools like SuperWaba. For our discussions, we’ll consider both of the tools jointly, although SuperWaba appears to be the tool that is getting updates. With that in mind, you will probably want to use SuperWaba for the tutorial in Chapter 17. Waba’s biggest advantage is the ports to other systems. This allows a developer to create an application for the Palm that also runs on Windows CE, saving time and effort. It is currently the best solution for developers interested in both platforms. The original Waba implementation is available from www.wabasoft.com, while SuperWaba can be found at www.superwaba.org.
Discontinued But Still Valuable Along with the above-mentioned projects, there are a few additional tools that have been discontinued by their authors but are still a valuable resource of information for Java developers. The first of the two is JUMP, which is available at http://www.hewgill.com/pilot/jump/. It has been officially discontinued by its author, although it appears someone might be continuing his work (http://sourceforge.net/projects/jump/). JUMP is interesting because it takes Java byte-code and turns it into 68k assembly language source code that can then be processed with the PILA
204
Chapter 16: Java Virtual Machines for the Palm OS
assembler to create Palm OS executables. JUMP only supports a very small subset of java-classes, although it does include some glue-classes that make a subset of the PalmOS API accessible to a developer. The most interesting aspect of this project is the availability of the JUMP source code, which allows developers to go through it to see how it was implemented. Another open-source Java project is Ghost (http://www.cs.utah.edu/~mcdirmid/ghost/index.html), which is a very limited implementation of a JVM. It really isn’t of much use in a production programming environment, but like JUMP, the open source might be of help to a developer who is looking to create his own set of tools.
Chapter Review As you have seen, there are several choices available for Java programmers looking at the Palm OS. Although none of them are perfect, they are all at stages where they can be used in the development of complete applications. All things considered equally, Waba/SuperWaba might be the most attractive, as it allows you to leverage a single project into working applications on many OSs, including both Palm and Windows CE. In the next chapter, we’ll create a simple Palm application using SuperWaba.
17 Programming Waba In this chapter, we’ll develop a complete Java application using the Waba VM. Before you begin following along in the chapter, you need to have access to several applications and SDKs, including Sun’s JDK for Windows, the Waba SDK, and Visual Waba. If you are new to Java, the installations may appear to be very involved, but if you simply follow the steps, it isn’t really all that difficult.
208
Chapter 17: Programming Waba
Sun’s Java SDK The first step is to download the Sun Java Development Kit for Windows version 1.2.2 or higher. It is freely available at http://java.sun.com, and at the time of writing, the current release of the SDK is 1.3.1_02. All directories mentioned in this chapter will refer to this version, so if you download a different version, please make certain to change the paths where it is used. The installation consists of simply running the j2sdk EXE file that you download from the Sun Web site. After installation, you need to set the Path and Classpath for your OS, as Visual Waba requires it. In the next step, we’ll set the Path, although we’ll wait to set the Classpath until after the Waba SDK is installed. To set the Path permanently, you need to add the full path of the c:\jdk1.3.1_02\bin directory to the Path variable. In Windows NT or 2000, go to the Control Panel and select System. In Windows NT, you select the Environment tab, while in Windows 2000, you select the Advanced tab, which can be seen in Figure 17.1. There is a “Path” variable in the User Variables and System Variables. You can add the Path information at the end of the path variable if there is something already listed. For our example, the path would be c:\jdk1.3.1_02\bin. If you have something already listed, you should add a semicolon “;” to the end of the first entry before adding the information to the line. Don’t worry about capitalization because it does not apply. Once you are finished, click OK and then reboot your machine.
Figure 17.1: Setting the Path in Windows 2000. In Windows 95 or 98, you can set the Path by opening the Autoexec.bat file and adding the Path. To do so, click the Start button and select Run. Type in sysedit for the program and then click OK. Go to the window that is displaying Autoexec.bat, and look for a Path statement. If you don’t see one, you can add Path to the file. Otherwise, you can add the c:\jdk1.3.1_02\bin to the end of the path, again adding a semicolon “;” before you add the path. For example, a typical Path statement will be something like Path C:\Windows;C:\, so you can add it after C:\. You should reboot your machine.
Visual Waba
209
Windows Me requires a different setting than its earlier siblings. To set the Path, click the Start menu and choose Programs, Accessories, System Tools, System Information. This opens Microsoft Help and Support, from which you can choose the Tools menu, selecting the system configuration utility. Click the Environment tab and select Path, followed by the Edit button. Add the Path as previously mentioned to the line and then reboot the machine. The last option for the various Windows operating systems is XP. Open the Control Panel and double-click System. In the System Control Panel, select Advanced and then the Environment Variables button. Add the Path like in the previous Windows 2000 or NT instructions and then save the changes and reboot your machine. If you have problems with the installation, you should consult the Sun documentation. Otherwise, the rest of the chapter will assume you have successfully installed it.
Waba The Waba SDK consists of two files, both of which need to be downloaded from http://www.wabasoft.com. The files should be unzipped to the root directory in a Waba subdirectory. In other words, after they have been uncompressed, the directory should be c:\waba\wabasdk.10\. After you have them placed in the appropriate directory, the installation is complete. At this time, we need to set the CLASSPATH variable to take into account the Java and Waba classes. It’s easier to set the CLASSPATH variable for the various Windows systems. Choose Start and then Run. In the Open text box type “command” and click OK, which will display a DOS Command Prompt. At the prompt, type the following and press Enter when finished: set CLASSPATH=C:\jdk1.3.1_02\lib\tools.jar;C:\Waba\WabaSDK.10\classes;
Again, the previous line assumes JDK version 1.3.1_02 and the installation of the Waba 1.0 SDK into a Waba subdirectory located in drive C. You should close the DOS prompt and reboot your machine.
Visual Waba Lastly, you need to obtain Visual Waba from http://www.dmic.fr. Once you have downloaded it, it is relatively painless to install. Follow along and answer any questions that are asked of you during the installation of the EXE file you downloaded. After you finish, the next step is to open Visual Waba and set its Parameters. To do so, click Parameters in the File menu, which will open a window similar to Figure 17.2.
210
Chapter 17: Programming Waba
Figure 17.2: The Parameters Panel in Visual Waba. In the Parameters Panel, you need to specify the following paths and information: • Path for the classes of the Waba SDK: C:\Waba\wabasdk.10\classes\ • Path for the java.exe program of the JDK: C:\jdk1.3.1_02\bin\ • Path for the javac.exe program of the JDK: C:\jdk1.3.1_02\bin\ • Path for the exegen.exe program of the Waba SDK: C:\Waba\wabasdk.10\bin\ • Path for the warp.exe program of the Waba SDK: C:\Waba\wabasdk.10\bin\ • Path for the default editor you want, to edit generated Waba files (JAVA extension): C:\WINDOWS\NOTEPAD.EXE • Destination directory for generated files: C:\Program Files\VisualW\Projects\ • Default Image used for your Waba application: C:\Program Files\VisualW\icon2.bmp • Path for your PalmOs-device emulator: C:\Palm\Emulator\Emulator.exe
Creating an Application
211
The previous paths may be slightly different for your machine and can be changed as necessary. It is important that you use the built-in windows for exploring and setting the Parameters, as any small discrepancies in the paths can cause you problems when trying to compile your application.
Creating an Application Now that you have finished installing Visual Waba, we can begin working on an application. The first step is to select New from the File menu. When you create a new project, an Input window is displayed that prompts you for a name for the project. You should give it a name of Waba1 and then click OK. Figure 17.3 displays the IDE of Visual Waba with your new project.
Figure 17.3: The Visual Waba IDE with a new project being started. The next step is to rename the form that was created when you started the project. At the bottom of the form, which is visible in Figure 17.3, you will find a text box for the name of the form. Change it to Form1. The IDE is very similar to other tools we have used throughout the book. There are components, such as an edit box or labels, that can be added to the form. Instead of a drag and drop approach to adding components, you simply click on the component you wish to add and it will be added to the
212
Chapter 17: Programming Waba
upper left of the form. It’s a little difficult to get used to, but in time, you will learn to build your forms from the bottom up. Otherwise, you’ll have to repeatedly move the upper components every time you add a new one. Add a label control to the form and then position it similar to Figure 17.4.
Figure 17.4: The label placed in the center of the form. Once the label is in the center of the form, you can adjust its properties to read “Palm Test” by changing the Text Property in the Properties/Events window. Next, add a button to the form and position it beneath the label so that it is similar to Figure 17.5. Change the text property of the button to read “Close.” The next step is to click the script property selection button, and from the window that appears (it can be seen in Figure 17.6), choose Close Application for the script and then click the OK button.
Creating an Application
213
Figure 17.5: The button in place.
Figure 17.6: Setting scripts for the button. Save the project by selecting File, Save. Now, we’ll generate the source code for our application and add some additional code. Choose Generate from the Source menu, which will generate the code for the application. Next, press Alt–3 on your keyboard, which will open the code in your default editor (in the preferences, we set the default editor to Notepad), as seen in Figure 17.7.
214
Chapter 17: Programming Waba
Figure 17.7: The source code for our application. If you were to run the application, it would function as you would expect. We’re going to add a little code that displays some text information in the upper portion of the form. Add the following code directly beneath the first import: import waba.fx.*;
Next, we’ll add the following code beneath the initialization that was generated by Visual Waba (the last line should be add(label1); followed by }): public void onPaint(Graphics g) { g.setColor(0, 0, 0); g.drawText(“Hello World”, 0, 0); }
Choose Save from the File menu and then close the editor. Back in the Visual Waba IDE, choose Compile from the Source menu. It will display a window that details the compiling of the application. If you have any errors, it will give you some explanations and you will be required to fix them before moving on. For this example, Waba1.class, Form1.class, Waba1.pdb, and Waba1.prc will be displayed as completing okay. Click the Done button. Next, choose Emulator from the Display menu. This will open the POSE emulator but does not automatically move the PRC and PDB files to it.
Chapter Review
215
Instead, Visual Waba displays a window that you can use to drag and drop Waba1.PRC and Waba1.PDB to the emulator. After doing so, you need to add the Waba runtime files. If you don’t have them, you can download them from http://www.wabasoft.com. After downloading them, you will need to install them like any application. After all the files are installed, you should reset the emulator by right-clicking it and choosing Reset. Now, you should see the application titled Waba1. Run it in the emulator and it should display similar to Figure 17.8. You should test the functionality of the application to see if it is working properly.
Figure 17.8: The Palm emulator running the Waba1 application.
Chapter Review In this final chapter, you have learned some of the basics related to Visual Waba and how it works to generate the source code for an application. We edited the generated form to add a simple feature and then compiled and tested the program on the POSE emulator.
A Important Web Sites for Palm OS Developers In this book, we have looked at a wide range of programming tools related to developing for the Palm OS. The following table gives you links to the Web sites of the vendors who make the tools. The Web sites contain additional information about the respective tools and, oftentimes, tutorials, examples, and even trial versions of the tools. Lastly, the table offers additional Web related sites that are pertinent to the Palm OS.
218
Appendix A
Table A.1: Web Sites of Interest Site
Basic Information
Link
Palm
Sign up for the Palm Developer Connection
http://www.palm.com
Puma Technology
Satellite Forms download demo
http://www.pumatech.com
AppForge
AppForge Visual Basic add-in
http://www.appforge.com
Codewarrior
C development environment
http://www.codewarrior.com
PDA Toolbox
Easy database development system
http://www.pdatoolbox.com
Handspring
Handspring SDK
http://www.handspring.com
Pocket C
C development
http://www.orbworks.com
NSBasic
NSBasic IDE
http://www.nsbasic.com
Waba
Java development
http://www.waba.com
Pendragon Forms
Forms-based development
http://www.pendragon-software.com
OnBoard C
C development
http://www.individeo.net/ OnBoardC.htm
VisualAge Micro Edition
Java
http://www.ibm.com
Java
Java SDK
http://www.sun.com
SmallBasic
BASIC for Palm & Unix
http://smallbasic. sourceforge.net/
IBM DB2 Everyplace
Database
http://www.ibm.com
FileMaker Mobile
Database
http://www.filemaker.com
QuickSheet
Spreadsheet
http://www.cesinc.com
Jfile
Database
http://www.land-j.com
MobileDB
Database
http://www.handmark.com
TinySheet
Spreadsheet
http://www.iambic.com
Pila
Assembler
http://mklasson.cjb.net/
CASL
Complete IDE for Palm
http://www.caslsoft.com
Prc2Pilrc
Resource extractor
http://www.vandenburg.net
Ptools
Decompiler
http://www.sra.co.jp/people/ hoshi/
Appendix A
219
Table A.1: continued Site
Basic Information
Link
Pippy
Python for Palm
http://www.endeavors.com/pippy/
Quartus Forth
Forth for Palm
http://www.quartus.net
LispMe
Scheme for Palm
http://www.lispme.de/lispme/
PocketSmalltalk
Smalltalk for Palm
http://www.pocketsmalltalk.com/
Squeak
Smalltalk for Palm
http://www.squeak.org
PocketStudio
Pascal for Palm
http://www.pocket-technologies. com/
B Satellite Form Controls Properties Properties are used by Satellite Forms throughout the development process. This appendix is a complete guide to the properties that individual controls offer along with a basic definition of what each property accomplishes.
222
Appendix B
Properties Common to All Controls Three properties are shared by all controls: • Name of Control: This property stores the name of the control and is also used by other objects to refer to it. Satellite Forms does not allow controls to have spaces in their name. As a result, App Designer will change a name given as “The Box” to read “The_Box”. • Dimensions: There are two options for dimensions: Position and Size. Position refers to the X, Y coordinates of the upper-left corner of the control on the form. The size refers to the actual width and height of a control. There are some types of controls that cannot be changed. For instance, the Title control is always the same size. • Visible: This determines whether a control is visible when the form on which it is located is displayed. It can be toggled at runtime. The title control does not have this option as it’s always visible.
Properties Common to Most Controls Some properties and attributes are available for the majority of controls: • Data Source: Some controls display and allow editing of data from the form’s linked table. The Data Source property sets which specific column’s data is used. To select a data source for a control, pick a column from the Column in Form’s Table drop list. The data in that column of the current record will be displayed in the control. • Font Attributes: Any control that displays text has a Font attribute. Satellite Forms supports the new fonts included in Palm OS 3.0. With version 3.0, the font selection now includes “Normal 9,” “Normal 12,” “Bold 9,” “Bold 12,” “LED,” “Symbol 7,” “Symbol 9,” and “Symbol 11.” • Read-Only: The Read-Only attribute allows you to use a control to only display information; a control’s content cannot be modified when this attribute is enabled. • Don’t Modify Table: Setting this attribute means that any changes made to the control will not be made to the linked table. If you would like to set every control so that they will not update a table, you can use the Modify permission of the form.
Appendix B
223
Specific to Individual Controls There are several tools that have controls that are specific to them. These tools include the Auto Stamp, Bitmap, Button, Checkbox, and Radio Button. We will discuss each of these (and more) in detail in this section.
Auto Stamp The Auto Stamp control automatically enters a date or time in a table column. This is an invisible control that will not be seen. The following list details the specific properties available to Auto Stamp: • Data Source: Same as above. • Stamp Type: Determines the type of stamp that the control will record. Set to Current Date for date or Current Time for time. • Only Stamp: If selected, the control will not automatically overwrite previous data. • Dimensions: Position is used to alter the Auto Stamp control’s position. Size cannot be changed.
Bitmap The bitmap control enables you to place bitmaps on your form. • Attributes: Visible is enabled by default.
Button The Button control allows an action to be executed. • Text: The information that is displayed on the button’s face. • Border: The Border attribute for the Button control specifies whether a button’s border is displayed when the button is visible. • Auto Repeat: When Auto Repeat is enabled, the control executes as soon as the screen is touched, and if held down, it will continue to repeat. • Alternate Shape: Changes the button’s shape on the handheld from a rectangle with rounded corners (the default) to a rectangle with square corners. • Action When Clicked: Options for setting or changing a control’s action and/or filters.
224
Appendix B
Check Box The Check Box control is a labeled box that can be selected (checked) or deselected (unchecked). • Text: Any text entered into this box will appear to the right of the check box on the handheld. • Data Source: Same as other controls. • Action When Clicked: Clicking the Edit button opens the Control Action and Filters dialog, which has options for setting or changing a control’s action and/or filters. • Alternate Shape: Selecting Alternate Shape enables the user to click the text instead of a small box for selection. • Right Anchor Attribute: Changes the way the control grows or shrinks to accommodate its text labels. Normally, the upper-left corner of the control is the control’s anchor and its position stays the same as the control gets larger or smaller. When this property is enabled, the upper-right corner of the control becomes the control’s anchor and its position stays the same as the control’s size grows or shrinks.
Drop List The Drop List control displays a drop-down list from which the user can select an option. • Data Source: Use this drop list to select a Column in Form’s Table as the control’s data source. • List Contents: This performs a lookup like the Lookup control. • Table Name: Used to select the table that contains the desired lookup data. • Key Column: Used to select the key column. • Displayed Column: Used to select the column in the lookup table to be displayed on the form. • Control Dimensions: Set the size and position of the control. • Drop List Dimensions: Position and size of drop list are set with these properties. The drop list dimension is a factor only when the list is displayed. This is different from the control dimension, which sets the size and position of the actual control.
Appendix B
225
Edit Control An Edit Control displays the contents of the specified column for the current record of the form’s linked table. • Alignment: Select Left or Right from the drop list to left- or rightjustify the contents. • Auto Keyboard: When this attribute is selected, the edit control pops up the appropriate handheld keyboard when the control is tapped. • Underlined: If selected, the input area on the handheld’s screen will appear like a form to be filled in. • Auto Shift: You can use this control to force the first character of an edit control or paragraph control to shift to uppercase and then shift back to lowercase for the characters that follow. • Input Required: Used to require input in the control before the user can move to another record or form.
Graffiti Shift Indicator The Graffiti Shift Indicator control places an “indicator” graphic on the handheld’s screen that shows the shift status of the Graffiti handwriting recognizer. • Attributes: If selected, this attribute changes the indicator shape to “Caps”, as it would appear on a PalmPilot 1.0.
Ink The Ink control enables the user to collect signatures or to make sketches on the handheld’s screen. • Discard Near Points: When enabled, the Ink control will not save points that are “too near” each other, which appears to smooth the lines. It is generally used when saving drawings instead of signatures.
List Box The List Box control displays the contents of a form’s linked table in tabular format. • Displayed Columns: This window shows the list of columns from the linked table that will appear in the list control, as well as their column widths. • Add/Edit Column: Clicking the Add button opens the Add Column dialog so that you can select a column from the drop list.
226
Appendix B
• Perform Lookup with Column Contents: Displays the table lookup settings for a column. • Table Name: Used to select the table containing the desired lookup data. • Key Column: Used to select the key column. • Retrieved Column: Used to select the column in the lookup table to be displayed on the form. • Delete Column: Deletes the column. • Move Column: Moves a column up or down in the list of columns. • Draw Separator Lines: If selected, will separate the columns with a line. • Action When Clicked: Sets or changes the action that occurs when the control is clicked.
Lookup The Lookup control allows a lookup to be performed on a field. • Table Name: Used to select the table that contains the desired lookup data. • Key Column: Used to select the key column. • Displayed Column: Select the column that is going to be displayed on the handheld by the control.
Paragraph Control The Paragraph control is similar to the edit control except the information is displayed on multiple lines. • Underlined: Sets underline on or off. • Scrollbar: If selected, a vertical scrollbar will be displayed when the contents of a paragraph control go beyond the handheld screen.
Radio Button A Radio Button control is similar to a check box except that the selection in a set of controls is mutually exclusive. • Text: The text that appears to the right of the radio button should be entered into the text property.
Appendix B
227
• Button Index: Your application keeps track of which button is which using a value called the button index. You can use the values automatically assigned to radio buttons linked to the same data source, or you can set the Button Index manually by using this drop list to select a unique value. • Action When Clicked: Alters the event that occurs when a control is clicked. • Alternate Shape: Allows the user to click the text instead of a small box for selection. • Input Required: User has to choose something before they can move on.
SFX Custom Control Custom controls can be created by users to add capabilities to their Satellite Forms applications through the Satellite Forms Application Programming Interface (API). • Action When Clicked: Alters the event that occurs when the Custom control is clicked.
Text The Text control displays static text that cannot be modified on the handheld. • Text: Any text entered into this will remain the entire time an application runs.
Title The Title control displays a title across the form or page. • Text: Text entered into this property is displayed at the top of the form.
C Standard Naming Conventions While not a requirement, it’s a good idea to adhere to some type of naming convention for your variables. This is true if you are using development tools that use scripting languages like Satellite Forms, the Visual Basic language used by AppForge, or many other languages. For instance, the following code might be hard to read if you were unfamiliar with the purpose of the variables: For X = 1 to 10 Z = X * Y Next X
Instead, you could use something like: For intLength = 1 to 10 intArea = intLength * intWidth Next intLength
You may have noticed that these variables have extra information associated with their prefixes. This is because you should also attempt to name the variables so that anyone glancing at the code can determine the type of variable instantly. The following list is a sample of the data types and suggested prefixes for a naming convention based on the popular Hungarian Notation (HN) originally created by Charles Simonyi of Microsoft:
230
Appendix C
Table C.1: Prefixes for Various Data Types Data Type
Prefix
Example
Boolean
bln
blnFirstTime
Byte
byt
bytData
Collection Object
col
colInformation
Currency
cur
curSales
Date (Time)
dtm
dtmTomorrow
Double
dbl
dblValue
Error
err
errCalculation
Integer
int
intAmount
Long
lng
lngMath
Object
obj
objLast
Single
sng
sngNew
String
str
strEmployeeName
User-defined Type
udt
udtSalesman
Variant
vnt
vntAnything
Controls from various languages also benefit from standard naming: Table C.2: Prefixes for Controls Control Type
Prefix
Example
Button
btn
btnClick
Check box
chk
chkDoIt
Combo box
cbo
cboState
Common dialog
dlg
dlgSave
Communications
com
comFax
Control
ctr
ctrCurrent
Data
dat
datBiblio
Data Grid
dgd
dgdTitles
Data List
dbl
dblPublisher
Date Picker
dtp
dtpPublished
Directory list box
dir
dirRoot
Appendix C
Table C.2: Continued Control Type
Prefix
Example
Drive list box
drv
drvRoot
File list box
fil
filStatistics
Flat Scroll Bar
fsb
fsbMove
Form
frm
frmStartUp
Frame
fra
fraEmployeeInfo
Gauge
gau
gauToday
Graph
gra
graSales
Grid
grd
grdDates
Horizontal Scroll Bar
hsb
hsbPosition
Image
img
imgHouse
Label
lbl
lblInformation
Line
lin
linDesign
List Box
lst
lstData
Menu
mnu
mnuExit
Month View
mvw
mvwDates
Option button
opt
optSound
Picture box
pic
picMap
ProgressBar
prg
prgConvert
Shape
shp
shpLine
Slider
sld
sldValues
Spin
spn
spnInfo
StatusBar
sta
staQuery
SysInfo
sys
sysMy
TabStrip
tab
tabOptions
Text box
txt
txtInformation
Timer
tmr
tmrFirst
Toolbar
tlb
tlbMenu
TreeView
tre
treData
Vertical Scroll Bar
vsb
vsbValue
231
232
Appendix C
The actual naming convention you choose isn’t as important as attempting to stay with it whenever possible. It makes your code much easier to read for you or others, which in turn makes maintenance easier, and it gives all programs some basic uniformity. It also keeps things easier for beginning programmers, who can learn a naming convention and more easily understand what is occurring in the source code.
Index Symbols <- (back button), 152 { } (curly braces), 214 “.” (decimal points), 141 -> (forward button), 152 + (plus sign), 82
A Abort button, 74 Access 2000, 115, 147-154 Action When Clicked property, 223-227 ActiveX, HotSync Extension ActiveX Control, 114 Add/Edit Column property, 225 adding numbers, calculators (AppForge), 141-143 AFButton control (AppForge), 125 AFCheckBox control (AppForge), 125 AFClientSocket control (AppForge), 126 AFComboBox control (AppForge), 125 AFFilmstrip control (AppForge), 126 AFGraphic control (AppForge), 126 AFGraphicButton control (AppForge), 125 AFGrid control (AppForge), 125 AFInetHTTP control (AppForge), 126 AFLabel control (AppForge), 125 AFListBox control (AppForge), 125 AFMovie control (AppForge), 126
AFRadioButton control (AppForge), 125 AFScanner control (AppForge), 126 AFSerial control (AppForge), 126 AFShape control (AppForge), 126 AFSignatureCapture control (AppForge), 126 AFSlider control (AppForge), 126 AFTextBox control (AppForge), 125-126 AFTimer control (AppForge), 126 AFToner control (AppForge), 126 AFVScrollBar control (AppForge), 126 Align Horizontal Center (Alignment Toolbar), 167 Align Left (Alignment Toolbar), 167 Align Object Bottom Edge or Top Edge (Alignment Toolbar), 167 Align Objects at Vertical Center Points (Alignment Toolbar), 167 Align Right (Alignment Toolbar), 167 Alignment property, 225 Alignment Toolbar, PDA Toolbox GUI (graphical user interface), 167 Alt+3 keyboard shortcut, 213 Alternate Shape property, 223-224, 227 alternatives, CW8 (CodeWarrior), 180
236
API (Application Programming Interface), VFS (Virtual File System)
API (Application Programming Interface), VFS (Virtual File System), 14 App Designer (Satellite Forms), 48, 58, 114-115 appearances, Palm devices, 11 AppForge Booster Runtime, downloading, 145 Button Ingot, Slot Machine, 158 Button Ingots, 134-138, 148 calculators, 134-145 Compile and Validate, 130 controls, 125-126 Database Converter, 130, 151 databases, programming, 147-154 demo, downloading, 117 Deploy to Device, 130 Font Converter, 130 Font Viewer, 130 Graphic Converter, 130 Graphic Viewer, 130 Ingots, 27, 134, 157-161 installing, 118 Label Ingots, 148-149, 158-159 language, Web site, 26 menu commands, Deploy to Palm OS, 144 menus, 130 Movie Converter, 130 Movie Viewer, 130 Open Project, 130 PDB Database Viewer, 130 Settings, 130 Text Box Ingots, 148 toolbars, 130 Universal Conduit Configuration, 130 VB controls, 124-125 versions, 126 Visual Basic, 118-128, 218 Zoom Level, 130 AppHandleEvent, creating applications with CW8 (CodeWarrior), code, 195-197 Application Icon (Application Property dialog box), 50 Property dialog box, 49-50 Stationery, 180
applications blank forms, 59 changing with CW8 (CodeWarrior), 184 conduits, 11-14 Constructor, CW8 (CodeWarrior), 184-185 creating, 189-197, 211-215 Creator ID, changing with CW8 (CodeWarrior), 184 databases, 27-29, 78-82, 88-95 displaying in Satellite Forms, 94 Hello World, 58-74 icons, changing with CW8 (CodeWarrior), 185-187 Java, 202-204 loading into POSE (Palm OS Emulator), 44 Main forms, displaying in Constructor, 190 names, changing or creating with CW8 (CodeWarrior), 185-187 Palm OS, 49-50 PQA (Palm query application), 44 PRC (Palm application), 44 properties, setting, 49-50, 111 running with CW8 (CodeWarrior), 182-184 Satellite Forms App Designer, 58 setting up with CW8 (CodeWarrior), 180-182 source code, 214 stationery, 180 tic-tac-toe game, 197 Time & Billing, 99-115 traditional, 11-12 Travel databases, icons, 171 Waba1, running with Palm emulator, 215 Web clipping, 12-13 Assembler, Pila Web site, 218 assembly language tools, 30 Attributes property, 223-225 Auto Keyboard property, 225 Auto Repeat property, 223 Auto Shift property, 225 Auto Stamp Control (Satellite Forms), 51, 223
B back (<-) button, 152 BASIC language tools, 25 SmallBasic Web site, 218 battery power, Palm devices, 6 BIN directory, uploading SDDI_PalmDB.PDB file or SF40SDK.PRC file, 74 Bitmap Control, 51, 101, 223 bitmaps, 79, 191 blank forms for applications, 59 Bluetooth (Palm OS 4), 15 Booster Runtime (AppForge), downloading, 145 Border property, 223 braces, curly ({ }), 214 btnBeginTime button, 105 btnDelete button, 104 btnDelete code, 153 btnEndTime button, 105 btnFind button, 106 btnNew button, 104 btnNext button, 104 btnPrevious button, 104 building database applications, 27-29 Hello World application, 58-63 search forms for Time & Billing program, 107-112 built-in components (Satellite Forms), 50 Button Contol (Satellite Forms), 51, 191, 223 button controls, 61, 80-92, 134, 174 Button Index property, 227 Button Ingots AppForce, 134-138, 148 Slot Machine, 158 buttons Abort, 74 AFButton control (AppForge), 125 AFGraphicButton control (AppForge), 125 AFRadioButton control (AppForge), 125
commands
back (<-), 152 Bitmap Control, 101 btnBeginTime, 105 btnDelete, 104 btnEndTime, 105 btnFind, 106 btnNew, 104 btnNext, 104 Button Control (Satellite Forms), 51 Button Ingots (AppForge), creating, 134-138 Catalog, available in, 191 Change Text, 72 Clear, 196 clicking (Sub Procedure), 139 cmdSpin Button Ingot, 160 CommandButton control, 124 controls, adding to forms, 92 Edit, 63, 170 Edit Form Properties, 171 Edit Script, 64 Find (Customer Look Up form), 113 on forms, 213 forward (->), 152 Graphic, 191 Graphic Push, 191 left mouse, 170 navigation, 104-105 New Project, 48 OptionButton control, 124 pasting keyboard shortcut, 134 properties, 148 Push, 192 Pushbutton (Field Tools Toolbar), 166 Radio Button (Field Tools Toolbar), 166 Radio Button Control (Satellite Forms), 51 Repeating, 192 right mouse, 170 scripts, exciting, 105 tnPrevious, 104
C C programming language code editor, 193 CodeWarrior Web site, 218 OnBoard C Web site, 218 calculators (AppForge) decimal values, 141 GUI (graphical user interface), 134-140 negative values, 140-141 numbers, 141-143 POSE (Palm OS Emulator), running in, 145 programming, 133 project, creating, 134 tangents (TAN function), 141 testing, 144-145 CASL, 31, 218 Catalog, 190-192 CDK (Conduit Development Kit) Web site, 14 cell phones (Handspring Springboard module), 15 Centered Square (Icon Drawing Toolbar), 167 Change Text button, 72 check boxes, AFCheckBox control (AppForge), 125 CheckBox control, 51, 124, 166, 191, 224 chips, 10-11 Class text control, properties, 90 CLASSPATH variable, setting in Waba SDK (Software Developers Kit), 209 Clear button, 196 click events, cmdSpin_Click event, 160-161 clicking buttons, Sub Procedures, 139 clipboard, 12-13, 79 cmd parameter (PilotMain function), 194 cmdPBP parameter (PilotMain function), 194 cmdSpin Button Ingot, 160 cmdSpin_Click event, 160-161
code AppHandleEvent applications, code to create with CW8 (CodeWarrior), 195-197 applications, 193-197, 214 btnDelete, 153 C, code editor, 193 databases, creating, 152-154 editor, 193 sysAppLaunchCmdNormalLaunch (launch code), 194 TextBox equal, setting to toggled dblTemp value, 140 Code Window, 127, 152 CodeWarrior (CW8), 20, 179-197, 218 colors (Palm OS 4), 16 columns data (edit controls), 91 Edit Column window, 109 MovieTable, 84-85 combo boxes, AFComboBox control (AppForge), 125 ComboBox control, 124 CommandButton control, 124 commands AppForge menu, Deploy to Palm OS command, 144 Display menu, Emulator, 214 Edit menu Copy, 165 Cut, 165 Delete, 165 Duplicate, 165 Insert Form, 80, 101 Paste, 165 Preferences, 182 Project Properties, 49, 62, 92 File menu Generate Application, 174 Get External Data, 115 New, 48, 170, 180 New Project, 78 Open, 164 save, 112, 164 Save As, 62, 170 Insert menu, Form, 171 pop-up menu Control Properties, 60 New Table, 150 Properties, 63
237
238
commands
Project menu Debug, 183 Make, 187, 197 Run, 183, 197 Source menu, Generate, 213 Table menu, Inventory, 151 View menu, Show Scripts, 82 comparing RAM and ROM, 8 Compile and Validate (AppForge), 130 compilers, GCC (GNU C/C++ compiler) Web site, 180 components adding to forms for Travel databases, 172-174 built-in (Satellite Forms), 50 Conduit Development Kit (CDK) Web site, 14 conduits, 11-14 configurations, Universal Conduit Configuration (AppForge), 130 connectivity of databases (Satellite Forms), 53-54 constructing. See creating Constructor, CW8 (CodeWarrior), 184-186, 190-193 Content windows App Designer (IDE), 48 Satellite Forms, finding control names, 51 Control Action and Filters window, 63, 109-110 Control Dimensions property, 224 Control Properties command (pop-up menu), 60 controls AFButton (AppForge), 125 AFCheckBox (AppForge), 125 AFClientSocket (AppForge), 126 AFComboBox (AppForge), 125 AFFilmstrip (AppForge), 126 AFGraphic (AppForge), 126 AFGraphicButton (AppForge), 125 AFGrid (AppForge), 125 AFInetHTTP (AppForge), 126 AFLabel (AppForge), 125 AFListBox (AppForge), 125
AFMovie (AppForge), 126 AFRadioButton (AppForge), 125 AFScanner (AppForge), 126 AFSerial (AppForge), 126 AFShape (AppForge), 126 AFSignatureCapture (AppForge), 126 AFSlider (AppForge), 126 AFTextBox (AppForge), 125-126 AFTimer (AppForge), 126 AFToner (AppForge), 126 AFVScrollBar (AppForge), 126 AppForge, 125-126 Auto Stamp Control, 51, 223 bitmap, 79 Bitmap Control, 51, 223 Button Control, 51, 134 buttons, 80-81, 92, 174, 223 Check Box Control, 51, 224 Class text, properties, 90 Custom Control, 51 Digital Ink controls on forms for Travel databases, 173-174 drop list, sorting data, 113 Drop List Control, 51, 224 drop-down list, properties, 107-108 eBegin edit, 105 edit, 88, 91, 103-104, 173 Edit Control, 50, 225 eTimeEnd edit, 105 frmFind form, 107-108 Graffiti Shift Indicator Control, 51, 225 handles (Satellite Forms), 51 HotSync Extension ActiveX Control, 114 Ink Control, 51, 225 ink on forms, properties, 103-104 List Box Control, 5, 108, 2251 Lookup Control, 51, 226 names (Satellite Forms), finding, 51 Paragraph Control, 50, 226 Properties window, 53 Radio Button Control, 51, 226 Rating drop-down list, 91 Satellite Forms, 51, 60 SFX Custom, properties, 227 Slider, 192 text, labels, 89
Text Control, 50, 227 Title Control, 50, 227 types, prefixes for naming, 230-231 VB (Visual Basic), 124-125 conventions, naming, 229-231 converters, 130, 151 Copy command (Edit menu), 165 CPU types, 10-11 Create New Filter window, 110-111 creating AppForge Button Ingots, 134-138 applications with CW8 (CodeWarrior), 189-197 names with CW8 (CodeWarrior), 185 with VisualWaba, 211-215 calculator (AppForge) project, 134 code for databases, 152-154 databases with Satellite Forms, 82-83 Form 1, 78-79 forms, 78-80 control buttons, adding, 92 GUI (graphical user interface), 88-92 for Time & Billing program, 100-101 for Travel databases, 171-172 Form_Load events, 139 frmTime GUI (graphical user interface) for Time & Billing program, 102-103 GUIs (graphical user interfaces), 134-138, 148-149 icons with icon editor, 186 tables, 83-87, 101-102 Travel databases, 170-171 Creator IDs, 50, 62, 151, 184 Ctrl+F5 keyboard shortcut, 183, 197 Ctrl+V keyboard shortcut, 134 curly braces ({ }), 214 Custom Control (Satellite Forms), 51 Customer Look Up form, displaying, 113
dialers, Network (IP addresses)
Cut command (Edit menu), 165 CW8 (CodeWarrior), 20, 179-197, 218
D data columns for edit controls, 91 HotSync Extension ActiveX Control, 114 navigation buttons, 104-105 sharing, 114 sorting, 113 Travel databases, synchronizing with desktops, 175-176 Data control, 125 Data Source property, 222-224 data types, prefixes for naming variables, 229 Database Converter (AppForge), 130, 151 Database Management Systems (DBMS), HotSync Extension ActiveX Control, 114 Database Window, 150 databases AppForge, 148-151 applications building, 27-29 Satellite Forms, 78-80, 88-95 buttons, properties, 148 Code Window, NewRecord variable, 152 code, creating, 152-154 connectivity (Satellite Forms), 53-54 creating, 82-83, 150 Creator IDs, registering, 151 designing, 149-152 development (Satellite Forms), Time & Billing program, 99 database navigation, 104-106 desktop database integration, 114-115 forms, creating, 100-101 frmTime GUI (graphical user interface), creating, 102-103 search forms, building, 107-112 tables, creating, 101-102 testing, 112-113
Edit Databases (Forms Toolbar), 166 FileMaker Mobile Web site, 218 flat file, 30, 83 Form_Load event, 153-154 Item field, 149 Jfile Web site, 218 MobileDB Web site, 218 MovieDatabase, 94 navigating in Time & Billing program, 104-106 PDA Toolbox Web site, 218 PDB (Palm database), 44 programming with AppForge, 147-154 Quantity field, 149 relational, 53-54, 83 Table window, 83 tables, creating, 83-87 Travel, 169-176 dates, Auto Stamp Control (Satellite Forms), 51 DBMS (Database Management Systems), HotSync Extension ActiveX Control, 114 DB: Motorola Dragonball chip (Motorola MC68328), 10 Debug command (Project menu), 183 toolbar, Visual Basic IDE (Integrated Development Environment), 121 debugging option changes (Satellite Forms), 70 decimal values, calculators (AppForge), 141 decompilers, Ptools Web site, 218 Delete Column property, 226 Delete command (Edit menu), 165 demos, downloading CW8 (CodeWarrior), 179 Deploy to Device (AppForge), 130 Deploy to Palm OS command (AppForge menu), 144 designers, App Designer (Satellite Forms), 48, 58, 114-115 designing databases, 149-152
desktop database integration, Time & Billing program, 114-115 Desktop DB Format (Application Property dialog box), 50 desktops Travel database data, synchronizing, 175-176 Windows, POSE (Palm OS Emulator), 36 development. See databases, development development processes, Satellite Forms, 58-63 development tools. See also tools AppForge, 26-27 assembly language tools, 30 basic languages, 25 CASL, 31 CW8 (CodeWarrior), downloading Lite version, 20 database applications, building, 27-29 flat file databases, 30 Java, 23-24 NS Basic language, 26 on-device, 22 Palm SDK, downloading, 20 PRC editing tools, 31-32 PRC-Tools, 21-22 spreadsheets, 30 Waba, 24-25 Device DB Format (Application Property dialog box), 50 devices Deploy to Device (AppForge), 130 emulating with POSE (Palm OS Emulator), 37 hardware, 8-11 on-device development tools, 22 Palm, 4-8, 11-13 POSE (Palm OS Emulator), ROMs, 36-38 Satellite Forms, downloading Hello World application, 74 dialers, Network (IP addresses), 70
239
240
dialog boxes
dialog boxes Application Property, 49-50 Download App & Table, 74 New, 181 Save As, 62 Select Index Files, 115 Digital Ink (Field Tools Toolbar), 167, 173-174 Dimensions property, 222-224 directories BIN, uploading SDDI_PalmDB.PDB and SF40SDK.PRC files, 74 PC, unzipping to POSE (Palm OS Emulator) emulators, 39 word usage, 39 DirListBox control, 124 Discard Near Points property, 225 Display menu commands, Emulator, 214 Displayed Column property, 224-226 displaying AppForge Ingots in Visual Basic IDE, 27 applications in Satellite Forms, 94 Customer Look Up form, 113 icons in Constructor, 186 Main forms in Constructor, 190 messages, 41 Modem Sync screen, 67 pop-up menus in POSE (Palm OS Emulator), 65 dividing numbers, calculators (AppForge), 141-143 Don’t Modify Table property, 222 Download App & Table dialog box, 74 Download Application to Handheld window, 71, 94 downloaded emulators (POSE), unzipping to PC directories, 39 downloading AppForge, 117, 145 Creator ID, 184 CW8 (CodeWarrior), 20, 179 emulators (POSE), 38
Ghost, 204 Hello World application, 71-74 J9 (Virtual Machine), 203 JUMP, 203 Kawt (KVM Abstract Window Toolkit), 203 KVM (Kilobyte Virtual Machine), 202 Palm SDK, 20 PDB Explorer, 175 POSE (Palm OS Emulator), 36 Satellite Forms, 47, 218 SDK (Software Developers Kit), 208 SuperWaba, 203 VisualWaba, 209 Waba, 203, 209, 215 Draw Separator Lines property, 226 DriveListBox control, 124 drop list control, sorting data, 113 Drop List Control, 5, 2241 Drop List Dimensions property, 224 drop-down list controls, 91, 107-108 Duplicate command (Edit menu), 165
E eBegin edit control, 105 Edit button, 63, 170 Edit Column window, 83, 101, 109 Edit Control, 50, 91, 102-104, 173, 225 Edit Databases (Forms Toolbar), 166 Edit Form Properties (Forms Toolbar), 166, 171 Edit menu commands Copy, 165 Cut, 165 Delete, 165 Duplicate, 165 Insert Form, 80, 101 Paste, 165
Preferences, 182 Project Properties, 49, 62, 92 PDA Toolbox GUI (graphical user interface), 165 Edit Script button, 64 Edit toolbar, Visual Basic IDE (Integrated Development Environment), 121 editing eBegin or eTimeEnd edit controls, 105 tools (PRC), 31-32 editors code, 193 icon, 186 Script Editor, opening, 82 emulating devices with POSE (Palm OS Emulator), 37 Emulator command (Display menu), 214 emulators Palm, running Waba1 application, 215 POSE (Palm OS Emulator), 14, 17 downloading, 38 opening, 214 unzipping to PC directories, 39 entries, properties window, 109 equals, TextBox (code to set toggled dblTemp value), 140 eTimeEnd edit control, 105 Evenly Space Object Horizontally (Alignment Toolbar), 167 Evenly Space Vertically (Alignment Toolbar), 167 event-driven programming language, VB (Visual Basic), 27, 118-127, 134, 139 events AppHandleEvent applications, code to create with CW8 (CodeWarrior), 195-197 Button controls, 134 click, cmdSpin_Click event, 160-161 Form_Load, 139, 153-154 GUIs (graphical user interfaces), handling, 139-140
functions
explorers, PDB Explorer, 175-176 extractors, resources (Prc2Pilrc Web site), 218 EZ: Motorola Dragonball EZ chip (Motorola MC68EZ328), 11
F Falch Web site, 180 Falch.Net Web site, 22 features, new (Palm OS 4), 14-17 Feedback Slider Control, 191 Field (Field Tools Toolbar), 166, 191 Field Tools Toolbar, PDA Toolbox GUI (graphical user interface), 166-167 fields, Item or Quantity, 149 File menu commands Generate Application, 174 Get External Data, 115 New, 48, 170, 180 New Project, 78 Open, 164 Save, 112, 164 Save As, 62, 170 PDA Toolbox GUI (graphical user interface), 164 File Toolbar, PDA Toolbox GUI (graphical user interface), 165 FileListBox control, 124 FileMaker Mobile Web site, 29, 218 files flat file databases, 30, 83 PRC, installing with Install Tool, 72 ROM, 38, 64 SDDI_PalmDB.PDB, uploading, 74 SF40SDK.PRC, uploading, 74 TravelData.PRC, 175 Waba SDK (Software Developers Kit), downloading, 209 filters, Create New Filter window, 110-111
Filters tab (Control Action and Filters window), 109-110 Find button, Customer Look Up form, 113 finding Satellite Forms control names, 51 flat file databases, 30, 83 folder, word usage, 39 Font Attributes property, 222 Font Converter (AppForge), 130 Font Viewer (AppForge), 130 Form 1, 78-79 Form Bitmap, 191 Form command (Insert lmenu), 171 Form Designer window, Visual Basic IDE (Integrated Development Environment), 126 Form Editor toolbar, Visual Basic IDE (Integrated Development Environment), 121 Form Layout window, Visual Basic IDE (Integrated Development Environment), 128 Form Properties window, 171-172 Form toolbar, Visual Basic IDE (Integrated Development Environment), 121 forms. See also Satellite Forms Access 2000, linking to intermediate tables, 115 bitmap controls, pasting images from clipboard, 79 blank for applications, 59 btnFind button, 106 buttons, 80-81, 92, 213 Control Action and Filters window, Filters tab, 109-110 control buttons, adding, 92 Create New Filter window, 110-111 creating, 78-80, 100-101, 171-172 Customer Look Up, displaying, 113
data, sorting, 113 drop list control, sorting data, 113 drop-down list control, properties, 107-108 eBegin edit control, 105 edit controls, 102-103 Edit Form Properties (Forms Toolbar), 166, 171 eTimeEnd edit control, 105 Form 1, changing properties, 79 frm prefix, 80 frmFind, 106-108 frmTime, finished version, 107 GUI (graphical user interface), creating, 88-92 ink control, properties, 103-104 Insert Forms (Forms Toolbar), 166 labels, placing, 212 list box control, properties, 108 look up, 100 Main, displaying in Constructor, 190 navigating, 80-82, 104-105 Pendragon Forms, 28, 218 properties, 100, 109 search, building for Time & Billing program, 107-112 target, setting, 81 Travel database, 172-174 Forms Toolbar, PDA Toolbox GUI (graphical user interface), 166 Form_Load event, 139, 153-154 Forth (Quartus) (PRC Editing tool), 32, 219 forward (->) button, 152 Frame control, 124 frm prefix (forms), 80 frmEntry, 80, 88 frmFind form, 106-108 frmTime GUI (graphical user interface), 102-103, 107 FSTN = Film compensative Super Twisted Numatic display, 11 functions PilotMain, 194 TAN (tangents), calculators (AppForge), 141
241
Gadget
242
G Gadget, 191 games, tic-tac-toe, 197 GCC (GNU C/C++ compiler) Web site, 180 Generate (Forms Toolbar), 166 Generate Application command (File menu), 174 Generate command (Source menu), 213 Get External Data command (File menu), 115 Ghost, downloading, 204 GNU C/C++ compiler (GCC) Web site, 180 Graffiti Shift Indicator control, 51, 191, 225 Graffiti software, 4-5 Graphic button, 191 Graphic Converter (AppForge), 130 Graphic Push button, 191 Graphic Viewer (AppForge), 130 graphical user interfaces. See GUIs graphics, AFGraphic control (AppForge), 126 grids, AFGrid control (AppForge), 125 GUIs (graphical user interfaces) AppForge Ingots (Slot Machine), 158-159 applications, creating with CW8 (CodeWarrior), 190-193 calculators (AppForge), 134-140 Catalog, 190 creating, 88-92, 148-149 frmFind form controls, 108 frmTime, creating, 102-103 PDA Toolbox, 164-167 Satellite Forms, Hello World application, 59 VisualWaba, 24
H handles, Satellite Form controls, 51 handling events, GUIs (graphical user interfaces), 139-140
Handspring Springboard module, 15, 218 handwriting-recognition software, 4 hardware devices, CPU types, 8-11 limitations (Palm devices), 5-8 skins, 39 Hello World application, building, 58. See also Satellite Forms Help menu, PDA Toolbox GUI (graphical user interface), 165 HN (Hungarian Notation), data type prefixes (naming variables), 229-231 HotSync Extension ActiveX Control, 114 icon, 66 IP addresses, Network dialer, 70 Palm OS devices, 13 setup window, 69 welcome window, 66 HotSyncing with POSE (Palm OS Emulator), Satellite Forms, 64-71 HTTP (Hypertext Transfer Protocol), AFInetHTTP control (AppForge), 126 Hungarian Notation (HN), 80, 229-231
I iBiz Technology Web site, 5 IBM DB2 Everyplace, 28-29, 218 J9 (Virtual Machine), downloading, 203 VisualAge Micro Edition, 23 Icon Drawing Toolbar, PDA Toolbox GUI (graphical user interface), 167 icons Application Icon (Application Property dialog box), 50 of applications, changing with CW8 (CodeWarrior), 185-187 creating with icon editor, 186 displaying in Constructor, 186 HotSync, 66 Travel databases, 171
ID numbers for Palm OS applications, Palm Web site, 50 IDEs (Integrated Development Environments), App Designer (Satellite Forms), 48, 58, 114-115 IDE Preferences window, 182-183 CASL, 31, 218 NS Basic language, 26 PilotMAG, 22 PocketC, 23 Visual Basic, 27, 118-128 VisualWaba, creating applications, 211 IDs, Creator, 50, 62, 151, 184 illusions, creating Slot Machine spinning, 160-161 Image control, 125 images files (ROMs), 38 pasting from clipboard, 79 Index, Sub Procedures (buttons clicking), 139 indicators Graffiti Shift Indicator Control (Satellite Forms), 51, 191 Shift Indicator (Field Tools Toolbar), 167 Ingots, AppForge Button Ingot, 148, 158 cmdSpin Button Ingot, 160 creating, 134-138 displaying in Visual Basic IDE, 27 Label Ingot, 148-149, 158-159 Slot Machine, 157-161 Text Box, 148 Initial Form (Application Property dialog box), 50 ink controls on forms, properties, 103-104 Digital Ink (Field Tools Toolbar), 167, 173-174 Ink Control (Satellite Forms), 51, 225 input, Palm devices or Pen, 5 Input Required property, 225-227
menus
Input window, 211 Insert Form command (Edit menu), 80, 101 Insert Forms (Forms Toolbar), 166 Insert menu commands, Form, 171 PDA Toolbox GUI (graphical user interface), 165 Install Tool, installing PRC files, 72 installing AppForge, 118 CW8 (CodeWarrior), 180 POSE (Palm OS Emulator), 38-39 PRC files with Install Tool, 72 Integrated Development Environments (IDEs), App Designer (Satellite Forms), 48, 58, 114-115 integration, desktop databases (Time & Billing program), 114-115 interfaces. See GUIs intermediate tables, linking to by Access 2000, 115 Inventory command (Table menu), 151 IP addresses, 68-70 Item field, 149
J J2ME (Java 2 Micro Edition), 24 J9 (Virtual Machine), downloading, 203 Java applications, 202-204 development tools, 23 Java 2, 24 VisualAge Micro Edition, 23, 218 VMs (Virtual Machines), 201 Waba Web site, 218 Java 2 Micro Edition (J2ME), 24 Java SDK Web site, 218 Jfile Web site, 218 JUMP, downloading, 203
K Kawt (KVM Abstract Window Toolkit), 202-203 Key Column property, 224-226 keyboard shortcuts Alt+3, 213 Ctrl+F5, 183, 197 Ctrl+V, 134 keyboards, Palm devices, 5 KVM (Kilobyte Virtual Machine), downloading, 202 KVM Abstract Window Toolkit (Kawt), 202-203
L Label (Field Tools Toolbar), 166, 191 Label control, 124 Label Ingots (AppForge), 148-149, 158-159 labels AFLabel control (AppForge), 125 edit controls, 104 on forms, placing, 172-173, 212 text controls, 89 Landware Web site, 5 languages AppForge, 26-27 assembly language tools, 30 BASIC, tools, 25 NS Basic, IDEs and Web site, 26 Palm OS (Operating System), 12 VB (Visual Basic), 27, 118-127, 134, 139 launchFlags parameter (PilotMain function), 194 launching applications, 194-195 lblSlot (Label Ingot), setting properties, 158 left mouse button, 170 limitations, hardware (Palm devices), 5-8 Line (Icon Drawing Toolbar), 167 Line control, 125 linking to intermediate tables by Access 2000, 115 MovieTable to frmEntry, 88
LispMe (PRC Editing tool), 32, 219 List, 191 List Box Control, 51, 108, 124, 225 list boxes, AFListBox control (AppForge), 125 List Contents property, 224 lists controls, Rating drop-down, 91 Drop List Control (Satellite Forms), 51 Popup List (Field Tools Toolbar), 166 loading applications into POSE (Palm OS Emulator), 44 locating Satellite Forms control names, 51 look up forms, 100 Lookup Control, 51, 226
M machines. See VMs Main forms, displaying in Constructor, 190 Make command (Project menu), 187, 197 managers, Visual Data Manager (creating databases), 150 managing projects with Project Explorer, 127 math. See calculators mathematical functions (Textbox), 133-134, 139-143 memory, 7-8 Menu Bar, PDA Toolbox GUI (graphical user interface), 164 menu bars, App Designer (IDE), 48 menus AppForge, 130 PDA Toolbox GUI (graphical user interface), 164-165 pop-up, displaying in POSE (Palm OS Emulator), 65 Visual Basic IDE (Integrated Development Environment), 120
243
messages, displaying
244
messages, displaying, 41 MIDP (Mobile Information Device Profile), 24 Miscellaneous (Application Property dialog box), 50 Mobile Information Device Profile (MIDP), 24 MobileDB Web site, 218 Modem Sync Preferences or screen, 67 modules, Handspring Springboard, 15 Motorola MC68328, 10 MC68EZ328, 11 MC68VZ328, 11 mouse buttons (left and right), 170 Move Column property, 226 Movie Converter (AppForge), 130 Movie Viewer (AppForge), 130 MovieDatabase, 94 movies, controls (AppForge), 126 MovieTable, 84-88 multiplying numbers, calculators (AppForge), 141-143 music, AFToner control (AppForge), 126
N Name of Application (Application Property dialog box), 50 Name of Control property, 222-223 names of applications, 185-187 of Satellite Forms controls, finding, 51 naming conventions, 229-231 navigating databases in Time & Billing program, 104-106 forms, 80-82 navigation buttons, 104-105 negative values, calculators (AppForge), 140-141 Network dialer, IP addresses, 70
New command (File menu), 48, 170, 180 dialog box, 181 new features of Palm OS 4, 14-17 New Project button, 48 command (File menu), 78 window, Visual Basic IDE (Integrated Development Environment), 118 New Session window, 42 New Table command (pop-up menu), 150 New window, 180 NewRecord variable, 152 non-debug ROM files, 64 notations, Hungarian, 80 NS Basic language, 26, 218 numbers adding, dividing, or multiplying, 141-143 random (Slot Machine), 157-161
O objects (Alignment Toolbar), 167 OLE (Object Linking and Embedding) control, 125 on-device development tools, 22 OnBoard C Web site, 218 Only Stamp property, 223 Open command (File menu), 164 Open Project (AppForge), 130 opening Constructor, CW8 (CodeWarrior), 185 frmFind form, 106 POSE (Palm OS Emulator), 214 Script Editor, 82 OptionButton control, 124 Orbworks Web site, 22 Oval (Icon Drawing Toolbar), 167
P PALM, 43 Palm III settings, 43
Palm OS (Operating System). See also PRC; POSE Application Stationery, 180 applications, 11-14, 49-50 Bluetooth, 15 CDK (Conduit Development Kit) Web site, 14 colors, 16 Computing, 4 conduits, 11 Developers’ Program Web site, 38 devices, 4-8, 11-13 Emulator window, 42 emulators, 14, 215 Graffiti software, 4 Handspring Springboard module, 15 hardware, 5-11 Install Tool window, 40 languages, 12 memory, comparing RAM and ROM, 8 new features, 14 Palm Developer Connection Web site, 218 PDB (Palm database), 44, 130, 175-176 PQA (Palm query application), 44 RAD (Rapid Application Development) tools, 12 SDK (Software Developers Kit), 17, 20 secondary storage, 14 Stationery applications, code to create with CW8 (CodeWarrior), 195-197 telephony, 15 usage patterns, 8 Web Clipping improvements, 15-16 Web site, 14, 17 Palm Pilot, 4-14 panels, Parameters, 210-211 Paragraph Control (Satellite Forms), 50, 226 parameters, PilotMain function, 194 Parameters panel, 210-211 Pascal (PRC Editing tool), 32, 219
projects
Paste command (Edit menu), 165 pasting images from clipboard, 79 keyboard shortcut, 134 Path variable, setting, 208-209 paths, Parameters panel, 210-211 PC directories, POSE (Palm OS Emulator) emulators, 39 PDA Toolbox Alignment Toolbar, 167 Icon Drawing Toolbar, 167 Field Tools Toolbar, 166-167 Forms Toolbar, 166 GUI (graphical user interface), 164-167 PDB Explorer, 175-176 Travel databases, 169-176 Web site, 29, 163, 218 PDAs (Personal Digital Assistants), 4-5, 218 PDB (Palm database), 44, 130, 175-176 Pen input, 5 Pencil (Icon Drawing Toolbar), 167 Pendragon Forms, 28, 218 Software Web site, 28 Perform Lookup with Column Contents property, 226 Personal Digital Assistants (PDAs), 4-5, 218 PictureBox control, 124 Pila Web site, 218 PilotMAG Web site, 22 PilotMain function, 194 Pippy (PRC Editing tool), 32, 219 plus sign (+), 82 Pocket C Web site, 218 Pocket Smalltalk (PRC Editing tool), 32 Pocket Squeak (PRC Editing tool), 32 PocketC, 22-23 PocketSmalltalk Web site, 219 PocketStudio Web site, 219 Pointer control, 124
pop-up menus commands Control Properties, 60 New Table, 150 Properties, 63 displaying in POSE (Palm OS Emulator), 65 Popup List (Field Tools Toolbar), 166 Popup Trigger, 192 ports (serial), AFSerial control (AppForge), 126 POSE (Palm OS Emulator), 14, 17, 35 applications, 18, 44 calculators (AppForge), running, 145 debugging option changes, 70 devices, ROMs, 36-38 emulators, 38-39, 214 HotSyncing, 64-71 installing, 38-39 messages, displaying, 41 pop-up menus, displaying, 65 PRC files, installing with Install Tool, 72 properties, setting, 65 ROMs, 36-42, 64 Satellite Forms, Hello World application, 71-72 setting up, 38-39 settings, 43 skins, 39 Travel databases, executing, 174 troubleshooting with Satellite Forms, 73-74 on Windows desktops, 36 POST, downloading, 36 PQA (Palm query application), 44 PRC (Palm application), 44 editing tools, 31-32 PRC-Tools, 21-22 files, 72, 175 prc transfer program, messages displayed, 41 Prc2Bin tool, 31 Prc2Pilrc tool, 31 Prc2Pilrc Web site, 218
preferences IDE Preferences window, 182-183 Modem Sync Preferences, 67 Preferences command (Edit menu), 182 prefixes control types, naming, 230-231 data types for naming variables, 229 frm (forms), 80 Primary PC Setup window, 67-68 procedures, Sub Procedures (buttons clicking), 139 processes, Satellite Forms development, 58-63 processing power, Palm devices, 6-7 programming. See also Java; Waba AppForge, 133 calculators (AppForge), 133-145 databases with AppForge, 147-154 programming languages (event-driven), VB (Visual Basic), 27, 118-127, 134, 139 programs. See applications Project Explorer, managing projects, 127 Project menu commands Debug, 183 Make, 187, 197 Run, 183, 197 Project Properties command (Edit menu), 49, 62, 92 Forms Toolbar, 166 window, 111, 170-171 Project Window, 164, 182 projects App Designer (IDE), 48 calculators (AppForge), creating, 134 Input window, 211 managing with Project Explorer, 127 Open Project (AppForge), 130 properties, changing, 92 saving, 112
245
246
projects
Slot Machine, 157-161 Travel databases, creating, 170-171 properties Action When Clicked, 223-227 Add/Edit Column, 225 Alignment, 225 Alternate Shape, 223-224, 227 AppForge Button Ingots, setting, 136-138 application, 62, 111 Attributes, 223-225 Auto Keyboard, 225 Auto Repeat, 223 Auto Shift, 225 Auto Stamp control, 223 Bitmap control, 223 Border, 223 button controls, 61, 81, 92, 223 Button Index, 227 of buttons, 148 Check Box control, 224 Class text control, 90 Control Dimensions, 224 controls (Satellite Forms), 221-223 Data Source, 222-224 Delete Column, 226 Dimensions, 222-224 Discard Near Points, 225 Displayed Column, 224-226 Don’t Modify Table, 222 Draw Separator Lines, 226 Drop List control, 224 Drop List Dimensions, 224 drop-down list control, 107-108 Edit control, 225 Edit Form Properties (Forms Toolbar), 166, 171 Font Attributes, 222 Form 1, changing, 79 form edit controls, 102 Form Properties window, 171-172 of forms, changing, 100 frmFind form controls, 107 Graffiti Shift Indicator control, 225 Ink control, 225 ink control on forms, 103-104 Input Required, 225-227
Key Column, 224-226 lblSlot (Label Ingot), setting, 158 list box control, 108, 225 List Contents, 224 Lookup control, 226 Move Column, 226 Name of Control, 222-223 Only Stamp, 223 Palm OS applications, setting, 49-50 Paragraph control, 226 Perform Lookup with Column Contents, 226 POSE (Palm OS Emulator), setting, 65 project, changing, 92 Project Properties (Forms Toolbar), 166, 170-171 Radio Button control, 226 Read-Only, 222 Retrieved Column, 226 Right Anchor Attribute, 224 Satellite Forms applications, setting, 49-50 Scrollbar, 226 SFX Custom control, 227 Stamp Type, 223 Table Name, 224-226 Text, 223-227 text control, 60, 227 Title control, 227 Underlined, 225-226 Visible, 222 window, 63, 109 Properties command (pop-up menu), 63 window, 53, 128 PTools tool, 31, 218 Puma Technologies (Satellite Forms) Web site, 27, 47, 218 Push button, 192 Pushbutton (Field Tools Toolbar), 166 Python (PRC Editing tool), 32, 219
Q-R Quantity field, 149 Quartus Forth (PRC Editing tool), 32, 219 QuickSheet Web site, 218
RAD (Rapid Application Development) tools, 12, 58 Radio Button (Field Tools Toolbar), 166 Radio Button Control (Satellite Forms), 51, 226 RAM and ROM, comparing, 8 random numbers (Slot Machine), 157-161 Rapid Application Development (RAD) tools, 12 Rating drop-down list control, 91 Read-Only property, 222 records, NewRecord variable, 152 registering Creator IDs (Web site), 62, 151 relational databases (Satellite Forms), 53-54, 83 Repeating button, 192 resource extractors, Prc2Pilrc Web site, 218 Retrieved Column property, 226 Right Anchor Attribute property, 224 right mouse button, 170 ROM image files, 38 non-debug file, 64 obtaining for POSE (Palm OS Emulator), 39-42 POSE (Palm OS Emulator), 36-38, 42 prc transfer program, messages displayed, 41 and RAM, comparing, 8 uploading, 40-41 Run command (Project menu), 183, 197 running CW8 (CodeWarrior), 180-184 Hello World application in POSE (Palm OS Emulator), 72 Waba1 applications with Palm emulator, 215 runtime files (Waba), downloading, 215
subtracting numbers, calculators (AppForge)
S Satellite Forms, 27 Access 2000, linking to intermediate tables, 115 App Designer, 48, 58, 114-115 Application Property dialog box, 49-50 applications displaying, 94 properties, setting, 49-50 Auto Stamp Control, 51, 223 Bitmap Control, 51, 223 Button Control, 51, 223 Check Box Control, 51, 224 components built-in, 50 controls, 51-53, 221-223 Custom Control, 51 data sharing, 114 databases applications, 78-82, 88-95 connectivity, 53-54 creating, 82-83 development (Time & Billing program), 99-115 relational, 53-54 tables, creating, 83-87 debugging option changes, 70 development process, 58-63 downloading, 47, 218 Drop List Control, 51, 224 Edit Control, 50, 225 Graffiti Shift Indicator Control, 51, 225 Hello World application, 58-74 HotSync Extension ActiveX Control, 114 HotSyncing with POSE (Palm OS Emulator), 64-71 Ink Control, 51, 225 List Box Control, 51, 225 Lookup Control, 51, 226 Palm OS applications, 49-50 Paragraph Control, 50, 226 POSE (Palm OS Emulator), troubleshooting, 73-74 Puma Technologies Web site, 47 RAD (Rapid Application Development) tool, 58 Radio Button Control, 51, 226 scripts, 63-64
SFX Custom control, properties, 227 Text Control, 50, 227 Title Control, 50, 227 Save As command (File menu), 62, 170 dialog box, 62 Save command (File menu), 112, 164 saving projects, 112 scanners, AFScanner control (AppForge), 126 Scheme (PRC Editing tool), 32, 219 screen size, Palm devices, 7 screens colors, 16 Modem Sync, displaying, 67 Script Editor, opening, 82 scripts, 63-64, 105, 213 scrollbars (AppForge), 126 Scrollbars control, 124, 192, 226 SDDI_PalmDB.PDB file, uploading, 74 SDK (Software Developers Kit) downloading, 208 Java Web site, 218 Palm SDK, downloading, 20 tool improvements, 17 Waba, 208-209 search forms, building for Time & Billing program, 107-112 searching Creator IDs (Web site), 62 secondary storage (Palm OS 4), 14 Select Index Files dialog box, 115 Selector Triffer, 192 serial ports, AFSerial control (AppForge), 126 SF40SDK.PRC file, uploading, 74 SFX Custom control, 227 Shape control, 125 shapes, 126, 167 sharing data, 114
Shift Indicator (Field Tools Toolbar), 167 Show Scripts command (View menu), 82 signatures AFSignatureCapture control (AppForge), 126 form ink control, 103-104 Simonyi, Charles, 229 skins, POSE (Palm OS Emulator), 39 Slider control, 192 sliders, 126, 191 Slot Machine, 157-161 SmallBasic Web site, 218 Smalltalk (Pocket) (PRC Editing tool), 32, 219 sockets, AFClientSocket control (AppForge), 126 software, 4-5 Software Developers Kit. See SDK sorting data, 113 source code, applications, 214 Source menu commands, Generate, 213 spinning illusion for Slot Machine, creating, 160-161 spreadsheets, 30, 218 Square (Icon Drawing Toolbar), 167 squares, Centered Square (Icon Drawing Toolbar), 167 Squeak (Pocket) (PRC Editing tool), 32, 219 Stamp Type property, 223 stamping, Auto Stamp Control (Satellite Forms), 51 Starter-Debug Settings window, 184 Stationery (Palm), 180, 195-197 storage, secondary (Palm OS 4), 14 storage capacity limits, Palm devices, 7-8 Sub Procedures, buttons clicking, 139 subtracting numbers, calculators (AppForge), 141-143
247
Sun Java Development Kit
248
Sun Java Development Kit. See SDK (Software Developers Kit) Sun Microsystems, 24, 202-203 SuperWaba, 24, 203 synchronizing Travel database data with desktops, 175-176 sysAppLaunchCmdNormalLaunch (launch code), 194
T Table (Field Tools Toolbar), 167, 192 Table menu commands, Inventory, 151 Table Name property, 224-226 Table window, 83 tables creating for Time & Billing program, 101-102 databases, relational (Satellite Forms), 53-54 intermediate, linking to by Access 2000, 115 MovieTable, 84-88 New Table command (pop-up menu), 150 TimeBill, 101 tabs, HotSync setup window, 69 TAN function (tangents), calculators (AppForge), 141 target forms, setting, 81 telephony, 15 testing calculators (AppForge), 144-145 database applications (Satellite Forms), 93-95 Time & Billing program, 112-113 Text Box Ingots (AppForge), 148 Text Control (Satellite Forms), 50, 227 text controls, 60, 89-90 Text property, 223-227 TextBox control, 124 equal, setting to toggled dblTemp value, code, 140 mathematical functions, 133-134, 139-143
textboxes, AFTextBox control (AppForge), 125 TFT = Thin Film Transistor display, 11 Think Outside Web site, 5 tic-tac-toe game, 197 Time & Billing program, 99-112 TimeBill table, 101 Timer control, 124 timers, AFTimer control (AppForge), 126 times, Auto Stamp Control (Satellite Forms), 51 TinySheet Web site, 218 Title Control (Satellite Forms), 50, 227 toolbars Alignment Toolbar, 167 AppForge, 130 Field Tools Toolbar, 166-167 File Toolbar, 165 Forms Toolbar, 166 Icon Drawing Toolbar, 167 PDA Toolbox, GUI (graphical user interface), 165-167 Visual Basic IDE (Integrated Development Environment), 120-121 Toolbox controls, 124-125 window, 123-126 toolboxes. See PDA Toolbox tools. See also development tools assembly language, 30 BASIC language, 25 Install Tool, installing PRC files, 72 Kawt (KVM Abstract Window Toolkit), 202-203 Palm SDK, downloading, 20 Prc2Bin, 31 Prc2Pilrc, 31 PTools, 31 RAD (Rapid Application Development), 12, 58 SDK (Software Developers Kit), improvements, 17 traditional applications, 11-12 Transfer ROM window, 41
Travel databases, 169-176 TravelData.PRC, 175 triggers, 192 troubleshooting POSE (Palm OS Emulator) with Satellite Forms, 73-74
U Underlined property, 225-226 Universal Conduit Configuration (AppForge), 130 uploading ROMs, 40-41 SDDI_PalmDB.PDB file, 74 SF40SDK.PRC file, 74 users, HotSync setup window, 69
V validating, Compile and Validate (AppForge), 130 values (AppForge), 140-141 variables CLASSPATH, setting in Waba SDK (Sofware Developers Kit), 209 naming conventions, 229-231 NewRecord, 152 Path, setting, 208-209 VB (Visual Basic), 27, 118-127, 134, 139 Version (Application Property dialog box), 50 versions, AppForge, 126 VFDIDE Web site, 22, 180 VFS (Virtual File System) API (Application Programmers Interface), 14 View menu commands, Show Scripts, 82 PDA Toolbox GUI (graphical user interface), 165 viewers (AppForge), 130 Virtual File System (VFS) Application Programming Interface (API), 14 Virtual Machines. See VMs Visible property, 222
windows
Visual Basic (VB), 27, 118-127, 134, 139 Visual Data Manager, creating databases, 150 VisualAge Micro Edition (IBM), 23, 218 VisualWaba, 24, 209-215 VMs (Virtual Machines), 201 J9, downloading, 203 Kawt (KVM Abstract Window Toolkit), 202-203 KVM (Kilobyte Virtual Machine), downloading, 202 SuperWaba, 203-203 VisualWaba, 209-215 Waba, 203, 207-215 VZ: Motorola Dragonball VZ chip (Motorola MC68VZ328), 11
W-Z Waba, 25 downloading, 203 Java applications, 203 programming, 207 running with Palm emulator, 215 SDK (Software Developers Kit), 208-209 Visual Waba, 24, 209-215 Web site, 24, 218 Web Clipping applications, 12-13 improvements, 15-16 Web sites AppForge, 26, 117, 145, 218 CASL, 218 Creator IDs, 62, 151, 184 CW8 (CodeWarrior), 20, 179, 218 Falch, 180 Falch.Net, 22 FileMaker Mobile, 29, 218 GCC (GNU C/C++ compiler), 180 Ghost, downloading, 204 Handspring SDK (Software Developers Kit), 218 iBiz Technology, 5 IBM DB2 Everyplace, 28, 218
J9 (Virtual Machine), downloading, 203 Java SDK (Software Developers Kit), 218 Jfile, 218 JUMP, downloading, 203 Kawt (KVM Abstract Window Toolkit), downloading, 203 KVM (Kilobyte Virtual Machine), downloading, 202 Landware, 5 LispMe, 219 MobileDB, 218 NS Basic language, 26 NSBasic IDE, 218 OnBoard C, 218 Orbworks, 22 Palm, 17 Palm Alliance program, 36 Palm Developer Connection, 218 Palm OS, 14, 20, 38, 50 PDA Toolbox, 29, 163, 218 PDB Explorer, downloading, 175 Pendragon, 28, 218 Pila, 218 PilotMAG, 22 Pippy, 219 PocketC, 22, 218 PocketSmalltalk, 219 PocketStudio, 219 POSE (Palm OS Emulator), downloading, 36-38 PRC-Tools, 21 Prc2Pilrc, 218 Ptools, 218 Puma Technologies (Satellite Forms), 47, 218 PumaTech, 27 Quartus Forth, 219 QuickSheet, 218 Satellite Forms, downloading, 47, 218 SDK (Software Developers Kit), downloading, 208 SmallBasic, 218 Squeak, 219 SuperWaba, downloading, 203 Think Outside, 5 TinySheet, 218 VFDIDE, 22, 180
VisualAge Micro Edition, 218 VisualWaba, downloading, 209 Waba, 24 downloading, 203 Java development, 218 runtime files, downloading, 215 SDK (Software Developers Kit), downloading files, 209 Web, 24 windows Code, 127, 152 Constructor, 185 Content, finding Satellite Forms control names, 51 Control Action and Filters, 63, 109-110 Create New Filter, 110-111 Database, 150 Download Application to Handheld, 71 Edit Column, 83, 101, 109 Form Designer, 126 Form Layout, 128 Form Properties, 171-172 HotSync, 66, 69 IDE Preferences, 182-183 Input, 211 Kawt (KVM Abstract Window Toolkit), 202-203 New, 180 New Project, 118 New Session, 42 Palm Install Tool, 40 Palm OS Emulator, 42 Primary PC Setup, 67-68 Project, 164, 182 Project Explorer, 127 Project Properties, 111, 170-171 Properties 63, 109, 53, 128 Starter-Debug Settings, 184 Table, 83 Toolbox, 123-126 Transfer ROM, 41 Visual Basic IDE (Integrated Development Environment), 123 Windows and an Install Tool, 40
249
250
Windows 95, 98, and 2000 (setting Path variable)
Windows 95, 98, and 2000 (setting Path variable), 208 Windows and an Install Tool window, 40 Windows desktops, POSE (Palm OS Emulator), 36 Windows Me and Windows XP, setting Path variable, 209 Zoom Level (AppForge), 130