Sie sind auf Seite 1von 18

The dBASE Book

Developing Windows Applications


With dBASE PLUS

Ken Mayer

Second Edition

The dBASE Book

Developing Windows Applications With dBASE PLUS


by Ken Mayer
All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording or by any information storage and retrieval
system, without written permission from the author, except for the inclusion of brief quotations in a review.
Copyright 2005, 2007 by Kenneth (Ken) J. Mayer
ISBN: 1-4288-7448-9 (sc) print

978-0-9812906-4-5 (electronic pdf file)

First Published by AuthorHouse 5/1/2007


Electronic version published by Freedom Graphics Press, Lytton, BC, Canada V0K 1Z0 on 6/26/2010
First Printing, 2005; Second Printing, 2007
Printed in the United States of America
Trademark and Copyright acknowledgments:
Visual dBASE, dBASE, dBASE PLUS, dQuery and variations of these product names and words are
registered trademarks of dataBased Intelligence, Inc.
Borland Database Engine, BDE, Paradox, InterBase and Delphi are registered trademarks of Borland
International, Inc.
Microsoft, Windows XP (and all other forms of the names of the Windows operating system), Word,
Excel, FoxPro are registered trademarks of Microsoft Corporation.
Quicken is a registered trademark of Intuit, Inc.
Inno Setup is copyrighted to Jordan Russel and Martijn Laan
Apache is copyrighted to the Apache Software Foundation
No attempt has been made to designate as trademarks or service marks all personal computer words or
terms in which proprietary rights might exist. The inclusion, exclusion or definition of a word or term is not
intended to affect, or express any judgement on, the validity or legal status of any proprietary right which
may be claimed in that word or term.
Disclaimer
The author and publisher have used their best efforts in preparing this book, and the programs contained
herein. However, the author and publisher make no warranties of any kind, express or implied, with regard
to the documentation or programs contained in this book, and specifically disclaim without any limitations,
any implied warranties of merchantability and fitness for a particular purpose with respect to program
listings in the book and/or the techniques described in the book. In no event shall the author or publisher
be responsible or liable for any loss or profit or any other commercial damages, including but not limited
to special, incidental, consequential or any other damages in connection with or arising out of furnishing,
performance, or use of this book or the programs.

Table of Contents

Table of Contents
About the Author............................................................................. 1
Acknowledgments and Thanks...................................................... 3
Introduction...................................................................................... 5
Part I - Getting Started.................................................................... 7
Chapter 1 - Setup and Parts of the Environment.......................... 9

dQuery the Startup Program............................................................................ 9


Some Basic Setup............................................................................................... 9
The dBASE Desktop......................................................................................... 14
The Title Bar..........................................................................................................................14
The Menu Bar.......................................................................................................................15
The Tool Bar..........................................................................................................................15
The Navigator Window..........................................................................................................15
The Command Window........................................................................................................16
The Status Bar......................................................................................................................16

Important Tools in dBASE PLUS....................................................................... 17

Speed Menus........................................................................................................................17
Getting Help..........................................................................................................................17
Using the Knowledgebase....................................................................................................19

Windows Vista................................................................................................... 19

Part II - Data................................................................................... 21
Chapter 2 - Table Types................................................................ 23

Should I Change the Table Level?..................................................................... 23


Terminology....................................................................................................... 24
The dBF Field Types......................................................................................... 24

Field Properties.....................................................................................................................25
Null Values............................................................................................................................26
Field Names..........................................................................................................................27
Table Language Drivers........................................................................................................27
Indexes.................................................................................................................................28
Using BLOB Fields................................................................................................................30
DBF Table Limits...................................................................................................................30

Table Design Guidelines.................................................................................... 30

Identify the Type of Information You Need to Store..............................................................31


Break the Information Down.................................................................................................31
Determine The Relationships Among the Tables..................................................................31

Making it Possible to Upsize to Other Platforms............................................. 33


v

Table of Contents

Designing Your Tables and Application Appropriately...........................................................33

Chapter 3 - SQL - A Different Language...................................... 35

What is SQL, and Why Is It Important?............................................................. 35


Calculated Fields............................................................................................... 39
SQL Joins.......................................................................................................... 40
The WHERE Clause.......................................................................................... 40
Read Only Queries............................................................................................ 40
Other Useful Local SQL Commands................................................................. 41

