foxpro 2: the complete reference - dandelon.com · foxpro 2: the complete reference edward jones...
TRANSCRIPT
FoxPro 2:The Complete Reference
Edward Jones and David Nesbitt
Osborne McGraw-HillBerkeley New York St. Louis San Francisco
Auckland Bogota Hamburg London MadridMexico City Milan Montreal New Delhi Panama City
Paris Sao Paulo Singapore SydneyTokyo Toronto
Contents at a Glance
Part I Using FoxPro 11 Getting Started with FoxPro 32 The FoxPro User Interface 153 Creating and Adding Information to Databases 374 Sorting and Indexing a Database 635 Performing Queries 836 Creating Queries with RQBE 977 Reports 1138 Designing Labels 1379 Macros 149
10 The Relational Powers of FoxPro 15711 Creating Screens 17512 FoxPro Tools and the FoxPro Editor 20713 The Project Manager and FoxPro's Power Tools 233
Part II Programming in FoxPro 24914 The Basics of FoxPro Programming 25115 Using Memory Variables 26516 Process Control in a FoxPro Program 27917 Programming for Data Entry, Editing, and Reporting 29318 Programming with the FoxPro User Interface 31719 Advanced Topics 351
Part III Networking with FoxPro 36920 Using FoxPro on a Network 37121 Network Programming 383
Part IV Reference 39122 Command Reference 39323 Function Reference 64724 FoxPro System Memory Variables 74725 Optimizing FoxPro 763
Part V Appendixes 775A File Types Used by FoxPro 777B System Functions 779C dBASE Commands Not Supported by FoxPro 781D ASCII Codes 783
Contents
IUsing FoxPro
iI
Getting Started with FoxProSystem Requirements
Conventional-MemoryRequirements
Extended and ExpandedMemory
Installing FoxProBefore the InstallationInstallation ProcedureCreating a Batch File for
FoxProStarting FoxPro
FoxPro's Options and FeaturesLanguage EnhancementsMouse SupportRushmore TechnologySQL LanguageRelational Query By Example
The User InterfaceFoxPro's MenusThe Command WindowDialog Boxes
The Application DevelopmentTools
33
4
4445
677888899
101112
13
Project ManagerScreen BuilderMenu Builder
2
The FoxPro User InterfaceUsing the Mouse with FoxPro
Mouse TipsUsing the KeyboardThe FoxPro Menu System
Making Menu SelectionsCanceling a Menu Selection
Summary of Menu OptionsThe System MenuFile MenuEdit MenuDatabase MenuRecord MenuProgram MenuWindow Menu
Working with WindowsOpening a WindowAdjusting the SizeMoving a WindowHiding a WindowChanging WindowsThe Zoom OptionClosing a Window
Dialog BoxesCheck BoxesList Boxes
141414
1515161618191919202123242627293031313232333333343434
PushbuttonsRadio ButtonsPulldown Control
353536
Creating and AddingInformation to Databases 37
What Is a Database? 37Data Types 37
Creating a New Database 38The Database Structure
Dialog Box 40Correcting Mistakes 41Inserting, Moving, and
Deleting Fields 41The Structure Menu 42Saving the Database Structure 42
Adding Information to theDatabase 43
Adding Data to Memo Fields 45Using the Edit Mode 49The Browse Mode 49
The Browse Menu 51Splitting the Browse Window
and Using Edit 53Adjusting Field Sizes and
Positions 53Unlinked Partitions 54Displaying Multiple Databases
in Browse Mode 55Using the LIST and DISPLAY
Commands 55Searching Within a Field 57
Deleting and Recalling Recordsfrom the Database 57
Deleting Records 57Recalling a Deleted Record 59Using the SET DELETED
Command 60Deleting and Recalling
Multiple Records 60Modifying the Structure of a
Database 61Saving the Changes 62
Sorting 64Selecting a Sort Field 65Sorting on Multiple Fields 68Using Ascending and
Descending Sort OrdersTogether 70
Using the FOR Clause to SortSelected Records 71
Using the FOR Clause to SortSelected Fields 72
A Caveat 72Indexing 72
Indexing with the INDEXCommand 73
Indexing with the FoxProMenus 75
Selective Indexing with theFOR Clause 77
Indexing on Multiple Fields 78Indexing on Fields of
Different Types 79Opening Databases with
Index Files 80Using the SET INDEX and
SET ORDER Commands 81Using REINDEX 82Using CLOSE INDEX 82
Performing Queries 83The Anatomy of an Expression 83
Relational Operators 84Logical Operators 85Arithmetical Operators 86String Operators 86Functions 87
Performing Queries 88Locate 88The Continue Option 91The LOCATE FOR Command 91The Seek Option 92The SEEK Command 93The FIND Command 93Using the SET FILTER
Command to Select Subsetsof Data 94
Sorting and Indexing aDatabase 63
Creating Queries withRQBE 97
About Rushmore 97Using the RQBE Window 98
Choosing Databases for Usewith the Query 99
Choosing Fields for the QueryResults 100
Choosing an Order for theQuery Results 100
Grouping the Query Results 100Specifying the Output
Destination 101Sample RQBE Window Queries 101
Examining the SELECTCommand 102
Inserting and RemovingSelection Criteria 104
Using Logical Operators inQueries
The .AND. ConditionThe .OR. ConditionUsing Date Ranges in QueriesSpecifying the Sort Order for
Your ResultsCreating Queries Using
Selected FieldsChanging the Query OutputSaving and Reusing Queries
Reusing Saved Queries
/Reports
The Report Creation ProcessTypes of Reports
Quick ReportsA Sample Quick ReportCustomized Reports
Examining the Report LayoutWindow
Manipulating Objects in theReport Layout Window
The Report Menu OptionsPage LayoutPage PreviewData GroupingTitle/SummaryBoxField
104105106106
106
108109112112
113113113114117117
118
119120120121122124124125
Text 126Add and Remove Line 126Bring to Front and Send to
Back 126Center 127Quick Report 127
The Report Expression DialogBox , 127
Printing and Displaying Reports 130A Sample Custom Report 131
Producing Reports at theCommand Level 133
Commands for Margin Settingsand Manual Ejects 135
8Designing Labels 137
Creating Labels 137The Label Design Screen 138The Expression Builder 140Page Preview 141Saving a Custom Label Layout 142Saving the Label Form 142Printing Labels 142Tips for Printing Labels 145
An Example Label 145Modifying Existing Labels 148
Macros 149Third-Party Macro Facilities 149Assigning Macros to Keys 150Creating a Macro 150The Keyboard Macros Dialog
Box 152A Sample Macro 154Saving Macros 154Tips for Creating and Using
Macros 155Adding to Existing Macros 155
Inserting Literals and AddingPauses in Macros 156
Limitations of Macros 156
10The Relational Powers ofFoxPro 157
Understanding RelationalDatabases
Ways to Relate Databases inFoxPro
Creating the HOURS DatabaseQuerying from Two Databases
A Sample Relational QueryThe View Window
Setting Relations Through theView Window
Relating Files with SETRELATION
A Warning AboutRelationships and Indexes
Using View Files to StoreRelationships
Creating Relational ReportsAnalyzing Types of Relationships
1 i
Creating ScreensDifferences Between Versions of
FoxProThe FoxPro 2 Screen Painter
and Format FilesStarting the FoxPro Screen
PainterThe Screen Menu
Placing FieldsPlacing TextMoving and Deleting ObjectsPlacing BoxesPlacing PushbuttonsPlacing Radio ButtonsPlacing Check BoxesPlacing PopupsPlacing ListsFurther Control of Screen
ObjectsSaving Screens and Generating
Cnr\pbUUC
Using ScreensA Screen Painter ExampleCreating Entry Forms with
Fox ViewCommands Available in
Fox ViewUsing Forms View to Create a
Form
158
158159160162163
165
168
171
171172172
175
175
176
176176178180181181181183184185186
187
1 881OO
189190
191
192
193
Moving FieldsChanging Field LabelsAdding TextSaving Screen Format FilesLeaving Fox ViewUsing a Screen Format FileModifying a Screen FormDrawing BoxesChanging ColorsMore About Table ViewMoving Fields and Objects in
Table ViewA Note About Fox View and
DOS
1 f1Z
FoxPro Tools and theFoxPro Editor
Desk AccessoriesCalculatorCalendar/DiarySpecial CharactersASCII ChartCaptureFiler
The FoxPro EditorCreating a New FileOpening Existing FilesSaving and Closing FilesEntering TextCursor MovementSelecting TextCut, Copy, and PasteFind and ReplacePrinting FilesSetting PreferencesRedefining the Editor with
Macros
t n
13The Project Manager andFoxPro's Power Tools
The Menu BuilderThe Menu Design WindowAssigning Hot KeysResponding to Menu PadsCreating a Submenu
194194195196197197198198199199
204
205
207207207209211213214214220221222222223224224225226227228
230
233234234234235236
Creating Divider Lines inSubmenus
Saving the Completed MenuGenerating Menu Code
The Project ManagerA Note About Stand-Alone
ProgramsCreating a ProjectThe Project Menu OptionsCreating Applications
Building a Sample Project andApplication
236236236237
237238240242
243
IIProgramming in FoxPro
1 41 4
The Basics of FoxProProgramming
A Sample ProgramCreating Programs
Using the FoxPro EditorUsing Another Word
ProcessorCompiling Versus
InterpretingProgramming Concepts
ConstantsMemory VariablesExpressionsOperatorsFunctions
Some Commonly UsedCommands
SET TALKSKIPRETURN?, ??, @, and TEXT
1 K
251251254254
255
255256256257257258260
261261261262262
Creating and Naming MemoryVariables 266
Creating Character Variables 267Creating Numeric Variables 268Creating Date Variables 269Creating Logical Variables 270
Viewing the Contents of MemoryVariables 270
Releasing Variables fromMemory 271
Memory Variable Files 272Hiding and Showing Variables
with PRIVATE and PUBLIC 272Arrays 274Macro Substitution 277
16Process Control in a FoxProProgram 279
Sequential Processing with DO,RETURN, RUN, and CALL 279
Using RUN to Run OtherPrograms 282
LOAD and CALL 283Assembler Guidelines and a
Warning 284FoxPro's Conditionals: IF, ELSE,
and ENDIF 285The Immediate IF() Function 286
Evaluating Multiple Choices withDO CASE 287
Repetitive Processing with DOWHILE...ENDDO andSCAN...ENDSCAN 288
Using Memory Variables 265Types of Memory Variables 266
17Programming for DataEntry, Editing, andReporting 293
ACCEPT, INPUT, and WAIT 293ACCEPT 293INPUT 294WAIT 295
The @...SAY...GET Command 295Using Colors with
@...SAY...GET Commands 297
Using @...CLEAR toSelectively Clear Screens 298
Working with Memo Fields 299Using TEXT...ENDTEXT to
Display Messages 300Data Entry and Editing Under
Program Control 301Adding Data Under Program
Control 301Editing Records Under
Program Control 303Deleting Records Under
Program Control 305Using BROWSE for Data Entry
and Editing 306Producing Reports Under
Program Control 308LIST and DISPLAY 308Using Stored Reports and
Labels in Programs 309Writing Reports with Program
Code 312Sending Escape Codes to the
Printer 315
18Programming with theFoxPro User Interface 317
Building Effective Menus 317Bar Menus 318Popup Menus 319Pulldown Menus 319A Note About User
Friendliness... 319Implementing Popup Menus in
FoxPro 320Popups Using ©...PROMPT
and MENU TO 320Popups Using DEFINE
POPUP and ONSELECTION POPUP 321
Popups Using @...MENU andREAD MENU TO 322
Implementing Bar Menus inFoxPro 323
Bar Menus Using DEFINEMENU, DEFINE PAD, andACTIVATE MENU 323
Bar Menus Using©...PROMPT and MENUTO 325
Implementing Pulldown Menusin FoxPro 325
Implementing Pick Lists 328FoxPro and Windows 330
Defining the Window 331Activating and Using the
Window 332Deactivating the Window 333An Example of the Use of
Windows 334IN WINDOW 334
Drawing Boxes 336Using Colors in FoxPro 336
Color Pairs 337Color Schemes 339Color Sets 341
Remember the Users... 342Implementing Custom Help 345
19Advanced Topics 351
Debugging Applications 351SET ECHO and the Trace
Window 352SET STEP 353Using the Debug Window 354Setting Breakpoints in the
Trace or Debug Windows 354Handling Errors Within the
Application 355Using Low-Level File Functions 358INKEY() and READKEY() 363User-Defined Functions 365
IIINetworking with FoxPro
20Using FoxPro ona Network 371
FoxPro/LAN and CompatibleNetworks 371
About SHARE 372
File Server Installation 372Optimizing the FoxPro/LAN
Installation 373Workstation Installation 373Running FoxPro/LAN 374Exclusive Versus Shared Use 375Database Integrity 375Automatic Versus Manual
Locking 376Network,Commands and
Functions 376SET EXCLUSIVE 377The Locking Functions 378UNLOCK 379SET REPROCESS 379SET LOCK and SET
MULTILOCKS 379DISPLAY STATUS and LIST
STATUS 380SET PRINTER 380
General Network Hints 381
21Network Programming 383
Using the Locking FunctionsWithin Programs 384
When to Open Files Exclusively 385Error Handling for Networks 386Performing Automated Retries 388Testing for Networks 388File Deadlock and How to
Avoid It 389
IVReference
22Command Reference
Symbols and Conventions\ (or) \\? or ?????@@...BOX©...CLEAR TO©...EDIT
393393394394395396397398399
©...FILL TO©...GET to Make Check Boxes©...GET to Make Invisible
Buttons©...GET to Make List Boxes©...GET to Make Popups©...GET to Make Pushbuttons©...GET to Make Radio Buttons©...MENU©...PROMPT©...TOACCEPTACTIVATE MENUACTIVATE POPUPACTIVATE SCREENACTIVATE WINDOWAPPENDAPPEND FROMAPPEND FROM ARRAYAPPEND MEMOAVERAGEBROWSEBUILD APPBUILD PROJECTCALCULATECALLCANCELCHANGECLEARCLEAR ALLCLEAR FIELDSCLEAR GETSCLEAR MACROSCLEAR MEMORYCLEAR MENUSCLEAR POPUPSCLEAR PROGRAMCLEAR PROMPTCLEAR READCLEAR TYPEAHEADCLEAR WINDOWSCLOSECLOSE MEMOCOMPILECONTINUECOPYCOPY FILECOPY INDEXESCOPY MEMOCOPY STRUCTURE 1
400400
402404405407408410410411412413414415416418418419420421422425426426428429430431432432433434434435435436436436437437438438439439441442442443444
COPY STRUCTUREEXTENDED
COPY TAGCOPY TO ARRAYCOUNTCREATECREATE FROMCREATE LABELCREATE MENUCREATE PROJECTCREATE QUERYCREATE REPORTCREATE REPORT FROMCREATE SCREENCREATE VIEW [FROM
ENVIRONMENT]DEACTIVATE MENUDEACTIVATE POPUPDEACTIVATE WINDOWDECLAREDEFINE BARDEFINE BOXDEFINE MENUDEFINE PADDEFINE POPUPDEFINE WINDOWDELETEDELETE FILEDELETE TAGDIMENSIONDIRDISPLAYDISPLAY FILESDISPLAY MEMORYDISPLAY STATUSDISPLAY STRUCTUREDODO CASEDO WHILEEDITEJECTEJECT PAGEENDCASEENDDOENDIFENDPRINTJOBENDSCANENDTEXTERASEEXIT
444446446447447448448449450450451451452
452453454455456457459460461462463466468468469469471472473475475476477478479482482483483484484484485485485
EXPORTEXTERNALFILERFINDFLUSHFORFUNCTIONGATHER FROMGETEXPRGO or GOTOHELPHIDE MENUHIDE POPUPHIDE WINDOWIFIMPORTINDEXINPUTINSERTJOINKEYBOARDLABEL FORMLISTLIST FILESLIST MEMORYLIST STATUSLIST STRUCTURELOADLOCATELOOPMENUMENU TOMODIFY COMMAND/MODIFY
FILEMODIFY LABELMODIFY MEMOMODIFY MENUMODIFY PROJECTMODIFY QUERYMODIFY REPORTMODIFY SCREENMODIFY STRUCTUREMOVE POPUPMOVE WINDOWNOTE or * or &&ON BARON ERRORON ESCAPEON KEYON KEY =
486486487487489490491492493494496497497498499500501504504505507507508509510510510511512513513515
515516517518518519519520520521521522522522524525527
ON KEY LABELON PADON PAGEON READ ERRORON SELECTION BARON SELECTION MENUON SELECTION PADON SELECTION POPUPPACKPARAMETERSPLAY MACROPOP MENUPOP POPUPPRINTJOB/ENDPRINTJOBPRIVATEPROCEDUREPUBLICPUSH MENUPUSH POPUPQUITREADREAD MENURECALLREINDEXRELEASERENAMEREPLACEREPORT FORMRESTORERESTORE MACROSRESTORE SCREENRESTORE WINDOWRESUMERETRYRETURNRUNSAVESAVE MACROSSAVE SCREENSAVE WINDOWSCANSCATTER TOSCROLLSEEKSELECTSELECT - SQLSETSET ALTERNATESET ANSISET AUTOSAVE
528529531531532533533534535536537538538538539540542544544544545547548550551551552554555556556557558558559560561561562562563564565566566567567568569569
SET BELLSET BELL TOSET BLINKSET BLOCKSIZESET BORDERSET CARRYSET CENTURYSET CLEARSET CLOCKSET CLOCK TOSET COLOR OFSET COLOR OF SCHEMESET COLOR OF SCHEME TOSET COLOR ON/OFFSET COLOR SET TOSET COLOR TOSET COMPATIBLESET CONFIRMSET CONSOLESET CURRENCYSET CURRENCY LEFT/RIGHTSET DATESET DECIMALSSET DEFAULTSET DELETEDSET DELIMITERSET DEVELOPMENTSET DEVICESET DISPLAY TOSET DOHISTORYSET ECHOSET ESCAPESET EXACTSET FIELDSSET FIELDS TOSET FILTERSET FIXEDSET FORMATSET FULLPATHSET FUNCTIONSET HEADINGSET HELPSET HELPFILTERSET HOURSSET INDEXSET INTENSITYSET LIBRARYSETLOGERRORSSET MARGINSET MARK
569570570571571572573574574575575577578579579580581581582583583583585586586588588589590591591592592593593594595596597597598599599600600602602603603604
SET MARK OF 605SET MEMOWIDTH 605SET MESSAGE 607SET MOUSE 607SET NEAR 608SET ODOMETER 609SET OPTIMIZE 609SET ORDER 609SET PATH 611SET POINT 612SET PRINT 612SET PRINTER TO 613SET PROCEDURE 613SET RELATION 616SET RELATION OFF 618SET RESOURCE 618SET RESOURCE TO 618SET SAFETY 619SET SEPARATOR 619SET SHADOWS 619SET SKIP 620SET SPACE 620SET STATUS 621SET STEP 621SET STICKY 621SET SYSMENU 622SET TALK 622SET TEXTMERGE 622SET TEXTMERGE
DELIMITERS 623SET TOPIC 623SET TYPEAHEAD 623SET UDFPARMS 624SET UNIQUE 624SET VIEW 626SET VIEW TO 626SET WINDOW OF MEMO 627SHOW GET 628SHOW GETS 629SHOW MENU 629SHOW OBJECT 629SHOW POPUP 630SHOW WINDOW 630SIZE POPUP 631SKIP 631SORT 632STORE 634SUM 636SUSPEND 637TEXT 637
TOTALTYPEUPDATEUSEWAITZAPZOOM WINDOW
638640640642643644645
23Function Reference
Reference Symbols andConventions
ABSACOPYACOSADELADIRAELEMENTAFIELDSAINSALENALIASALLTRIMASCASCANASINASORTASUBSCRIPTATATANATCATCLINEATLINEATN2BARBETWEENBOFCAPSLOCKCDOWCDXCEILINGCHRCHRSAWCHRTRANCMONTHCNTBARCNTPADCOLCOSCTOD
647
647648648649649650650650651651652652653653654654655655656656657657658658659659660660661661662662663663663664664664665
CURDIRDATEDAYDBFDELETEDDIFFERENCEDISKSPACEDMYDOWDTOCDTORDTOSEMPTYEOFERROREVALUATEEXPFCLOSEFCOUNTFCREATEFEOFFERRORFFLUSHFGETSFIELDFILEFILTERFKLABELFKMAXFLOORFOPENFOUNDFPUTSFREADFSEEKFSIZEFULLPATHFVFWRITEGETBARGETENVGETFILEGETPADGOMONTHHEADERIIFINKEYINLISTINSMODEINT
666666667667668668669670670671672672673673674674674675675676677677678678679679680680680681681682683683683684684685685686686687687687688688688689689690
ISALPHAISCOLORISDIGITISLOWERISUPPERKEYLASTKEYLEFTLENLIKELINENOLOCFILELOGLOG10LOWERLTRIMLUPDATEMAXMCOL()MDOWN()MDX()MDYMEMLINESMEMORYMENUMESSAGEMINMLINEMODMONTHMRKBARMRKPADMROW()NDX()NUMLOCKOBJNUMOCCURSORDEROSPADPADC, PADL, PADRPARAMETERSPAYMENTPCOLPIPOPUPPRINTSTATUSPRMBARPRMPADPROGRAM
690691691692692693693694694695695695696696697697698699699700700701701702702703703704705705706706706707708708708709709710710711711712712713713713714714
PROMPTPROPERPROWPUTFILEPVRANDRATRATLINERDLEVELREADKEYRECCOUNTRECNORECSIZERELATIONREPLICATERIGHTROUNDROWRTODRTRIMSCHEMESCOLSSECONDSSEEKSELECTSETSIGNSINSOUNDEXSPACESQRTSROWSSTRSTRTRANSTUFFSUBSTRSYSTAGTANTARGETTIMETRANSFORMTRIMTYPEUPDATEDUPPERUSEDVALVARREAD
714715715715716716717718718718719719720721721722723723724724725725725726726726727728728729729730730731731732733733734734735735736737737738739739740
VERSIONWCHILDWCOLSWEXISTWLCOLWLROWWONTOPWOUTPUTWPARENTWROWSWVISIBLEYEAR
tA.
FoxPro System MemoryVariables
_ALIGNMENT_BOX_CALCMEM_CALCVALUE_CLIPTEXT_CUROBJ_DBCLICK_DIARYDATE_ INDENT_LMARGIN_MLINE_PADVANCE_PAGENO_PBPAGE_PCOLNO_PCOPIES_PDRIVER_PECODE_PEJECT_PEPAGE_PFORM_PLENGTH_PLINENO_PLOFFSET_PPITCH_PQUALITY.PRETEXT_PSCODE_PSPACING_PWAIT_RMARGIN
TABS
741741742742743743744744744745745746
747749749750750750751751751752752752753753753754754754755755755756756756757757757758758758759759759
_ TALLY 760_TEXT 760_WRAP 760Using System Memory Variables
and Other Parameters 761
25Optimizing FoxPro 763
Modifying the CONFIG. FP File 763Valid Options for CONFIG.FP 764Using SET Commands in
Applications 767FoxPro's Printer Drivers 768
Choosing a Printer Driver 768Changing or Deleting an
Existing Printer Setup 769Specifying the Default Printer
Driver Setup 769Loading a Printer Driver Setup 770FoxPro and Memory 770
Types of PC Memory 770A Note About Conventional
RAM 771A Note for Users of Microsoft
Windows 771
Modifying the FoxPro ResourceFile 772
Finally, a Note About Hardware 773
VAppendixes
File Types Used byFoxPro 777
BSystem Functions 779
dBASE Commands NotSupported by FoxPro 781
DASCII Codes 783