Creating a table.....................................................................................................................41
Add/Remove Fields...............................................................................................................41
Deleting a Table....................................................................................................................41
Renaming A Table.................................................................................................................42
Creating an Index Tag...........................................................................................................42
Deleting an Index Tag...........................................................................................................42
Adding Data to a Table..........................................................................................................42
Update a Set of Data............................................................................................................42

Chapter 4 - Connecting to SQL and Local Databases............... 45

What Is SQL Data, versus dBASE or Local Tables?....................................... 45

Database Aliases..................................................................................................................45

Making the Connection...................................................................................... 46

Start the Data Engine............................................................................................................46


Create the Database Alias....................................................................................................47
Start dBASE..........................................................................................................................48

Other Data Engines........................................................................................... 49


ODBC Drivers.................................................................................................... 49
In General.......................................................................................................... 50
Creating a Database Alias for Local Tables....................................................... 50

Part III - Object Oriented Code and dBASE................................. 53


Chapter 5 - Introduction to Objects and dBASE PLUS.............. 55

OOP Concepts and Terminology....................................................................... 55


Working with Simple Objects............................................................................. 57

Creating a form object...........................................................................................................57


Creating Objects On A Form.................................................................................................58

Dot Notation...................................................................................................... 59
Containership.................................................................................................... 60
Understanding the Object Inspector.................................................................. 60
Understanding Events....................................................................................... 61

Windows is Event-Driven......................................................................................................61
What is Event-Driven Programming?....................................................................................62
dBASE Events......................................................................................................................62
Using the dBASE Form To See How This Works..................................................................62
vi

Table of Contents

Event Handlers.....................................................................................................................63
Assigning Event Handlers.....................................................................................................63

Working With Methods...................................................................................... 64


Codeblocks........................................................................................................ 64

Expression Codeblocks........................................................................................................65
Statement Codeblocks..........................................................................................................65
Using Codeblocks as Event Handlers...................................................................................66

Using Custom Properties and Methods............................................................. 66


The Object is Built From the Class.................................................................... 66

Parts of a Class.....................................................................................................................66
The Class Declaration Statement.........................................................................................66
The Class Constructor Code.................................................................................................67
Class Declaration of Methods...............................................................................................68
The ENDCLASS Statement..................................................................................................69

The className and baseClassName Properties.............................................. 71


Working with Object Reference Variables......................................................... 72
The dBASE Object Class.................................................................................. 72
Types of Classes............................................................................................... 73

Stock Classes.......................................................................................................................73
User-created Custom Classes..............................................................................................73
Building Custom Classes from Scratch.................................................................................73
General Syntax for Custom Classes.....................................................................................74

Declaring Class Parameters.............................................................................. 76


Using Class Hierarchies.................................................................................... 77
Using the Scope Resolution Operator............................................................... 79

Overriding Methods and Events............................................................................................81

Object Containership......................................................................................... 81

The Keyword This.................................................................................................................81


The Keyword Form...............................................................................................................81
The Keyword CLASS............................................................................................................82

Using Objects as Parameters............................................................................ 84


Making Objects Go Away.................................................................................. 84

Multiple References to the Same Object..............................................................................85


Multiple Instances of the Same Class...................................................................................86

Protecting Members of a Class......................................................................... 86


Knowing What the Members of a Class Are...................................................... 88

Chapter 6 - Working with the Data Object Model (OODML)....... 91

An Overview...................................................................................................... 91
Creating and Coding Query Objects................................................................. 92

How Do I Use a Query?........................................................................................................92


Query Objects and SQL Server Databases..........................................................................94

Rowset and Field Objects The Heart of the Data Object Structure................ 95

Some Basic Information about Rowsets...............................................................................96


Rowset Events and Event Handlers.....................................................................................96
vii

Table of Contents

Navigation In A Rowset.........................................................................................................99
Programmatically Stepping Through a Rowset...................................................................101
Editing Data In a Rowset....................................................................................................102
Deleting Rows.....................................................................................................................102

Fields Array and Field Objects........................................................................ 103

Field Class..........................................................................................................................103
Looping Through All Fields In A Table.................................................................................104
Other Field Object Events, Methods, etc............................................................................104
OLE, Binary and Memo Fields............................................................................................105

Creating and Coding Database Objects.......................................................... 105

The Default Database.........................................................................................................105


Creating a Database Object Reference..............................................................................105
Table Maintenance..............................................................................................................106
Transaction Processing.......................................................................................................106

Using the Index Object(s)................................................................................ 107

More on Expressions..........................................................................................................107

Creating and Coding Session Objects............................................................ 109

The Default Session............................................................................................................ 110

Creating and Coding Stored Procedure Objects..............................................110


The TableDef Object.........................................................................................110

List Field Information........................................................................................................... 111


List Index Information.......................................................................................................... 111

The UpdateSet Object......................................................................................112

Part IV - Data Objects and The Language................................. 113


Chapter 7 - OODML, SQL, and XDML........................................ 115

How To Do Things You May Have Done Before...............................................115

Finding Data........................................................................................................................ 115

Performing Lookups in Other Tables............................................................... 127


Shortening References.................................................................................... 128
Relating Tables................................................................................................ 129

Setting a Relationship Between Parent and Child Tables...................................................129


Set Skip...............................................................................................................................130
Referential Integrity Adding A Parent to Parent/Child......................................................134
Referential Integrity Cascading Deletes...........................................................................135
Child Table Sorted Differently?............................................................................................136

Calculated Fields............................................................................................. 137


Morphing Data................................................................................................. 138
More on Data Object Events........................................................................... 140

Query Object - canOpen()...................................................................................................141


Rowset Object onAppend()..............................................................................................141
Rowset Object canSave()................................................................................................142

UpdateSet....................................................................................................... 143

Copying a Table or Rowset.................................................................................................143


Using Copy() with Calculated Fields...................................................................................145
viii

Table of Contents

Appending Rows From Another Table................................................................................146


Updating Rows From Another Rowset................................................................................147
Updating Rows and Adding NEW Rows.............................................................................148
Deleting Rows.....................................................................................................................149

Chapter 8 - Creating and Working With Data Modules............ 151

What is a Data Module, and Why Should You Care?...................................... 151


Starting dQuery............................................................................................... 151
Using dQuery to Create and Modify Data Modules......................................... 153
Opening an Existing Data Module................................................................... 156

Examining the Source Code...............................................................................................156

Filtering Data With Conditional Statements..................................................... 158


Adding Calculated Fields................................................................................. 160

A More Complex Calculated Field?.....................................................................................160

Using Multiple-Table Queries.......................................................................... 161


Understanding Relationships Among Different Tables.................................... 162
Using Multiple Database Queries.................................................................... 163

Chapter 9 - Working in a Shared Environment......................... 165

Programming for a Shared Environment......................................................... 165


Opening a Table for Exclusive Use.................................................................. 166
Opening a Table for Read-Only (RO) Access.................................................. 167
Locking Data................................................................................................... 168

Implicit Locks......................................................................................................................168
Explicit Locks......................................................................................................................168
Using the Session Object to Modify Lock Behavior............................................................169
Locking the Rowset.............................................................................................................171
The _DBASELOCK Field....................................................................................................171
Maximum Locks..................................................................................................................172

Using Session Objects.................................................................................... 172

Adding a Session Object In the Form Designer..................................................................173


Adding a Session Object to a Data Module........................................................................173
The Session Object and Encrypted Tables.........................................................................174

Locking Related Tables................................................................................... 175


Processing Transactions................................................................................. 175

Drawbacks to Using Transactions.......................................................................................175

CacheUpdates................................................................................................. 176
Working with Non-dBASE Tables.................................................................... 176

Transaction Processing.......................................................................................................176

Chapter 10 - Security.................................................................. 179

The PROTECT Command............................................................................... 179


SET ENCRYPTION......................................................................................... 183
LOGOUT......................................................................................................... 183
ix

Table of Contents

Security and Paradox Tables........................................................................... 183


Security and SQL Server Tables..................................................................... 185
The Session Object......................................................................................... 185
The Database Object...................................................................................... 185
Application Security......................................................................................... 185

Part V - Designing the User Interface........................................ 187


Chapter 11 - Working With the Designers................................. 189

A Warning........................................................................................................ 189
The Form Designer......................................................................................... 189

Form Designer Properties...................................................................................................192

The Menu Designer......................................................................................... 193


The Report/Label Designer............................................................................. 194
The Table Designer......................................................................................... 195
The SQL Designer........................................................................................... 196
The Data Module Designer............................................................................. 196
Designer Common Tools................................................................................. 196

The Inspector......................................................................................................................196
The Component Palette......................................................................................................199
The Field Palette.................................................................................................................201
The Format Toolbar.............................................................................................................202

Chapter 12 - Creating Forms...................................................... 205

What is a Form?.............................................................................................. 205


Design Concepts............................................................................................. 205
Types of Forms................................................................................................ 206
Creating a Form.............................................................................................. 207

Form Metrics.......................................................................................................................208
Add a Text Control..............................................................................................................209
Saving The Form................................................................................................................210
Modifying Properties of the Text Control.............................................................................210
Add a Pushbutton............................................................................................................... 211
Run the Form...................................................................................................................... 211
Add An Event Handler.........................................................................................................212
Modifying .wfm files.............................................................................................................213
Two-way Tools....................................................................................................................215

OODML and Forms......................................................................................... 216

Put Some Fields On The Form...........................................................................................216


Interacting With the Data....................................................................................................219
Putting Buttons On the Form..............................................................................................219
Form Cosmetics..................................................................................................................235

Multi-Page Forms....................................................................................... 236

Table of Contents

Changing Pages Using a TabBox Control...........................................................................236


Changing Pages Using PushButtons..................................................................................239
Potential Problems..............................................................................................................241

Running Forms................................................................................................ 241


Communicating Between Forms..................................................................... 242

Passing Data to and Returning Data from A Dialog Form...................................................242


It Is Important That You Understand ..................................................................................246
What Can This Be Used For?.............................................................................................246

Naming Your Controls..................................................................................... 247


Tab Order Of Controls..................................................................................... 247

Some Notes on Tab Order..................................................................................................249

Chapter 13 - Stock Form Controls............................................. 253

Windows XP Themes and Other Changes...................................................... 253


Common Properties, Events and Methods...................................................... 257
A Brief Overview of the Stock User-Interface Controls.................................... 257
Text.................................................................................................................. 257
TextLabel......................................................................................................... 259
Entryfield......................................................................................................... 259
Spinbox........................................................................................................... 262
Checkbox........................................................................................................ 264
Radiobutton..................................................................................................... 265
Container......................................................................................................... 268
Notebook......................................................................................................... 269
Editor............................................................................................................... 269
Combobox....................................................................................................... 272
Listbox............................................................................................................. 275
Grid.................................................................................................................. 276

Getting Started With A Grid.................................................................................................276

Tabbox............................................................................................................. 279
Pushbutton...................................................................................................... 282

Windows XP/Vista, Themes, and Pushbuttons...................................................................282

Line.................................................................................................................. 284
Rectangle........................................................................................................ 284
Image.............................................................................................................. 285
Shape.............................................................................................................. 285
TreeView and TreeItem................................................................................... 285
Progress.......................................................................................................... 291
ActiveX............................................................................................................ 293
ReportViewer................................................................................................... 298
SubForm.......................................................................................................... 301

xi

Table of Contents

Chapter 14 - Working With The Grid.......................................... 305

Getting Started................................................................................................ 305

The Columns Array.............................................................................................................306


The Columns editorType Property.....................................................................................310
Editable or Not?..................................................................................................................313
Editable Grids.....................................................................................................................313
Non-Editable Grids..............................................................................................................314

Display Issues................................................................................................. 314

Fonts...................................................................................................................................314
Colors..................................................................................................................................315
Other Grid Appearance Properties......................................................................................316

Changing the Appearance of Individual Columns........................................... 317


Enhancing the Grids Abilities.......................................................................... 318
Multiselect Grids.............................................................................................. 318
Changing Rowset Sort Order.......................................................................... 321
Conditional Colors of Cells and Rows............................................................. 325

The Grids rowSelect and multiSelect Properties and Colored Cells..................................327


Coloring a Whole Row........................................................................................................329

Saving and Restoring Column Positions......................................................... 330

Multi-User?..........................................................................................................................335
Saving/Restoring More Properties Than Shown Here........................................................335

Using Multi Table Rowsets.............................................................................. 336


Building A Grid On The Fly.............................................................................. 336
Restating Datalinks......................................................................................... 338

Chapter 15 - Common Properties and Event Handlers of Form


Controls................................................................................... 341

Common Properties........................................................................................ 341

Formatting Data Picture and Function.............................................................................341


The enabled Property and the when() Event......................................................................342

Common Events ............................................................................................. 343

Event Sequences................................................................................................................343
The key() Event...................................................................................................................346
The onKey() Event..............................................................................................................346
The onChange() Event........................................................................................................347
Using the onLostFocus() Event to Force Navigation and/or Validation...............................347
The onMouseOver() and onMouseOut() Events.................................................................348

Data Validation................................................................................................ 348

Table Designer/Field Level Validation.................................................................................348


Control-Level Validation......................................................................................................349
Form-Level Validation.........................................................................................................351
Record-Level Validation......................................................................................................351

Drag and Drop................................................................................................. 354

What Else Can Be Done?...................................................................................................357

xii

Table of Contents

Chapter 16 - Custom Forms and Custom Form Classes......... 359

Source Code Aliases vs. Database Aliases, and Why Theyre Important....... 359

How To Create A Source Code Alias.........................................................................................360

Using Custom Forms....................................................................................... 362

Why Work With Custom Form Classes?.............................................................................362


Changing Built-in Default Property Values..........................................................................362
Creating New (Custom) Properties for Custom Form Classes...........................................363
Assigning Default Actions to Event Handlers......................................................................363
Creating Methods for a Custom Class................................................................................363
Define Default Controls for a Form.....................................................................................363
The Complete Custom Form Class.....................................................................................363
Clearing Out The Custom Form Class................................................................................366
A Data Custom Form..........................................................................................................367
Placing Custom Forms in Source Alias Folder....................................................................370
Using The Data Custom Form..........................................................................................371

Creating Classes for Control Objects.............................................................. 374

Why Create Your Own Custom Classes?...........................................................................375


Methods of Creating and Modifying Custom Classes.........................................................375
Creating a Custom TextLabel Class....................................................................................376
Creating a Custom Entryfield Class....................................................................................378
Creating a Custom Spinbox Class......................................................................................379
Creating a Custom Editor Class..........................................................................................379
Creating a Custom Image Class.........................................................................................379
Cleanup of the Custom Class Code....................................................................................379
Putting These Custom Classes to Work.............................................................................381
Creating a Custom Pushbutton Class.................................................................................385
Putting the Custom Pushbutton Classes to Work...............................................................390
Modifying the Base Pushbutton Class................................................................................392

Using Your Custom Classes For New Forms.................................................. 393

Chapter 17 - Using the Custom Classes that Ship with dBASE.... 397

Custom Pushbuttons....................................................................................... 397


Custom Controls on the Form Controls Tab.................................................... 399

Seeker.................................................................................................................................399
Splitter.................................................................................................................................401
Animate...............................................................................................................................405
Calendar.............................................................................................................................406
Form Viewer........................................................................................................................408

Chapter 18 - Creating Menus, Popup Menus, Speedbars and


Toolbars................................................................................... 411

Creating Menus................................................................................................411
Edit Menu Options..............................................................................................................413

Attaching the Menu to a Form......................................................................... 414


Creating an Application Menu......................................................................... 415

Adding A Separator.............................................................................................................417
xiii

Table of Contents

Attaching a Menu to the Application Framewindow......................................... 417

Form and Rowset References...................................................................................................418

Creating Popup (Right-Click) Menus............................................................... 421

The onInitMenu Event.........................................................................................................423


Attaching a Popup Menu to a Form....................................................................................424

Creating SpeedBars........................................................................................ 425


Creating Toolbars............................................................................................ 428

How Do You Design a ToolBar?..........................................................................................428


More Source Code Alias Stuff.............................................................................................429
Putting Toolbuttons in the Toolbar.......................................................................................429
Making The Toolbar More Useful........................................................................................430
Testing Our Toolbar.............................................................................................................433
Adding Functionality To the ToolBar....................................................................................436
Things to Note.....................................................................................................................440
Toolbars and SDI Forms.....................................................................................................443
Floating Palettes versus Attached to Form.........................................................................444

Chapter 19 - Reporting and Printing.......................................... 445

Report Objects................................................................................................ 445


How a Report is Rendered.............................................................................. 446
The Report Designer....................................................................................... 447

Metrics................................................................................................................................448

Creating A Simple Report................................................................................ 448

A Quick Look At The Design Surface..................................................................................448


Report Headings.................................................................................................................449
Adding A Page Number.......................................................................................................450
Add a Table.........................................................................................................................451
Place Fields On The Report................................................................................................451

Multi-Table Reports......................................................................................... 455

Start the Report...................................................................................................................455


Add the Tables....................................................................................................................456
The detailBand....................................................................................................................456
The Group Object...............................................................................................................456
Change the Controlling Rowset..........................................................................................457
Summary (Aggregate) Calculations....................................................................................458
Group Report Hints.............................................................................................................460

Labels.............................................................................................................. 462

Custom Label Sizes?..........................................................................................................465

Printing Reports............................................................................................... 465

Print from the Preview Window...........................................................................................466


Print Using Code.................................................................................................................466
Create A Preview Form Using a ReportViewer Object........................................................467

General Report Designer Hints....................................................................... 468

Field Labels.........................................................................................................................468
Alignment Tools...................................................................................................................468
Lines...................................................................................................................................468
xiv

Table of Contents

Large Tables.......................................................................................................................469
Navigating In Report Designer............................................................................................469
Null Fields...........................................................................................................................469
Displaying Numeric Values.................................................................................................470

Part VI - Programming................................................................ 471


Chapter 20 - Programming in dBASE PLUS............................. 473

Using the Source Code Editor......................................................................... 473

Setting the Source Code Editors Default Properties..........................................................474


Using the Source Editor To Modify Your Forms, Reports, Labels and other Source Code....475

Getting Started................................................................................................ 475

Documenting Your Code.....................................................................................................476


Indenting Your Code...........................................................................................................478
Creating the Program File...................................................................................................479
Testing Programs................................................................................................................479

Working with the Command Window............................................................... 480

Entering and Executing Commands...................................................................................480


Pasting Syntax from Help or Other Files.............................................................................481

Functions and Procedures.............................................................................. 481


Working with Memory Variables...................................................................... 483

Codeblocks.........................................................................................................................484
Function Pointers................................................................................................................485
The Scope Commands.......................................................................................................485
Assignment Operators........................................................................................................491
Math....................................................................................................................................492

Some Basic Commands.................................................................................. 493

Controlling Program Flow...................................................................................................495

Working with Data Types................................................................................. 506

Performing Financial Calculations......................................................................................506


Computing Engineering and Scientific Formulas................................................................506
Working with Date Data......................................................................................................508
Working with Time Data...................................................................................................... 511
DateTime() And Related Functionality................................................................................ 511
Working with Logical Data..................................................................................................513
Working with Character Data..............................................................................................513
Converting Data Types.......................................................................................................513

Using Preprocessor Directives........................................................................ 514


Using Source Aliases to Manage Your Code................................................... 516

The SET PROCEDURE Command....................................................................................516

Debugging Your Programs.............................................................................. 517


Testing Methods, Fixing Program Errors......................................................... 518

Compiling the Code............................................................................................................518


Visual Review.....................................................................................................................518
Running Portions of the Application....................................................................................518
Observing Others Running the Application.........................................................................518
xv

Table of Contents

Using Code to Trap Errors..................................................................................................519

Shortcuts......................................................................................................... 521
Built-In Functions and Other Commands........................................................ 522

Chapter 21 - dBASEs Non-Visual Objects................................ 523

Using Arrays.................................................................................................... 523

How Do I Define An Array?.................................................................................................525


Now You Have Defined The Array, How Do You Put Data In It?.........................................525
Deleting Data in An Array....................................................................................................526
Referencing/Displaying Data In An Array............................................................................529
Sorting The Contents of An Array.......................................................................................531
A Couple of dBL Functions That Are Very Useful When Working With Arrays....................522
Making an Array Larger.......................................................................................................533
The insert() Method.............................................................................................................535
Adding Default Values Into An Array fill().........................................................................536
Directory Listings dir() and dirExt()..................................................................................537
Storing the Records (or Certain Fields) in a Table Into an Array.........................................538
Copying An Array................................................................................................................539
Searching An Array.............................................................................................................540
The element() Method.........................................................................................................541
The subscript() Method.......................................................................................................541
Using Arrays With dBASE User Interface Objects..............................................................541
Array Size Limits.................................................................................................................544

Literal Arrays................................................................................................... 544


Associative Arrays........................................................................................... 544
The Timer Class.............................................................................................. 546
The File Class................................................................................................. 548

To Copy a File.....................................................................................................................548
Rename a File . ..................................................................................................................549
Deleting a File ....................................................................................................................549
See If a File Exists..............................................................................................................549
To Check Attributes of a File...............................................................................................549
Opening or Creating a File..................................................................................................550
Looping Through a File.......................................................................................................550
Reading From A File...........................................................................................................551
Writing To A File..................................................................................................................551

The Math Class............................................................................................... 555


The Date Class................................................................................................ 555

Date Math...........................................................................................................................556
International Issues.............................................................................................................557

The String Class.............................................................................................. 558

Methods That Operate on The String..................................................................................558


Methods That Wrap the String in HTML Tags.....................................................................562
Using the String Objects Methods......................................................................................562
Stacking Methods...............................................................................................................563
Strings and Nulls.................................................................................................................563
xvi

Table of Contents

Part VII - Working With the Outside World................................ 565


Chapter 22 - OLE and WSH......................................................... 567

Object Linking and Embedding (OLE)............................................................. 567

OLE2 Automation Support..................................................................................................567


Communicating with Excel..................................................................................................569
Some Fun The Sound API in Windows............................................................................571
Working with OLE Data and Fields.....................................................................................573

Windows Script Host (WSH)............................................................................ 577

Chapter 23 - The Windows API and DLLs................................. 581

Overview......................................................................................................... 581
The Right Documentation................................................................................ 581
Header Files.................................................................................................... 582
The EXTERN Statement................................................................................. 582

Typical EXTERN Statement . .............................................................................................583


Calling Convention..............................................................................................................583
Mapping Data Types...........................................................................................................584
Data Type Mapping.............................................................................................................585
Taking Advantage of Module Aliases..................................................................................586
Aliasing Function Names....................................................................................................587
Working with Win32 Character-Based Functions...............................................................588
Dealing with Character Data...............................................................................................589

Data Structures 101........................................................................................ 590

Using a Simple Data Structure............................................................................................590


Retrieving Data from a Structure........................................................................................592
Making Structures Easy with OOP......................................................................................593
More About Structures........................................................................................................597
When to EXTERN...............................................................................................................598
Placing Data in Structures..................................................................................................599

Part VIII - Putting An Application Together............................... 603


Chapter 24 - Some Application Design Concepts.................... 605

The Application Framework............................................................................. 605

_app Properties...................................................................................................................605
_app.Methods.....................................................................................................................608
The Application Framewindow............................................................................................608
The Application Framewindows Properties and Methods..................................................610

Creating an Application Object.........................................................................611


SDI vs. MDI Style Applications........................................................................ 619
Menus, Toolbars, Popup Menus Should You Use Them?............................ 620
Passing Parameters to An Application............................................................ 620

xvii

Table of Contents

Chapter 25 - Using the Project Explorer................................... 633

Starting a New Project..................................................................................... 623

Project.......................................................................................................................................624
File Details..........................................................................................................................625
Log......................................................................................................................................625
DEO....................................................................................................................................625
Inno.....................................................................................................................................625
Adding Files to The Project.................................................................................................625

Creating a Basic (Non-DEO) Application...................................................... 625

Getting Started....................................................................................................................626
Add Files.............................................................................................................................627
Start Program......................................................................................................................629
Finishing Touches...............................................................................................................629
Now What?.........................................................................................................................630
Compiling and Building the Application...............................................................................630
Running the Executable in the Same Folder as the Source...............................................631

Creating a DEO Application............................................................................. 631

DEO Folders.......................................................................................................................632
Selecting the DEO Folder For Each File.............................................................................634
The Applications INI File....................................................................................................635
Compile and Build The Application.....................................................................................636
DEO and NON-DEO?.........................................................................................................636

.INI Files.......................................................................................................... 637

Encrypted Tables................................................................................................................638
Start Your Application Without the Data Engine..................................................................639

ActiveX and DLL Controls............................................................................... 639

Manually Handling These In Your Own Code.....................................................................639

Network Deployment....................................................................................... 641


Other Ways to Build Your Executable.............................................................. 642
Running a dBASE PLUS Executable.............................................................. 642

Using an Alternate INI File..................................................................................................643

Chapter 26 - The .INI File............................................................ 645

What Exactly Is a .INI File?............................................................................. 645


How Do I Find Things in My .INI File?............................................................. 645
Examining PLUS.INI........................................................................................ 646
Custom BDE .CFG File................................................................................... 658
Encrypted Tables............................................................................................. 658
Items You Can Add.......................................................................................... 658
No Data Engine............................................................................................... 658
Reading/Modifying a .INI File In An Application............................................... 659

Chapter 27 - Preparing An Application For Deployment......... 661

Using Inno Setup Manually............................................................................. 661


xviii

Table of Contents

Some Basic Information.................................................................................. 662

Inno Constants....................................................................................................................662
Using Other Languages......................................................................................................663

Creating an Install........................................................................................... 663

The Types and Components Sections................................................................................665


The INI Section...................................................................................................................669
The Code Section...............................................................................................................670

Borland Database Engine Issues.................................................................... 672

Handling the Registry Settings............................................................................................672


Database Aliases................................................................................................................673
SQL Links Drivers...............................................................................................................673

Creating a CD Image....................................................................................... 673


Using Inno Setup Through the Project Explorer.............................................. 674
Contacting the Author of Inno Setup............................................................... 675
Manual Deployment What Files Are Needed?............................................. 675

Application Files (DEO vs. non-DEO).................................................................................675


Installing the dBASE PLUS Runtime With Your Application................................................676
BDE Files............................................................................................................................677

Windows Vista Issues...................................................................................... 678


Other Issues.................................................................................................... 678

Part IX - The Internet................................................................... 679


Chapter 28 - dBASE PLUS On The Web.................................... 681

What Is a Web Application?............................................................................. 681

Static Web Pages vs. Interactive dBL Applications.............................................................682

Automatically Generated Web Applications..................................................... 682

Using the Web Wizards......................................................................................................682


The Data Entry Web Wizard...............................................................................................683
The Query and Response Web Wizard..............................................................................689
The Publish Web Wizard....................................................................................................689

Using dQuerys One-Click Web Application.................................................... 689


Testing Using Apache...................................................................................... 690

The Configuration File.........................................................................................................690


Start Apache.......................................................................................................................692

Writing Your Own Web Applications................................................................ 692

The Appendices........................................................................... 695


Appendix 1 - Resources Available............................................. 697

Other dBASE Books........................................................................................ 700

Appendix 2 - A Brief History of dBASE..................................... 701

xix

Table of Contents

Appendix 3 - Colors, Images and Graphics in dBASE Applications......................................................................................... 705

Colors.............................................................................................................. 705

16-Bit/DOS Color Names....................................................................................................705


JavaScript Safe Palette Color Names..............................................................................705
Hexadecimal BGR Colors...................................................................................................705
Windows Named Colors.....................................................................................................706
User Defined Color Name...................................................................................................706

Working With DLL Files................................................................................... 706

Other Ways to Store Images...............................................................................................709

Graphics Issues for Icons and Buttons (Pushbuttons and Toolbuttons).......... 709

Icons...................................................................................................................................709
Images for Pushbuttons......................................................................................................710
Images for Toolbuttons........................................................................................................ 711

An Undocumented Feature............................................................................. 712

Appendix 4 - Borland Database Engine and Table Specifications......................................................................................... 713

Differences Between dBASE (DBF) Table Levels...............................................................719

Appendix 5 - Undocumented Features...................................... 727


Appendix 6 - ANSI Chart............................................................. 735
Appendix 7 - Windows Application Interface Design and Standards........................................................................................ 739
Appendix 8 - Glossary................................................................ 745
Index............................................................................................. 749

xx

Das könnte Ihnen auch gefallen