Top Banner
Discovering Training Guide Copyright 2004 Data Access Corporation DATA ACCESS WORLDWIDE 14000 S.W. 119 Avenue Miami, Florida 33186 USA Revision Date: January 8, 2004 * This manual applies to Visual DataFlex Revision 9.1 Part No.: 917900 .
550
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Discovering Visual DataFlex 9.1

Discovering

Training Guide

Copyright 2004 Data Access Corporation

DATA ACCESS WORLDWIDE

14000 S.W. 119 Avenue

Miami, Florida 33186

USA

Revision Date: January 8, 2004

* This manual applies to Visual DataFlex Revision 9.1

Part No.: 917900

.

Page 2: Discovering Visual DataFlex 9.1

COPYRIGHT NOTICE

Copyright 2004 DATA ACCESS CORPORATION. All rights reserved.

No part of this publication may be reproduced, or distributed, transmitted, transcribed,stored in a retrieval system, or translated into any human or computer language, in anyform or by any means, electronic, mechanical, magnetic, optical, manual, or otherwise,or disclosed to third parties without the express written permission of Data AccessCorporation, 14000 SW 119 Avenue, Miami, Florida, 33186, USA.

DISCLAIMER

Data Access Corporation makes no representation or warranties, expressed or implied,with respect to the software or this publication, or any Data Access Corporation product,including but not limited to warranties of merchantability or fitness for any particularpurpose.

Data Access Corporation reserves to itself the right to make changes, enhancements,revisions and alterations of any kind to this manual and / or its accompanying softwarewithout obligation to notify any person, institution, or organization of such changes,enhancements, revisions, and alterations.

TRADEMARKS

DataFlex is a registered trademark of Data Access Corporation.

Crystal Reports is a registered trademark of Seagate Corporation

Microsoft Windows is a registered trademark of Microsoft.

Multi-Edit is a registered trademark of American Cybernetics

All other brand and product names are trademarks or registered trademarks of theirrespective companies.

Page 3: Discovering Visual DataFlex 9.1

More Information on Object Oriented Programming &Visual DataFlex

The most current data is posted on our web site. Visit us on the Internet athttp://www.dataaccess.com/. Free product upgrades, white papers and even access to thenewsgroups are accessible via our web site.

The newsgroup has a wealth of information to support all of our products. Additionally,it is a meeting place for the Data Access community. Users—ranging in experience fromfirst time computer users to experienced MIS professionals—share ideas and help eachother. This is an invaluable aid during the learning process and will serve as an excellentresource during projects.

The newsgroup contains code examples, questions, and answer, etc. from Data AccessCorporation and other users. By frequenting the newsgroup, you can learn the languagefaster and more efficiently. Additionally, once you're confident in your knowledge, youcan assist other new users in learning the product as well.

Page 4: Discovering Visual DataFlex 9.1
Page 5: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Table of Contents

Data Access Corporation 5

Table of Contents

Introduction ..................................................................................................................... 19How to Use the Manual .........................................................................................................20

Classroom Environment: .......................................................................................................20

Self Taught Method: ..............................................................................................................20

Reading List To Excel Quickly..............................................................................................21

Lesson 1............................................................................................................................ 23

Getting Ready ............................................................................................................. 23Requirements .........................................................................................................................24

How Items Will Be Displayed ...............................................................................................25

Naming Conventions .............................................................................................................27

Lesson 1 Lab ............................................................................................................... 28Did You Discover? ................................................................................................................29

Lesson 2............................................................................................................................ 31

Creating Workspaces & Database Files................................................................... 31Application Building Outline Used by the Labs ....................................................................32

Outline of Project Database Tables .......................................................................................33

Definition Files - .DEF Files..................................................................................................34

Workspace Subdirectories .....................................................................................................40

Starting the Studio .................................................................................................................45

Creating Workspaces .............................................................................................................46

Workspace Pathing ................................................................................................................50

The Goal ................................................................................................................................51

Database Builder Utility ........................................................................................................54

Page 6: Discovering Visual DataFlex 9.1

Table of Contents Discovering Visual DataFlex

6 Data Access Corporation

Database Builder’s Lock........................................................................................................55

Using Context Sensitive Help ................................................................................................56

The Fields Tab.......................................................................................................................57

Good File Relationships are the Key! ....................................................................................57

The Index Tab........................................................................................................................58

The Parameters Tab ...............................................................................................................59

Lesson 2 Lab ............................................................................................................... 60Database Builder—Building Database Tables.......................................................................63

Copy Test Data ......................................................................................................................63

Creating a Database Table from Scratch................................................................................64

Adding Database File Names Directly into Filelist................................................................66

Use a .DEF File to Create a Database Table..........................................................................68

Did You Discover? ................................................................................................................73

Lesson 3............................................................................................................................ 77

Building Views & Components ................................................................................. 77Selection Lists........................................................................................................................78

Creating New Application .....................................................................................................80

Button Bar .............................................................................................................................88

Tools Pull-Down....................................................................................................................89

Database Selector Tool..........................................................................................................90

DDO Tree Button ..................................................................................................................91

Which Related Field? ............................................................................................................93

Object Properties Tool...........................................................................................................94

Setting Object Properties .......................................................................................................95

Controls Palette Tool .............................................................................................................97

Selecting Tab pages & Tabdialogs ........................................................................................98

Base Tab page........................................................................................................................99

Data Tab page......................................................................................................................100

Using the Data Tab page......................................................................................................101

Page 7: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Table of Contents

Data Access Corporation 7

Base Containers Tab page ...................................................................................................102

Data Containers Tab-page ...................................................................................................103

Non-Visible Tab page..........................................................................................................104

Object Placement Tools.......................................................................................................106

Alignment Palette Tool........................................................................................................107

Popup Menus .......................................................................................................................108

Arrange Objects Tool ..........................................................................................................109

Nudge Objects Tool.............................................................................................................110

Resolution Check Tool ........................................................................................................111

Object-Order Definition Tool ..............................................................................................112

Drag Lock............................................................................................................................113

Lost Objects in the Studio (recovering objects not visible on screen) .................................115

Cutting & Pasting Objects to Different Containers..............................................................116

Anchors & Min/Max Size....................................................................................................118

Lesson 3 Lab ............................................................................................................. 121Creating Selection Lists .......................................................................................................121

Attaching Selection Lists in the DataDictionary..................................................................126

Using Application Wizard ...................................................................................................129

Creating the Empl View – Without Wizards .......................................................................135

Attaching a New View to the Application ...........................................................................142

Compiling Code & Testing..................................................................................................143

Adding Pictures to Records .................................................................................................144

Did You Discover? ..............................................................................................................145

Lesson 4.......................................................................................................................... 147

Generated Code ........................................................................................................ 147Editor’s Full Source Mode...................................................................................................148

The Big Picture....................................................................................................................149

Activating Views .................................................................................................................153

Creating Templates..............................................................................................................154

Page 8: Discovering Visual DataFlex 9.1

Table of Contents Discovering Visual DataFlex

8 Data Access Corporation

Manual Code That the Studio Can Read..............................................................................155

1. Manual Code in the .SRC file (via the Studio) ................................................................155

2. Manual Code in Visual Objects (via the Studio) .............................................................156

3. Manual Code in the DataDictionary Objects (via the Studio)..........................................157

Lesson 4 Lab ............................................................................................................. 159Creating an Invoice Style View Template ...........................................................................160

Adding Manual Code to Objects .........................................................................................162

Creating Dept/Empl View – Using View Templates ...........................................................172

Grid Options ........................................................................................................................175

Changing Navigation ...........................................................................................................176

Did You Discover? ..............................................................................................................179

Lesson 5.......................................................................................................................... 181

Data Dictionarys Part 1 ........................................................................................... 181DataDictionary Classes – the .DD File ................................................................................182

Business Rules .....................................................................................................................183

DataDictionary Class & DataDictionary Object Differences...............................................184

Building DataDictionarys for Database Files ......................................................................185

Field Settings .......................................................................................................................186

Field Options .......................................................................................................................186

Field Validation ...................................................................................................................188

Modal Objects are Popups...................................................................................................189

Using Validation Tables ......................................................................................................190

Field Masking ......................................................................................................................199

Appearance Tab...................................................................................................................203

Other Tab page ....................................................................................................................205

Checkbox Option.................................................................................................................205

Status Help...........................................................................................................................206

Simple Default Value...........................................................................................................207

Entry/Exit/Validation Messages ..........................................................................................208

Page 9: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Table of Contents

Data Access Corporation 9

Entry & Exit Messages ........................................................................................................209

Auto-Assigning Numbers.....................................................................................................212

External Structure ................................................................................................................213

Lesson 5 Lab ............................................................................................................. 214Building DataDictionarys for All Database Files ................................................................214

Setting Field Options ...........................................................................................................215

Setting Field Validation.......................................................................................................216

Validation Tables.................................................................................................................217

Setting Field Masking..........................................................................................................220

Setting Appearance Tab.......................................................................................................221

Setting Status Help ..............................................................................................................222

Field_Default_Value Property.............................................................................................223

Auto-Assigning Numbers.....................................................................................................224

Changing an Object’s Class .................................................................................................225

Did You Discover? ..............................................................................................................226

Lesson 6.......................................................................................................................... 227

Data Dictionarys Part 2 ........................................................................................... 227Methods Tab........................................................................................................................228

Options Tab .........................................................................................................................229

Foreign Field Options ..........................................................................................................229

Error Handling.....................................................................................................................229

Structures Tab......................................................................................................................230

Cascade Delete ....................................................................................................................231

Database Explorer................................................................................................................232

Lesson 6 Lab ............................................................................................................. 233Methods Tab........................................................................................................................233

Structures Tab......................................................................................................................236

Initializing Auto-Assign Number.........................................................................................237

Did You Discover? ..............................................................................................................238

Page 10: Discovering Visual DataFlex 9.1

Table of Contents Discovering Visual DataFlex

10 Data Access Corporation

Lesson 7.......................................................................................................................... 239

Connecting Parts ...................................................................................................... 239Differences between the DD Class Files and DDOs............................................................240

Connecting DDs to DDs within the DataDictionary Class...................................................243

Connecting DDOs to DDOs within the View ......................................................................245

Connecting DEOs to DDOs within the View.......................................................................248

Object Nesting .....................................................................................................................250

Encapsulation of DDO Structures........................................................................................251

Lesson 7 Lab ............................................................................................................. 252Completing the DDO Structure of Our Views .....................................................................252

Did You Discover? ..............................................................................................................253

Lesson 8.......................................................................................................................... 255

Constraints................................................................................................................ 255Constraining Records...........................................................................................................256

Constrain_File Property.......................................................................................................256

OnConstrain Procedure........................................................................................................260

Lesson 8 Lab ............................................................................................................. 262Building Constraints in Selection Lists................................................................................263

Building Constraints that Change ........................................................................................264

Did You Discover? ..............................................................................................................265

Lesson 9.......................................................................................................................... 267

All about Messages................................................................................................... 267The Link Between Messages and Procedures/Functions .....................................................268

Triggering Messages (Event Driven) ...................................................................................269

Focus Object & Self.............................................................................................................270

Sending a Message ..............................................................................................................271

Access Methods ...................................................................................................................272

Forwarding & Delegating (location of methods) .................................................................273

Page 11: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Table of Contents

Data Access Corporation 11

Self Access Method Works by Delegation ..........................................................................275

Relaying a Message (Breaking Encapsulation – sort of…)..................................................276

Neighborhoods.....................................................................................................................278

Broadcast Command............................................................................................................280

Delegate Send ......................................................................................................................281

Using Online Documentation – Commands.........................................................................282

Changing Behavior of Existing Messages ...........................................................................283

Augmenting a Message........................................................................................................283

Canceling a Message ...........................................................................................................284

Overriding a Message ..........................................................................................................284

Adding (creating) a Message ...............................................................................................284

Using Online Documentation – Procedures.........................................................................285

Using Online Documentation – Class Hierarchy .................................................................286

Local Variables....................................................................................................................287

On_Key Commands.............................................................................................................288

Properties (creating) ............................................................................................................289

Properties (Set & Get Commands) ......................................................................................290

Object Properties .................................................................................................................290

Item Properties.....................................................................................................................291

Procedures ...........................................................................................................................292

Functions .............................................................................................................................293

Functions as Expressions .....................................................................................................294

Categories of Messages .......................................................................................................295

Delegation & the Importance of Container Objects.............................................................296

“On” Procedures (Events)....................................................................................................298

Using OnClick Event ...........................................................................................................299

Using OnActivateApp Event ...............................................................................................299

Using OnMaxText Event .....................................................................................................299

Creating Buttons ..................................................................................................................300

Creating Checkboxes & Radios ...........................................................................................301

Page 12: Discovering Visual DataFlex 9.1

Table of Contents Discovering Visual DataFlex

12 Data Access Corporation

Lesson 9 Lab ............................................................................................................. 303Checking the Servers: ..........................................................................................................305

Properties – (the global variables) .......................................................................................307

Highlighting a Grid Row .....................................................................................................315

Did You Discover? ..............................................................................................................318

Lesson 10........................................................................................................................ 321

Items & Predefined Classes..................................................................................... 321Items - Zero-Based ..............................................................................................................322

Referencing Items Outside the Current Object ....................................................................323

Grid - Column Properties.....................................................................................................324

Lesson 10 Lab ........................................................................................................... 325Creating Timers ...................................................................................................................325

Did You Discover? ..............................................................................................................332

Lesson 11........................................................................................................................ 335

Troubleshooting........................................................................................................ 335Studio Databases..................................................................................................................336

Troubleshooting Hints .........................................................................................................337

1. Compile Each View Separately..................................................................................338

2. Checking File Relationships.......................................................................................339

3. Checking for Unique Index on the Parent Related Field ............................................342

4. Rebuilding the DDO Tree Within the View...............................................................343

5. Checking the Data ......................................................................................................345

6. Debugging Compiler Errors & using a .PRN file.......................................................346

7. Create a Small Test Program......................................................................................349

8. The Debugger – Runtime problems: ...............................................................................350

Lesson 11 Lab ........................................................................................................... 352Debugger Breakpoints .........................................................................................................352

Debugger Watches...............................................................................................................353

Did You Discover? ..............................................................................................................354

Page 13: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Table of Contents

Data Access Corporation 13

Lesson 12........................................................................................................................ 355

Waves and Bitmaps.................................................................................................. 355Displaying Bitmaps from a Database File............................................................................356

Displaying Bitmaps as a Backdrop ......................................................................................357

Wave Files - Applications with Sound.................................................................................359

Creating a Wave File ...........................................................................................................360

Embedded Bitmaps..............................................................................................................361

Lesson 12 Lab ........................................................................................................... 363Did You Discover? ..............................................................................................................364

Lesson 13........................................................................................................................ 365

DD’s Local Buffers & Procedures .......................................................................... 365Changing Field Values - DataDictionary’s Local Buffers ...................................................366

Optimizing Field_Exit_Msg ................................................................................................368

Important DataDictionary Procedures .................................................................................373

Procedure Creating ..............................................................................................................374

Procedure Update & Backout ..............................................................................................375

Functions Validate_Save & Validate_Delete.......................................................................376

Procedures Save_Main_File & Delete_Main_File ..............................................................377

Lesson 13 Lab ........................................................................................................... 378

Lesson 14........................................................................................................................ 385

Classes Within the Studio........................................................................................ 385Building New Subclasses.....................................................................................................386

Switching Classes the Studio Uses ......................................................................................388

Creating SubClass Layering.................................................................................................389

Templates (Speeding Development)....................................................................................392

DFS files ..............................................................................................................................393

Saving a DFS: ......................................................................................................................394

Inserting a DFS....................................................................................................................395

Page 14: Discovering Visual DataFlex 9.1

Table of Contents Discovering Visual DataFlex

14 Data Access Corporation

DFO Files ............................................................................................................................396

Using Subclasses in the Studio ............................................................................................399

Local & Global directories ..................................................................................................401

Lesson 14 Lab ........................................................................................................... 402Steps to Add a New Class to the Controls Palette ...............................................................402

Did You Discover? ..............................................................................................................407

Lesson 15........................................................................................................................ 409

Batch Processing....................................................................................................... 409Business Process Objects (BPO) .........................................................................................410

Batch Process using DDOs..................................................................................................412

Lesson 15 Lab ........................................................................................................... 414BPO to Update Company Fields in Dept Records ...............................................................414

BPO to Log Employees Out at End of Day .........................................................................417

Did You Discover?.................................................................................................... 421

Lesson 16........................................................................................................................ 423

Reporting................................................................................................................... 423Comparing the Reporting Methods......................................................................................424

BasicReport Class................................................................................................................424

WinReport (WinPrint) .........................................................................................................424

CrystalReport Class .............................................................................................................424

Lesson 16 Lab ........................................................................................................... 425Using WinPrint Report Wizard............................................................................................425

Using Crystal Report Wizard...............................................................................................432

Adding a Print Button to an Entry View..............................................................................438

Did You Discover? ..............................................................................................................444

Appendix A..................................................................................................................... 445

“Did you Discover” Answers................................................................................... 445Lesson 1 - Discover Answers...............................................................................................446

Page 15: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Table of Contents

Data Access Corporation 15

Lesson 2 - Discover Answers...............................................................................................447

Lesson 3 - Discover Answers...............................................................................................449

Lesson 4 - Discover Answers...............................................................................................452

Lesson 5 - Discover Answers...............................................................................................454

Lesson 6 - Discover Answers...............................................................................................455

Lesson 7 - Discover Answers...............................................................................................456

Lesson 8 - Discover Answers...............................................................................................457

Lesson 9 - Discover Answers...............................................................................................459

Lesson 10 - Discover Answers.............................................................................................463

Lesson 11 - Discover Answers.............................................................................................464

Lesson 12 - Discover Answers.............................................................................................465

Lesson 13 - Discover Answers.............................................................................................466

Lesson 14 - Discover Answers.............................................................................................468

Lesson 15 - Discover Answers.............................................................................................471

Lesson 16 - Discover Answers.............................................................................................472

Appendix B..................................................................................................................... 473

Problems & Solutions .............................................................................................. 473Popup Messages/Questions..................................................................................................474

On_Key {to object} parameter ...........................................................................................475

Auto Activate First View.....................................................................................................476

ToolTip................................................................................................................................477

Multiple directories in a Path...............................................................................................478

Checking filename is only 15 Characters.............................................................................479

Procedure Set.......................................................................................................................480

Retrieving data from the Windows Registry........................................................................481

Deployment..........................................................................................................................482

Saving Resources:................................................................................................................483

Customizing error messages: ...............................................................................................484

Adding your own Utilities....................................................................................................485

Page 16: Discovering Visual DataFlex 9.1

Table of Contents Discovering Visual DataFlex

16 Data Access Corporation

Maintain Class-Lists ............................................................................................................486

Field_Default_Value Property.............................................................................................487

Appendix C..................................................................................................................... 489

Core Information ..................................................................................................... 489Accelerator Keys .................................................................................................................490

Studio Hot Keys...................................................................................................................492

Visual DataFlex Core Information......................................................................... 495The Main Utilities................................................................................................................496

File Relationships ................................................................................................................497

Some Sample Relationships.................................................................................................498

Data Integrity.......................................................................................................................500

What Happens During a Save to Keep the Related Fields the Same?..................................501

File Normalization ...............................................................................................................502

DataFlex File Extensions .....................................................................................................503

Maintenance of Files............................................................................................................504

OOP Core Information............................................................................................ 506Definition of Classes and Objects:.......................................................................................507

Procedures & Local Variables .............................................................................................510

Multiple DataDictionary Objects (DDOs) ...........................................................................512

Encapsulation.......................................................................................................................514

Message Forwarding............................................................................................................516

Event Driven........................................................................................................................518

Building New Classes:.........................................................................................................519

The UIMS............................................................................................................................520

Summary..............................................................................................................................522

Prior DataFlex Users ...........................................................................................................523

Prior DataFlex Procedural Users .........................................................................................523

Prior DataFlex Character-Based OOP Users .......................................................................523

Everyone New to VDF8 ......................................................................................................523

Page 17: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Table of Contents

Data Access Corporation 17

Glossary.......................................................................................................................... 525

Evaluation ...................................................................................................................... 549

Page 18: Discovering Visual DataFlex 9.1

Table of Contents Discovering Visual DataFlex

18 Data Access Corporation

Page 19: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Introduction

Data Access Corporation 19

IntroductionDiscovering Visual DataFlex is a training guide designed to introduce users to VisualDataFlex object-oriented Windows programming. The manual was written for VisualDataFlex to be used in a classroom environment or as a Self-taught study guide. VisualDataFlex revision 9.1 will be required when using this manual since the packagesand features of this revision are used.

Some familiarity with DOS, Microsoft Windows and general computer skills isnecessary to accomplish the labs.

The manual covers items ranging from beginning to advanced level skills. Students withprior object oriented and or DataFlex programming experience may wish to jump oversections. Review the topics covered in a Lesson to determine if you wish to skip alesson. If you do skip Lessons, the Lab sections normally will have to be completedsince each Lab builds on prior work.

Page 20: Discovering Visual DataFlex 9.1

Introduction Discovering Visual DataFlex

20 Data Access Corporation

How to Use the ManualThe manual covers topics that will be helpful to a broad range of reader experiences.Some of the topics will be simple and some more advanced. If you fall into any of thefollowing categories, you may find it helpful to read the appropriate “Core Information”sections in Appendix C before continuing.

• New DataFlex Users Appendix C “DataFlex Core Information”

• Procedural Programmers Appendix C “OOP Core Information”

• DOS Object Oriented Programmers Appendix C “OOP Core Information”

• Prior VDF Users Appendix C “Prior VDF Users”

Classroom Environment:A hands-on classroom is the recommended setting for using this manual. The Self-studymethod is possible, but classroom interaction and the aid of an instructor will enhancethe learning process. If you are interested in locating a class near you, please call one ofour Training Centers. Visit our Web site for contact information.

Self Taught Method:This manual can also be used as a Self-study guide. Before beginning, check the nextfew pages to ensure you have all needed equipment/software.

The manual is broken up into Lessons, Labs and “Did You Discover?” questions. The“Did You Discover?” sections are NOT quizzes! Some of the topics are not evencovered in the lesson. They are intended as extra information and to challenge thestudents. Do not use them as a test of your knowledge, but as an additional learning toolto cover more information. You will find the answers to these questions in Appendix A.

Included on the training CD that comes with the training manual is aFinishedExampleZip.Exe file. This Self-extracting zip file contains all the files createdthroughout the course of the manual, as they will appear at the end of the manual. If youhave any problems, unzip this file into a separate directory so you may compare yourfiles to them.

Page 21: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Introduction

Data Access Corporation 21

Reading List To Excel QuicklyA well thought-out training plan must be implemented. This plan should include all ofthe DataFlex documentation. The documentation is full of fabulous examples. No matterif you attend a class or use this manual as a Self-study guide, this recommended studylist would speed you along to success.

• Before attending class:

Review Appendix C sections appropriate for your experience level

Read entire Visual DataFlex Quick Start manual

Run all Example Applications. This will demonstrate the look and feelfor the many window controls available. The examples are availableby clicking Start | Programs | Visual DataFlex | Sample Applications.

• After class:

Review this training manual

Read entire Visual DataFlex Developing Applications manual

Read entire Language Guide in the on-line help

Experiment with the code from the Example Applications. Whenchanging the Workspace in the Studio you will see all the exampleworkspaces. The manual code additions in these samples are full ofuseful ideas. These examples are also great areas to test and learnnew features. If you would like to experiment with a new propertysimply test it out in one of the examples.

Page 22: Discovering Visual DataFlex 9.1

Introduction Discovering Visual DataFlex

22 Data Access Corporation

More books to read:

Book Title Ask your Bookstore for this ISBN numberThe Windows Guidelines forsoftware design

1-55615-679-0

Visual Interface Design 0-471-13419-8Windows 32 API Bible 1-57169-009-3XML in 24 Hours 0672319500MSDN (internet) http://msdn.microsoft.com

Page 23: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 1 Getting Ready

Data Access Corporation 23

Lesson 1Getting Ready

This lesson ensures that we have the required equipment and software. The setup CDthat comes with this manual has all the needed files that are used throughout the manual

Topics in this Chapter:

♦ Requirements

♦ How Items will be Displayed

♦ Naming Conventions

♦ Lab1

Page 24: Discovering Visual DataFlex 9.1

Lesson 1 Getting Ready Discovering Visual DataFlex

24 Data Access Corporation

Requirements• Computer

• Intel Pentium based PC or higher

• Computer mouse installed

• 32 Meg RAM (64 MB NT; 2000; XP;2003) bare minimum

• Microsoft Windows 98 SE; ME; NT4;2000, XP, 2003

• Visual DataFlex revision 9 .1 withDocumentation installed. (200 MBHard Disk space required for fullinstallation)

• Crystal Reports & DataFlex for CrystalDriver (this is optional – if you do nothave these products you may skip thissection in the reporting lesson)

• SVGA 800x600 or higher resolution

Note: The Workspace Wizard uses the”Projects folder” as the default location for newworkspaces. This manual will use this projects directory, but it is suggested that you changethis location and point it to an area where you wish all your development work to be done.

* New service packs (when available) can be downloaded from http://www.dataaccess.com/web page from the Download pull-down area.

Figure 1

Page 25: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 1 Getting Ready

Data Access Corporation 25

How Items Will Be Displayed• Instructions/Commands

• Symbols: Many look very similar—attention to detail is necessary!

Symbol Description

] Click the right mouse button.

[ Click the left mouse button.

/ Double click the left mouse button.

E Press the Escape Key.

R Press the Enter Key (Return Key)

C Control Key

S Press the Shift Key

T Press the Tab Key

u Press the Page Up Key

d Press the Page Down Key

; Left Dragging: Hold left mouse key down while moving themouse to a new location and then releasing.

Instructions requiring action will be displayedwith a bold top & bottom line. Completion ofthese instructions is required for the sampleprogram to operate.

Sometimes symbols are used.

Example: [ = Click left mouse button

File | OptionsMeans select “File” from the menu bar andthen select “Options” from the pull down.

Page 26: Discovering Visual DataFlex 9.1

Lesson 1 Getting Ready Discovering Visual DataFlex

26 Data Access Corporation

• Informative Text:

Informative data will be displayed in this font and will be used to explain topics. Do notconfuse informative text with instructions/commands. Text in this printing style is usedto explain topics. Even if screen shots are included – no action is required on yourcomputer.

• Code:

The lab exercises will be making many modifications to the generated code. A filecalled Code_Mod.TXT is available on the CD that accompanies this manual. Whenasked to make code modifications, open this file in your editor and cut and paste themodifications into the application.

Code Available = Code_Mod.TXT

Object Outer_container is a dbcontainer3d //// AArreeaass tthhaatt aarree sshhaaddoowweedd aarree aarreeaass ooff iinntteerreesstt,, //// oorr ttoo sshhooww wwhheerree ccooddee hhaass bbeeeenn aaddddeedd oorr mmooddiiffiieedd.. // The comment “partial code addition/modificationpartial code addition/modificationpartial code addition/modificationpartial code addition/modification” will appear next to // a line when only part of the code has been added or modified. Object Customer_Name is a dbForm Set Location to 5 12 Set Size to 45 5 : // A colon is used to show the code has been abbreviated End_Object

• Notes:

Notes will be displayed like this. If a note is directed to only certain students(example: for users of prior revisions of DataFlex) it will state this in parentheses atthe beginning of the note so students can skip over notes that do not pertain to them.

Page 27: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 1 Getting Ready

Data Access Corporation 27

Naming ConventionsIt is recommended that you use Hungarian notation when naming classes; objects;properties; constants and variables. This will increase readability of your code and willeliminate the problem of duplicating names.

Prefix Meaning Samplec Class cSuperEditoro Object oPrintButtonp Property piCounterC_ Constant C_Versiong Global variable gsMaxUsers

Local variable (no prefix) iTeamCountSubPrefix (for properties; constants;global and local variables

Meaning

b Boolean (true/false)d Dateh Handlei Integern Numberr Reals Stringv VariantSub-SubPrefix (for handles)ho Handles for object IDs

ie Integer enumerators*All prefixes except for Constants (C_) are lowercase.

* Enumerators are the replacement value of a parameter constant.

Page 28: Discovering Visual DataFlex 9.1

Lesson 1 Lesson 1 Lab Discovering Visual DataFlex

28 Data Access Corporation

Lesson 1 Lab

Description:

Preparation work to get hardware and software ready:

Tasks:

• Ensure that your computer has VDF 9.1 installed and you meet all the hardwareand software requirements listed in this lesson.

Page 29: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 1 Lesson 1 Lab

Data Access Corporation 29

Did You Discover?

1. Which Appendix in this manual has basic information on the DataFlex language?

2. Create names for the following items:

Sample NameA Local Boolean VariableA Local Integer VariableA Global Integer VariableA Global String VariableA ClassAn ObjectAn Integer PropertyA String PropertyA Variant PropertyA ConstantA Local Integer Variable (used to holdan object ID)

Page 30: Discovering Visual DataFlex 9.1

Lesson 1 Lesson 1 Lab Discovering Visual DataFlex

30 Data Access Corporation

Page 31: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporation 31

Lesson 2Creating Workspaces & Database Files

This lesson gives a brief outline of the application to be created. Creating workspacesand the use of Database Builder for creating the database structure are covered.

Topics in this Chapter:♦ Application Building Outline

used by the Labs

♦ Outline of Project DatabaseTables

♦ Definition Files - .DEF Files

♦ Workspace Subdirectories

♦ Starting the Studio

♦ Creating Workspaces

♦ Workspace Pathing

♦ The Goal

♦ Database Builder Utility

♦ Database Builder’s Lock

♦ Using Context Sensitive Help

♦ The Field Tab

♦ Good File Relationships are theKey!

♦ The Index Tab

♦ The Parameters Tab

♦ Lab 2

• Database Builder - BuildingDatabase Tables

• Copy Test Data

• Creating a Database Tablefrom Scratch

• Adding Database FileNames Directly into Filelist

• Use a .DEF File to Create aDatabase Table

Page 32: Discovering Visual DataFlex 9.1

Lesson 2 Creating Workspaces & Database FilesDiscovering Visual DataFlex

32 Data Access Corporation

Application Building Outline Used by the Labs

We will be using the Visual DataFlex tools in the next few lessons to accomplish all ofthese steps from within the Studio.

1. Create a Workspace

2. Create Data Files

3. Create simple Views (create simple data entry code first to help fine-tune our DataDictionarys)

4. Create Data Dictionarys. These contain our business rules such as:

• Auto-Assign Employee number on new saves

• Set default values

• Set up Status Help lines

• Set up Entry options such as CapsLock and AutoFind

• Field Masking

• Validation Tables

• Error Messages

5. Create Templates

6. Create complex Views (add manual code to increase functionality)

7. Add more bells and whistles to our existing application

8. Create Batch Processing

9. Multiple methods of creating reports

Page 33: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporatio

Outline of Project Database TablesA brief description of the files:

Filenames & #s Description

COMPANY (#1) Company informationDEPT (#10) Department information with total number of employees.EMPL (#20) Employee Detail informationTIMECARD (#60) Time records to log time in and outWK_SUM(#80) Collection of daily timesSYSFILE (#200) A one-record file that stores system information, such as the

next employee number.

Arrow points to parent file:

Note: The Company fil

- Empl File

0 - Dept File

200 - SysFile

ompany File

#20

n

e will NOT be ad

imeCard Filek_Sum F

#60 - Tile #80 - W

#1

#

#1 - C

33

ded until a later lesson.

Page 34: Discovering Visual DataFlex 9.1

Lesson 2 Creating Workspaces & Database FilesDiscovering Visual DataFlex

34 Data Access Corporation

Definition Files - .DEF FilesDEF files are ASCII files that show field, index, and file relationship information. Theyare displayed here simply for reference. We will use them later in the lab to quicklycreate our files.

Company.DEF ----------------------------------------------------------------------------- DATE: 06/01/2002 TIME: 20:18 PAGE: 1 FILE DEFINITION FOR FILE: COMPANY (# 1) ----------------------------------------------------------------------------- DRIVER NAME : DATAFLEX FILE ROOT NAME : Company USER DISPLAY NAME : Company DATAFLEX FILE NAME : COMPANY ----------------------------------------------------------------------------- RECORD LENGTH : 34 ( USED: 34 ) MAX NUMBER OF RECORDS : 10000 ( USED: 1 ) FILE COMPRESSION : NONE RE-USE DELETED SPACE : YES LOCKING TYPE : FILE HEADER INTEGRITY CHECKING : YES TRANSACTION TYPE : CLIENT ATOMIC RECORD IDENTITY INDEX : 0 ( 0 , 0 ) FILE LOGIN PARAMETER : SYSTEM FILE : NO ----------------------------------------------------------------------------- NUM FIELD NAME TYPE SIZE OFFST IX RELATES TO FILE.FIELD --- --------------- ---- ----- ----- -- --------------------------------- 1 COMPANY_CODE ASC 4 1 1 2 NAME ASC 25 5 3 TOTAL_BUDGET NUM 8.2 30 INDEX# FIELDS DES U/C LENGTH LEVELS SEGMENTS MODE ------ --------------- --- --- ------ ------ -------- ------- 1 CODE NO YES 4 2 1 ON-LINE

Page 35: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporation 35

Dept.DEF ----------------------------------------------------------------------------- DATE: 06/01/2002 TIME: 12:38 PAGE: 1 FILE DEFINITION FOR FILE: DEPT (# 10) ----------------------------------------------------------------------------- DRIVER NAME : DATAFLEX FILE ROOT NAME : Dept USER DISPLAY NAME : Dept DATAFLEX FILE NAME : DEPT ----------------------------------------------------------------------------- RECORD LENGTH : 1152 ( USED: 1053 ) MAX NUMBER OF RECORDS : 100 ( USED: 3 ) FILE COMPRESSION : NONE RE-USE DELETED SPACE : YES LOCKING TYPE : FILE HEADER INTEGRITY CHECKING : YES TRANSACTION TYPE : CLIENT ATOMIC RECORD IDENTITY INDEX : 0 ( 0 , 0 ) FILE LOGIN PARAMETER : SYSTEM FILE : NO ----------------------------------------------------------------------------- NUM FIELD NAME TYPE SIZE OFFST IX RELATES TO FILE.FIELD --- --------------- ---- ----- ----- -- --------------------------------- 1 DEPT_CODE ASC 4 1 1 2 NAME ASC 20 5 3 NUMBER_OF_EMPL NUM 2.0 25 2 4 BUDGET NUM 6.2 26 5 COMMENTS TEX 1024 30 INDEX# FIELDS DES U/C LENGTH LEVELS SEGMENTS MODE ------ --------------- --- --- ------ ------ -------- ------- 1 DEPT_CODE NO YES 4 1 1 ON-LINE 2 NUMBER_OF_EMPL NO NO 4 1 2 ON-LINE RECNUM NO NO

In another lab, we will addanother field and link it tothe Company file.

Page 36: Discovering Visual DataFlex 9.1

Lesson 2 Creating Workspaces & Database FilesDiscovering Visual DataFlex

36 Data Access Corporation

Empl.DEF ----------------------------------------------------------------------------- DATE: 06/01/2002 TIME: 15:40 PAGE: 1 FILE DEFINITION FOR FILE: EMPL (# 20) ----------------------------------------------------------------------------- DRIVER NAME : DATAFLEX FILE ROOT NAME : Empl USER DISPLAY NAME : Employee DATAFLEX FILE NAME : EMPL ----------------------------------------------------------------------------- RECORD LENGTH : 512 ( USED: 406 ) MAX NUMBER OF RECORDS : 10000 ( USED: 10 ) FILE COMPRESSION : NONE RE-USE DELETED SPACE : YES LOCKING TYPE : FILE HEADER INTEGRITY CHECKING : YES TRANSACTION TYPE : CLIENT ATOMIC RECORD IDENTITY INDEX : 0 ( 0 , 0 ) FILE LOGIN PARAMETER : SYSTEM FILE : NO ----------------------------------------------------------------------------- NUM FIELD NAME TYPE SIZE OFFST IX RELATES TO FILE.FIELD --- --------------- ---- ----- ----- -- --------------------------------- 1 CODE NUM 4.0 1 1 2 LAST_NAME ASC 20 3 2 3 FIRST_NAME ASC 20 23 2 4 SOC_SEC_NUMBER ASC 9 43 3 5 ADDRESS ASC 30 52 6 CITY ASC 12 82 7 ST ASC 2 94 8 ZIP ASC 10 96 9 PHONE ASC 14 106 10 HIRE_DATE DAT 6 120 11 DEPT ASC 4 123 3 DEPT.FIELD_1 (10,1) 12 PAY_TYPE ASC 1 127 13 PAY_RATE NUM 6.2 128 14 LOGGED ASC 1 132 4 15 TERM_DATE DAT 6 133 16 COMMENTS TEX 256 136 17 PICTURE_ID ASC 15 392 INDEX# FIELDS DES U/C LENGTH LEVELS SEGMENTS MODE ------ --------------- --- --- ------ ------ -------- ------- 1 CODE NO NO 2 2 1 ON-LINE 2 LAST_NAME NO YES 40 4 2 ON-LINE FIRST_NAME NO YES 3 DEPT NO YES 53 5 4 ON-LINE LAST_NAME NO YES FIRST_NAME NO YES SOC_SEC_NUMBER NO NO 4 LOGGED NO NO 44 4 4 ON-LINE LAST_NAME NO NO FIRST_NAME NO NO RECNUM NO NO 5 SOC_SEC_NUMBER NO NO 9 3 1 ON-LINE

Page 37: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporation 37

TimeCard.DEF ----------------------------------------------------------------------------- DATE: 06/01/2002 TIME: 12:38 PAGE: 1 FILE DEFINITION FOR FILE: TIMECARD (# 60) ----------------------------------------------------------------------------- DRIVER NAME : DATAFLEX FILE ROOT NAME : TimeCard USER DISPLAY NAME : TimeCard DATAFLEX FILE NAME : TIMECARD ----------------------------------------------------------------------------- RECORD LENGTH : 384 ( USED: 265 ) MAX NUMBER OF RECORDS : 10000 ( USED: 0 ) FILE COMPRESSION : NONE RE-USE DELETED SPACE : YES LOCKING TYPE : FILE HEADER INTEGRITY CHECKING : YES TRANSACTION TYPE : CLIENT ATOMIC RECORD IDENTITY INDEX : 0 ( 0 , 0 ) FILE LOGIN PARAMETER : SYSTEM FILE : NO ----------------------------------------------------------------------------- NUM FIELD NAME TYPE SIZE OFFST IX RELATES TO FILE.FIELD --- --------------- ---- ----- ----- -- --------------------------------- 1 EMPL_CODE NUM 4.0 1 1 EMPL.FIELD_1 (20,1) 2 DATE DAT 6 3 1 3 HOURS NUM 2.0 6 1 4 MINUTES NUM 2.0 7 1 5 IN_OR_OUT ASC 1 8 3 6 MEMO TEX 256 9 7 REASON_CODE ASC 1 265 4 INDEX# FIELDS DES U/C LENGTH LEVELS SEGMENTS MODE ------ --------------- --- --- ------ ------ -------- ------- 1 EMPL_CODE NO NO 11 3 6 ON-LINE DATE NO NO HOURS NO NO MINUTES NO NO IN_OR_OUT NO NO RECNUM NO NO 2 DATE NO NO 10 3 5 ON-LINE HOURS NO NO MINUTES NO NO EMPL_CODE NO NO RECNUM NO NO 3 IN_OR_OUT NO NO 6 3 3 ON-LINE EMPL_CODE NO NO RECNUM NO NO 4 REASON_CODE NO NO 6 3 3 ON-LINE EMPL_CODE NO NO RECNUM NO NO

Page 38: Discovering Visual DataFlex 9.1

Lesson 2 Creating Workspaces & Database FilesDiscovering Visual DataFlex

38 Data Access Corporation

Wk_Sum.DEF ----------------------------------------------------------------------------- DATE: 06/01/2002 TIME: 12:38 PAGE: 1 FILE DEFINITION FOR FILE: WK_SUM (# 80) ----------------------------------------------------------------------------- DRIVER NAME : DATAFLEX FILE ROOT NAME : Wk_Sum USER DISPLAY NAME : Wk_Sum DATAFLEX FILE NAME : WK_SUM ----------------------------------------------------------------------------- RECORD LENGTH : 25 ( USED: 22 ) MAX NUMBER OF RECORDS : 60000 ( USED: 0 ) FILE COMPRESSION : NONE RE-USE DELETED SPACE : YES LOCKING TYPE : FILE HEADER INTEGRITY CHECKING : YES TRANSACTION TYPE : CLIENT ATOMIC RECORD IDENTITY INDEX : 0 ( 0 , 0 ) FILE LOGIN PARAMETER : SYSTEM FILE : NO ----------------------------------------------------------------------------- NUM FIELD NAME TYPE SIZE OFFST IX RELATES TO FILE.FIELD --- --------------- ---- ----- ----- -- --------------------------------- 1 EMPL_CODE NUM 4.0 1 1 EMPL.FIELD_1 (20,1) 2 YEAR NUM 4.0 3 1 3 WEEK_NUMBER NUM 2.0 5 1 4 SUN_HOURS NUM 2.2 6 5 MON_HOURS NUM 2.2 8 6 TUE_HOURS NUM 2.2 10 7 WED_HOURS NUM 2.2 12 8 THU_HOURS NUM 2.2 14 9 FRI_HOURS NUM 2.2 16 10 SAT_HOURS NUM 2.2 18 11 WEEKLY_TOTAL NUM 4.2 20 2 INDEX# FIELDS DES U/C LENGTH LEVELS SEGMENTS MODE ------ --------------- --- --- ------ ------ -------- ------- 1 EMPL_CODE NO NO 5 3 3 ON-LINE YEAR NO NO WEEK_NUMBER NO NO 2 WEEKLY_TOTAL NO NO 6 3 2 ON-LINE RECNUM NO NO

Page 39: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporation 39

SysFile.DEF ----------------------------------------------------------------------------- DATE: 06/01/2002 TIME: 12:38 PAGE: 1 FILE DEFINITION FOR FILE: SYSFILE (# 200) ----------------------------------------------------------------------------- DRIVER NAME : DATAFLEX FILE ROOT NAME : SysFile USER DISPLAY NAME : SysFile DATAFLEX FILE NAME : SYSFILE ----------------------------------------------------------------------------- RECORD LENGTH : 39 ( USED: 39 ) MAX NUMBER OF RECORDS : 1 ( USED: 0 ) FILE COMPRESSION : NONE RE-USE DELETED SPACE : YES LOCKING TYPE : FILE HEADER INTEGRITY CHECKING : YES TRANSACTION TYPE : CLIENT ATOMIC RECORD IDENTITY INDEX : 0 ( 0 , 0 ) FILE LOGIN PARAMETER : SYSTEM FILE : YES ----------------------------------------------------------------------------- NUM FIELD NAME TYPE SIZE OFFST IX RELATES TO FILE.FIELD --- --------------- ---- ----- ----- -- --------------------------------- 1 CORP_NAME ASC 35 1 2 LAST_EMPL_NUM NUM 4.0 36 3 LOCAL_STATE ASC 2 38

Page 40: Discovering Visual DataFlex 9.1

Lesson 2 Creating Workspaces & Database FilesDiscovering Visual DataFlex

40 Data Access Corporation

Workspace SubdirectoriesA workspace is the work area for yourapplication. Workspace subdirectories willkeep all of our application files neatlyseparated. The directory structure after anew workspace is created for the ABCCorporation would have eight subdirectories(AppHtml; AppSrc; Bitmaps; Data; DDSrc;Help; IdeSrc; Programs).

Within theStudio:

Tools | ConfigureEnvironment |General TabLook at theoptionsClose the dialog

Note Keeping the workspace name and application name the same will simplify things.

Figure 2

Figure 3

Used by the WorkspaceWizards as the default areato create the workspace

Page 41: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporation 41

To separate your many applications into structured grouping you can create multipledivisions to organize your workspaces. The Order workspace is organized under theDAW | Examples | Windows divisions. It was created in the sub-directory structure ofExamples | Windows | Order

File | Select Workspace

After you are done looking at thisdialog then close it using the “X” closebutton at the top.

Figure 4

Figure 5

Page 42: Discovering Visual DataFlex 9.1

Lesson 2 Creating Workspaces & Database FilesDiscovering Visual DataFlex

42 Data Access Corporation

This chart shows in which subdirectory your files will be located.

WorkspaceDirectory:

Extension & Description of Files Contained in theDirectory:

UserFiles?

AppHtml Application Html (for web applications) NoAppSrc Studio Data Files → abData

CFG WorkspaceName.cfg holds embeddedresources

DG Dialog filesINC Include filesMN Menu filesPrecompiled package files: FLP Precompiled package (with P option) PKI Precompiled package (with P option) FLD Precompiled package (with PZ option) PKD Precompiled package (with PZ option) PRP Precompiled package (with PF option)PKG Custom Package/Class filesPRN Compiling list when f option usedRV Report View filesSL Selection list filesSRC Source code filesTRC Trace files created by using debuggerTRE Studio’s temporary filesVW View files

No

Bitmaps Bitmap files the application uses, such as CompanyLogos; icons (.ICO); and movies. These are only neededif they where NOT embedded within the EXE.

Yes,unlessembedded

Page 43: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporation 43

WorkspaceDirectory:

Extension & Description of Files Contained in theDirectory:

UserFiles?

Data Filelist.CFG Lists all data file namesDAT Data filesHDR Header filesK# Index (Key) filesRPT Crystal Report filesTAG Field name fileVLD Variable Length Data(If using other databases, they would also be stored here)

Yes

DDSRC DataDictionary Data Files → DDDATADD Data Dictionary filesFD File DefinitionDEF ASCII Definition files

No

Help Help files created for your application YesIDESrc IDEClasses.DFC Studio’s Class-List for workspace

BMP Bitmaps for the New ClassesDFC DataFlex Class filesDFO DataFlex Object Preference filesDFS DataFlex Subcomponent filesTPD Template Dialog filesTPL Template List filesTPR Template Report filesTPV Template View files

No

Programs EXE Compiled CodeOCP ActiveX control preference filesWS Holds pathing & application informationStudio temp file to compile a single program→idetestrun_X.exe

Yes

Note: The workspace subdirectories help the developer separate the files required by the userfrom the files only required by the developer. The last column indicates the directories requiredby the End Users. These directories must be deployed with your application.

Page 44: Discovering Visual DataFlex 9.1

Lesson 2 Creating Workspaces & Database FilesDiscovering Visual DataFlex

44 Data Access Corporation

Page 45: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporation 45

Starting the StudioThe Studio gives the developer quick access to the utilities and tools.

[ Start[ Programs[ Visual DataFlex 9.1[ Visual DataFlex Studio

Figure 6

Page 46: Discovering Visual DataFlex 9.1

Lesson 2 Creating Workspaces & Database FilesDiscovering Visual DataFlex

46 Data Access Corporation

Creating WorkspacesOur first task when starting a new application will be to create a new workspace.

File | NewWorkspace

Figure 7

Page 47: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporation 47

[[[[ Learn More[[[[ Next

[ Learn More

Class.VDF.Finished Example

Finished Example

[[[[ Next

Figure 8

Figure 9

Do not miss thesetwo periods!

Page 48: Discovering Visual DataFlex 9.1

Lesson 2 Creating Workspaces & Database FilesDiscovering Visual DataFlex

48 Data Access Corporation

[[[[ Learn More[[[[ Next button

The “…” promptbutton allows youto browsedirectories tomake a selection.We will leave thedefault location.

Warning: Most of the time you will have your own directory area where you will store yourworkspaces.

[[[[ Learn More[[[[ OK

Figure 10

Figure 11

Page 49: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporation 49

Upon completion of the workspacewizard, this is what has happened:

• Our new Finished Exampleworkspace directory and eightsubdirectories have been created.

• The Studio default workspace hasbeen changed to our newly createdworkspace.

• A few files have been inserted intothese subdirectories that are usedby the Studio (abData & ddData)and other files such as a blankFilelist.CFG. (If any of these filesalready exist in these directories,they will NOT be over-written).The new files that will be used tocreate all new workspaces arecopied from the \Usr\Newdirectory.

• The workspace has been registeredin the workspace.ini file located inthe \Bin directory. This allows theStudio to keep track of allworkspaces and can be modifiedusing the Studio’s Workspacepulldown menu and optionProperties or Workspace Manager.

• A WorkspaceName.WS file wascreated in the \Programs directory. This file is shown on the next page.

Figure 12

Page 50: Discovering Visual DataFlex 9.1

Lesson 2 Creating Workspaces & Database FilesDiscovering Visual DataFlex

50 Data Access Corporation

Workspace PathingIn order to locate files a special .WS file is created in the \Programs directory. Thecontents are listed below. . i.e.; The DataPath is used to find the database table files.Multiple directories can be listed by separating them with a semicolon.

Class.VDF.Finished Example.WS [Workspace] Home=..\ AppSrcPath=.\AppSrc AppHTMLPath=.\AppHtml BitmapPath=.\Bitmaps IdeSrcPath=.\IdeSrc DataPath=.\Data DDSrcPath=.\DdSrc Description=Finished Example HelpPath=.\Help ProgramPath=.\Programs FileList=.\Data\Filelist.cfg

The Studio interfaceto update this file:

Workspace |Workspace Manager

Figure 13

Page 51: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporation 51

The GoalLooking at the finished application will give us a better understanding of the code thatwe will be building. The manual code additions will be more meaningful if you see thefinished application in operation.

We will use a Self-extracting zip file that will install the finished version of the program.This will allow us to see what we are building and have completed files to compare to ifhelp is needed.

Close all VDF utilitiesInsert training CD into drive[[[[ Start[[[[ RunUse the browse button topoint to your CD drive thendouble click on FinishedExampleZip.EXE

Do not change “Unzip tofolder” unless you created theworkspace in a differentlocation

[[[[ Unzip Button

Figure 14

Page 52: Discovering Visual DataFlex 9.1

Lesson 2 Creating Workspaces & Database FilesDiscovering Visual DataFlex

52 Data Access Corporation

Open WindowsExplorer

Go to the Drive anddirectory where yourworkspace is created[[[[ Finished Example[[[[ Programs//// FinishedExample.exe

Figure 15

Page 53: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporation 53

We will be building6 views and 2reports plusmiscellaneous testviews.

Select “Views” fromthe menu to openeach of the viewsand see how theapplicationoperates. Add a fewrecords if you like.

Close theapplication andreturn to the Studio

Things to note:

• New Employee records automatically have the next available number assigned

• The Departments and Employee Views show only the associated Employees in thegrid that belong to the Department record in the top of the view.

• Click on the prompt buttons. These are buttons with three dots on them “…”.

• Running totals in the Dept and Company records update when a new Empl/Deptrecord is updated.

• Process a few employees out with the Logging out View – Then use the button tobatch process the remaining employees out.

• Use the Report Pull-Down to check out the reports that will be created.

Figure 16

Page 54: Discovering Visual DataFlex 9.1

Lesson 2 Creating Workspaces & Database FilesDiscovering Visual DataFlex

54 Data Access Corporation

Database Builder UtilityDatabase Builder utility canbe started from the Studio orfrom the Windows StartMenu. When started fromthe Studio the workspace issynchronized with theStudio’s workspace. Thisutility is where database filesand DataDictionary classfiles are created andmaintained.

Database | Database Builder

File | Open[[[[ Empl File[[[[ Open Button

Figure 17

Figure 18

combo box willalso open files

Page 55: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporation 55

Database Builder’s Lock

Figure 19

The last four tabs will be disscussedin a later lesson. They create theDataDictionary file (.DD). Changesto these last four tabs can be madewith the lock set to red or green.

The Green/Red lock togglesto indicate when the filestructure (first 3 tabs) canbe altered. Green indicatesan exclusive lock on thefile, giving a green light tochange the file structure.

Page 56: Discovering Visual DataFlex 9.1

Lesson 2 Creating Workspaces & Database FilesDiscovering Visual DataFlex

56 Data Access Corporation

Using Context Sensitive HelpOn-line Help is available to obtain a full explanation of any Database Builder option.

[[[[ Lock Icon (so it isgreen)[[[[ Parameters Tab[[[[ Client Atomic1111

Scroll down to theTransaction Typeexplanation

Figure 20

Page 57: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporation 57

The Fields Tab

[[[[ Fields Tab

Good File Relationships are the Key!The “Relates to” column in the grid above is the key to success in VDF. If you areunsure on how to set up file relationships read the “File Relationship” section inAppendix C and look up this topic in the other DataFlex manuals. The basic buildingblocks of a VDF application are based on File relationships. They must be createdcorrectly!

Figure 21

This tab allowschanges to thefields in thedatabase.

Page 58: Discovering Visual DataFlex 9.1

Lesson 2 Creating Workspaces & Database FilesDiscovering Visual DataFlex

58 Data Access Corporation

The Index Tab

[[[[ Index Tab

Figure 22

Spinform tocycle throughthe 15 indexes

A prompt is available to make addingsegments to an index easier. Click onthe Name>> label to popup the field list.Pressing F4 (the prompt key) or InsertButton also brings up this popup.

Page 59: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Creating Workspaces & Database Files

Data Access Corporation 59

The Parameters Tab

[[[[ Parameters Tab

Remember on-linehelp is alwaysavailable.

Figure 23

Page 60: Discovering Visual DataFlex 9.1

Lesson 2 Lab Creating Workspaces & Database Files Discovering Visual DataFlex

60 Data Access Corporation

Lesson 2 Lab

Description:

Practice creating a workspace and database tables:

Tasks:

• Create a new workspace for our application.

Within the Studio:

File | NewWorkspace

Figure 24

Page 61: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Lab Creating Workspaces & Database Files

Data Access Corporation 61

[ Next

[[[[ Select Group[[[[ Class[[[[ VDF[[[[ OKCorporationX

Record Keeping forCorporationX[[[[ Next

Figure 25

Figure 26

Page 62: Discovering Visual DataFlex 9.1

Lesson 2 Lab Creating Workspaces & Database Files Discovering Visual DataFlex

62 Data Access Corporation

[[[[ Next button

The “…” promptbutton allows youto browsedirectories tomake yourselection.

[[[[ OK

Figure 27

Figure 28

Page 63: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Lab Creating Workspaces & Database Files

Data Access Corporation 63

Database Builder—Building Database TablesVisual DataFlex uses a file called Filelist to store the names of all database tables used inan application. There are three ways to add database table names to the Filelist.cfg file.

1. Create a database table from scratch

2. Add the database file name directly to filelist

3. Use a .DEF file to create a database table

File Number Rootname DEF Filename10 Dept Dept.DEF20 Empl Empl.DEF60 TimeCard TimeCard.DEF80 Wk_Sum Wk_Sum.DEF200 SysFile SysFile.DEF

Copy Test DataTo speed things along we will be using a Self-extracting .ZIP file that will copy test dataand .DEF files into our workspace. This test data will be helpful in seeing the operationof our views that we create in the next few lessons.

Close all VDF utilitiesInsert training CD into drive[[[[ Start (MS Windows)[[[[ RunUse the browse button topoint to your CD drive thendouble click onCorporationXZip.EXE

Do not change “Unzip tofolder” unless you created theworkspace in a differentlocation

[[[[ Unzip Button

Figure 29

The file numbers areimportant because theywill determine therelationships among thefiles

Page 64: Discovering Visual DataFlex 9.1

Lesson 2 Lab Creating Workspaces & Database Files Discovering Visual DataFlex

64 Data Access Corporation

Creating a Database Table from ScratchOur first added file will be the SysFile.

From the Studio:

Database |Database Builder

Figure 30

Page 65: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Lab Creating Workspaces & Database Files

Data Access Corporation 65

Within DBB

File | New

200SysFile[[[[ OK

Enter the fields fromthe chart

[[[[ Parameters tab[[[[ System file

File | Save[[[[ OK[[[[ OK

Field Name Type SizeCorp_Name ASCII 35Last_Empl_Num NUMERIC 4Local_State ASCII 2

Figure 31

Figure 32

Page 66: Discovering Visual DataFlex 9.1

Lesson 2 Lab Creating Workspaces & Database Files Discovering Visual DataFlex

66 Data Access Corporation

Adding Database File Names Directly into FilelistIf the database tables already exist, you can just add them to the current Filelist.CFG.This will not wipe out the existing data in these files.

Filelist | New Entry

10DeptDepartmentDept[[[[ OK

Figure 33

Figure 34

Page 67: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Lab Creating Workspaces & Database Files

Data Access Corporation 67

Filelist | New Entry20EmplEmployeeEmpl[[[[ OK

Figure 35

Page 68: Discovering Visual DataFlex 9.1

Lesson 2 Lab Creating Workspaces & Database Files Discovering Visual DataFlex

68 Data Access Corporation

Use a .DEF File to Create a Database TableLoading TimeCard &Wk_Sum files from.DEF files will createempty databasetables with definedfields and indexes.

File | Load DEF

80Wk_SumWk_Sum.def[[[[ OK

Warning! Make sure the file number is correct according to the chart or you will get an “Unableto commit the Structure changes” error. This error says that the .DEF that you are using has arelationship to a file number that does not exist.

Figure 36

Figure 37

Page 69: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Lab Creating Workspaces & Database Files

Data Access Corporation 69

[[[[ Save Button

[[[[ OK[[[[ OK (on the nextdialog)

Figure 38

Figure 39

Page 70: Discovering Visual DataFlex 9.1

Lesson 2 Lab Creating Workspaces & Database Files Discovering Visual DataFlex

70 Data Access Corporation

File | Load DEF60TimeCardTimeCard.def[[[[ OK[[[[ Save Button[[[[ OK[[[[ OK

Figure 40

Page 71: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Lab Creating Workspaces & Database Files

Data Access Corporation 71

Database Builder creates a DataDictionary file (.DD file) every time it creates a databasefile. We will cover these DD files in depth in another lesson but for now, we need toconnect the Data Dictionarys together properly. This is done by the required child and

required parentlists that willmatch the filerelationships.

Use thecombobox toopen all filesexcept “DataFlexerror file”

[[[[ Yes to anyquestion oncreating new .DDfiles

Figure 41

Combobox

Page 72: Discovering Visual DataFlex 9.1

Lesson 2 Lab Creating Workspaces & Database Files Discovering Visual DataFlex

72 Data Access Corporation

[[[[ Empl File Dialog[[[[ Structures tab[[[[ Delete Button untilall files are removedin the section called“Required Childfiles”[[[[ Magic WandbuttonRepeat these stepsin the section called“Required Parentfiles”Save the fileRepeat these stepson all files exceptSysFile

If files are listed in any of these areas, it is best to remove them and then press the wandbutton. The magic wand will add files to the area but it will not remove files that arethere incorrectly. (incorrect files could have been added manually or by relationshipsthat no longer exist).

The SysFile is a system file (a one record file). It will not be listed as a Required Childor Parent file since it has no file relationships. Therefore, it does not need the structurestab updated.

Figure 42

Magic Wand Button

Delete Button

Page 73: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Lab Creating Workspaces & Database Files

Data Access Corporation 73

Did You Discover?

1. Printed in this lesson was a DEF for the TimeCard file that shows its file structure.Without modifications to the TimeCard file, can it have a child file attached to it?Why or Why not? (look in the Appendix C for relationship rules for help)

2. The lock in the upper right corner must be green to make changes to the first threetab pages. When opening a file it always comes up in red - Is there a way to defaultit to green?

3. When adding a new field in Database Builder, are the “Add” and “Insert” buttonsrequired to add a new field?

4. When loading a complete file structure (with many relationships) into a newFilelist.CFG, is it important to load the .DEF files in any special file numberposition? Why?

Page 74: Discovering Visual DataFlex 9.1

Lesson 2 Lab Creating Workspaces & Database Files Discovering Visual DataFlex

74 Data Access Corporation

5. Write down 3 different ways to open a database file in DDB. (open, not create)

6. What is End User Mode and how do you set up Database Builder in End User Mode?(hint look this up in the on-line help under the index tab)

Page 75: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 2 Lab Creating Workspaces & Database Files

Data Access Corporation 75

Page 76: Discovering Visual DataFlex 9.1
Page 77: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 77

Lesson 3Building Views & ComponentsThe Studio is a powerful utility that allows you to not only generate Views and SelectionLists but also generate and maintain a full application.

Topics in this Chapter:♦ Selection Lists

♦ Application Wizard

♦ Button Bar

♦ Tools Pull-Down

♦ Database Selector Tool

♦ DDO Tree Button

♦ Which Related Field?

♦ Object Properties Tool

♦ Setting Object Properties

♦ Controls Palette Tool

♦ Selecting Tab pages &TabDialogs

♦ Base Tab page

♦ Data Tab page

♦ Using the Data Tab page

♦ Base Containers Tab page

♦ Data Containers Tab page

♦ Non-Visible Tab page

♦ Object Placement Tools

♦ Alignment PaletteTool

♦ Popup Menu

♦ Arrange Objects Tool

♦ Nudge Objects Tool

♦ Resolution Check Tool

♦ Object-Order Definition Tool

♦ Drag Lock

♦ Lost Objects in the Studio

♦ Cutting & Pasting Objects

♦ Anchors & Min/Max Size

♦ Lab 3

• Creating Selection Lists

• Attaching Selection Lists

• Using Application Wizard

• Creating the Empl View –without Wizards

• Attaching a New View tothe Application

• Compiling Code & Testing

• Adding Pictures to Records

Page 78: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

78 Data Access Corporation

Selection ListsSelection Lists or Lookup Lists as they are also called allow the user to call up a list tomake a selection from one of the existing records in the database. The selection list iscalled up by clicking on the prompt button or pressing F4 while the cursor is in thatobject.

When your program is running this is what a selection list will look like:

Figure 43

Prompt button from the viewpops-up selection list

Selection List

Page 79: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 79

There are two Steps to create a Selection List:

We will create multiple selection lists later in the lab.

Figure 44

Figure 45

1. Within the Studio, createthe Lookup List

The New Lookup button willcreate a blank lookup ready toadd the file.fields to display.

We will see this later in the lab

2. Within DatabaseBuilder, attach it toone or more fields

New LookupButton

Page 80: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

80 Data Access Corporation

Creating New ApplicationThe Application Wizards will quickly generate the code for an application. It will createthe outermost container with the main menu bar and the first view. Additional views canthen be added later.

We will create a small test program in order to check out the many tools of the Studio.

File | NewProgram

Figure 46

Page 81: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 81

MDI ApplicationWizard[[[[ OK

MDI (Multiple Document Interface) style is where the application window has a numberof iconizable document windows which fit within it. This saves clutter on the desktopsince iconizing or moving the parent window iconizes or moves all the child windows.MDI contrasts with SDI (Single Document Interface) in which windows are notconstrained within one parent window, and normal practice is to run one instance of theapplication per document.

MDI Application Wizard

Use this option to start the wizard that will build your MDI Application shell and one ormore views

Basic Application

Use this option to create a very basic interface. The sample is a “Hello World”, whichcan be built upon to meet your application requirements.

MDI Application

Use this option to create the MDI application without starting the wizard.

Figure 47

Page 82: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

82 Data Access Corporation

TestStudio[[[[ Next

[[[[ Next

Figure 48

Figure 49

Page 83: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 83

TestView[[[[ Next

[[[[ Next

Figure 50

Figure 51

Page 84: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

84 Data Access Corporation

[[[[ DeptDataDictionary

C+[C+[C+[C+[ EmplDataDictionary[[[[ Next

Normally allData Dictionarysin the filestructure areselected. Later,we will learn thatthis view willonly allowemployee recordsto be saved butnot deleted.

Figure 52

Page 85: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 85

Employee[[[[ Next

The main datadictionary is thecentral file usedin the view (it isnot the child-most file). Moreon this topiclater.

//// Empl file[[[[ Code field[[[[ Last_name field[[[[ First_name field

[[[[ Next

Figure 53

Figure 54

Page 86: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

86 Data Access Corporation

[[[[ Finish

//// TestView

Double clickingon the view namewill open theview.

Figure 55

Figure 56

TestView

Page 87: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 87

Resize thecontainer objectsas shown byselecting theobjects anddragging thecorners larger.

Make sure youexperiment withall the tools –The purpose ofthe TestApplication is topractice using theStudio tools!

Figure 57

Page 88: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

88 Data Access Corporation

Button BarMany of the options for the Menu Pull-downs are available from the button bar

Move your mouseover the buttonson the button barto see the tool tipof each button

[ second to thelast button onbottom row toopen the CodeExplorer

Figure 58

Page 89: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 89

Tools Pull-DownThe Tools pull-down lists the many tools available to us. These tools allow you toenhance the views that the wizard has started, or totally create views without the help ofthe wizard.

There are hot keys listed in many of the pull-downs, learning these will increase yourproductivity. There is also a list of hot keys listed Appendix B.

Open the first three tools. They are used in the basic building of the objects in the view

Tools | DatabaseSelector

Tools | ObjectProperties

Tools | ControlsPalette

As we cover thetools experimentwith them to seehow to createobjects within aview

Figure 59

Page 90: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

90 Data Access Corporation

Database Selector ToolThe Database Selector allows you to drag database fields into your component creatingdata-aware objects.

• The top row of buttons allows you to select fromthe most-commonly-used data-aware objects.

• Double Clicking on the file icon will expand thefile to show the field list.

• Selection of a range of fields is done by clickingon the first field in the range and then shiftclicking on the last field in the range. This willselected all fields between.

• The fields will be displayed in the same orderthat they are listed in the Database Selector.They can then be rearranged to your desiredlocation.

[ DDO tree button

Figure 60

Page 91: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 91

DDO Tree ButtonThe DataDictionary Object Button calls up an important dialog. Many complex topicsstem from this dialog. We will be calling up this dialog in many labs. In Lesson 6 wewill fully discuss the linkage between DataDictionarys. In Lesson 8 we will see thisdialog again when troubleshooting problems.

For now, simply look over what is available concentrating on two main topics:

1. The Main DDO is the central file for finding. In our sample program the Main DDOis the Empl DDO. The file relationship does NOT determine the Main DDO. It is alsonot necessarily the child-most file. You determine the Main DDO by determining themain file for finding in the view. Therefore, you must determine how the view willoperate. In our example, when an Employee record is found all other files will fill intheir corresponding record(s). We will see later that all Client (Child) DataDictionarysto the Main DDO should normally be constrained to the Main DDO.

2. Normally all theData Dictionarys inthe file structureare listed. Noticethe child files tothe Empl file arenot listed. Thiswas done todemonstrate thatdeleting recordswould not beallowed, we willcorrect this inanother lesson.

Expand the view byclicking on all the“+” symbols andseeing what isavailable[ Close button

Figure 61

Page 92: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

92 Data Access Corporation

[ Automatic ClassSelection button

/ Dept Icon toexpand the field list

[ Dept.Dept_Codefield

; Dept_Code fieldto the view

; Dept Codeobject larger (bydragging the left orright side)

Figure 62

Automatic ClassSelection Button

Page 93: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 93

Which Related Field?Always reference the Parent-related field in a view!

Before we start on this topic, let’s explain the term Record Buffer. For each database fileopened in a program, a section of memory large enough to hold one record is set aside.This memory storage area is refered to as a Record Buffer. When a record is read it isplaced into this record buffer (memory area). During a save operation the data is movedfrom the screen to the record buffer and then moved from the record buffer to the harddrive. Whenever you reference a file.field name (ex: Move “Miami” to Customer.City),you are referencing the record buffer memory area for that field. The database should belocked when making changes to the record buffer.

During a save operation, the parent related field(s) ismoved from the Parent record buffer to the Child recordbuffer. If a child related field is used in a view, it willbe overwritten by the data from the parent during thesave operation.

In this example the Dept_Code is the relating field.Empl.Dept field relates to Dept.Dept_Code. Whenreferencing the Dept code, you should place the fieldfrom the parent (Dept.Dept_Code). The save operationwill move the Dept_Code data from the parent recordbuffer to the child record buffer. If we mistakenlyentered the Child related field, the Studio (whengenerating the code) will replace it with the Parentrelated field and add a note in the source code that thiscorrection replacement was made.

Figure 63

Page 94: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

94 Data Access Corporation

Object Properties Tool

The Object Properties allows you tochange the most common propertysettings for an object.

[ on the Label Value areaType Department Code:R

Figure 64

Object Class

Name of the Object – This can be changed

Label Property

Page 95: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 95

Setting Object Properties

Many Object Properties will have apopup listing the valid choices. Simplyright click on the property line to seethe list of valid entries.

] Right Click on Form_Border[ Border_None] Label_Justification_Mode[ jMode_Top] Right Click ColorExperiment with the color settings ondifferent objects – for a full explanationrefer to the on-line help

Notice in the TestView where the labels are positioned. Your labels may be offset to theleft with a large space between the label and the object. We will learn how to changethis default in later lesson when we talk about DFOs. For now changing theLabel_Col_Offset property to 0 and Label_Justification_Mode property to jMode_Rightwill adjust the label to the object.

Figure 65

Page 96: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

96 Data Access Corporation

[[[[ Database Tab

The Database tab-page ofthe Object Properties dialogis used to assign values toentry items (file.fields orexpressions) and connectthe currently selected Data-Entry object to a Data-Dictionary object.

This page is only used byDEOs (Data Entry Object -“db” classes). If the currentobject is not a DEO, allitems on this tab page willbe shadowed.

Data Source

Use the radios to connect a file.field, an expression or variable. If the selected object isrow-based, (e.g. dbGrid), use the spin buttons to rotate through the columns of theobject and change the file.field or expression for each column in turn.

The bottom part of the Database tab page is used to set and display the appropriate DDOserver for the object. The server will provide the save/find/clear&delete functionality tothe object. We will cover this in detail in another lesson on connecting DEOs to DDOs.Since save operations propagate up, we will leave the Server set to Empl_DD.

Note: A file.field can be changed into an expression by adding parentheses. Addingparentheses around the Dept.Dept_Code will shadow the object, disallowing user entry duringruntime.

Figure 66

Page 97: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 97

Controls Palette ToolThe Controls Palette in the Studio contains the most commonly used classes from whichobjects are built, The classes are separated into groups on several tab-pages.

• Base and Base Containers tab pages contain non-data-aware controls.

• Data and Data Containers tab pages contain data-aware controls.

• Non Visible tab page contains non-visual or modal controls.

Figure 67

Page 98: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

98 Data Access Corporation

Selecting Tab pages & Tabdialogs

[ Data Containers Tab page on the Controls Palette; dbTabDialog to theviewNotice the black selectionsquares showing theTabDialog is selected[ in the middle of the TabpageNotice the black squaresturn into white squaresshowing the Tab page isselectedBring up the ObjectProperties dialogAgain toggle theselection betweenTabDialog (click the tabarea) and Tab page (clickthe page area). The objectproperties will changeaccordingly

Resize the TabDialog (toresize or move theTabDialog, black squaresmust be showing)[ Base Tab page in theControls Palette; two Textboxes intothe Tab pageChange the textboxObject names and Labelsto BoxA and BoxB

It is a good habit toalways rename the object name to a meaningful name. The object name is how you willrefer to the object when sending messages directly to it. The Language Guide &Appendix C have the suggested naming conventions. All object names should start witha lowercase “o”.

Figure 68

Object and Label

dbTabDialog

Page 99: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 99

Base Tab page

Controls on this page are general-purpose and are not data-aware. Base objects can beplaced inside of Data or Base type containers.

Class Name Classes that objects can be built from:Edit A multi-line text-based control. The control automatically wraps

words between lines and has a vertical and horizontal scrollbar.Button Used to create a user event.Checkbox Used to toggle a Boolean value.SpinForm Displays data and permits the incrementing and reduction of

available values.LineControl Draws a 3-D line on a container.Radio Can only be used within a RadioGroup container, to show the

current selection from a group of mutually exclusive options.ComboForm Combines the functionality of the Form class with that of a

standard Windows drop-down list. This class is used when it isappropriate to supply a form with a list of static options.

Form Simple class to enter single-line information.BitmapContainer Used to display a bitmap.Grid Displays multi-row, multi-column lists,List Used to display a list of values in a single column.Textbox Used to display a text in a container. You may not need to use

this class too often, as the Label property of most classes providesthe functionality automatically.

TrackBar A control to provide users with a visual control to 'slide' through arange of values.

cProgressBar A control to show the progress on a lengthy process.cAnimation A control to displays an AVI animation clip without audio.TreeView A control to display a hierarchical list of items that can expand

and collapse the associated list of sub items.

Figure 69

Page 100: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

100 Data Access Corporation

Data Tab page

Controls on this page are data-aware and are used to display data from, and enter datainto, a database. Data-aware objects can be placed only inside of data-aware containers.

Class Name Classes that objects can be built from:dbEdit Displays database data on multiple lines. Used with Text fields.dbCheckbox Displays Boolean-style database data in a checkbox.dbSpinForm Displays database data and permits the incrementing and

reduction of available values.dbComboForm Combines the functionality of the dbForm class with that of a

standard Windows drop-down list. This class is used when it isappropriate to supply a dbForm with a list of static options.

dbForm Displays database data on one line.dbBitmap Displays the bitmap file listed in the database field.dbGrid A multi-row, multi-column object to enter data into.dbList A multi-row, multi-column object to view data in.dbTrackBar Displays database data on a track bar

Note: The db prefix added to the above class names flags them as data-aware classes.

Figure 70

Page 101: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 101

Using the Data Tab page

Right click on the first tabpageSelect Add Tab page

WU[ Data Tab page on theControls Palette; Drag a dbGrid into tabpage2 and enlarge it

; Drag these fields fromthe Database Selector to thedbGridCodeLast_NameFirst_Name

To delete a tab page:Select tab page2Right click on tab page2Select the Delete Tab pageoption

Figure 71

Figure 72

dbGrid

Page 102: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

102 Data Access Corporation

Base Containers Tab page

Controls on this page are containers designed to hold non-data-aware controls.

Class Name Classes that objects can be built from:Group Used to contain non-data-aware controls. Visually drawn with a

3d-line border with a label in the top left corner.RadioGroup Used to group Radio objects within a Group.Container3d A general-purpose container that has a 3-D appearance.TabDialog A container that holds Tab page objects. It is very useful for

conserving screen space.

Figure 73

Page 103: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 103

Data Containers Tab-pageData Containers are used to group data-aware DEOs (data-entry objects). They must beplaced inside a db-type container themselves (dbView or dbContainer or ReportView).

Controls on this page are containers used to hold other data-aware controls.

Class Name Classes that objects can be built from:dbGroup A container with a label in its top-left corner.dbContainer3d A container with a border that makes it visually appear raised.dbTabDialog Tabs are a great way to display large amounts of data neatly on

the screen. The dbTabDialog holds a single dbTab page objectand allows you to add more dbTab pages.

dbTabDialogView A container to contain and provide coordinated access todbTabView objects. Each TabView displays a standalone viewwith its own DataDictionary structure. Use the dbTabDialog todisplay many TabViews on multiple unrelated datafiles (likemaintenance views), where you can consolidate the number ofviews in your overall application.

dbRadioGroup A container to group Radio objects whose value is of a singledata-entry element.

Figure 74

Page 104: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

104 Data Access Corporation

Non-Visible Tab page

Controls on this page do not create a visual control during runtime or create a modalcontrol that will have to be called. They will generate a visual icon in the Studio so youmay click on it to add manual code in the code editor.

Class Name Classes that objects can be built from:BusinessProcess To perform a batch process on an application’s database files.OpenDialog To provide access to the Windows file-open dialog. It permits

users to select an existing file or enter a name to create.SaveAsDialog To provide access to the Windows file-save dialog. Objects of this

class enable users to enter file names.FontDialog To permit users to select fonts. It is an encapsulation of the

Windows Common Font Dialog. All aspects of the dialog can beset before it is displayed, and queried upon its return.

PrintDialog The PrintDialog class is a wrapper for the Windows Print dialogbox. This dialog box is used to specify the properties of a printjob. This class is intended to be used with the CrystalReport classexclusively

Array The Array class is a general storage device. It is used to store alldata types and its size grows dynamically to accommodate thestorage requirements. Data elements in the array are accessed byan integer index.

Set To assemble and maintain a set of unique values, with operations toadd, remove, and find elements.

Figure 75

Page 105: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 105

dfTimer Objects of this class can be used to trigger an event after a certainamount of time has passed.

cImageList An imagelist is a collection of images of the same size, each ofwhich can be referred to by its index. Imagelists are used toefficiently manage large sets of images, which can then be sharedby multiple objects. A single imagelist object can provide imagesto the TreeView, cToolbar and TabDialog classes.

ColorDialog The ColorDialog class provides an interface to the Windowsstandard Color dialog. The dialog will maintain its own list ofcustom colors and return the selected RGB color.

cMapiHandler Simple MAPI consists of functions for sending mail, receiving mailand sending documents. Consider MAPI as a transport mechanismfor mail and fax messages.

cObject To create a simple object without any special methods found insuperclasses.You can use cObject to create your own subclasses.

Page 106: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

106 Data Access Corporation

Object Placement ToolsThe object placement tools are used to align objects in the view.

Close all open tools, then:

Tools | Alignment Palette

Tools | Arrange Objects

Tools | Nudge Object

Tools | Resolution Check

As we cover the toolsexperiment with each ofthem to see how to arrangeobjects within a view.Remember this is only atest view and its wholepurpose is to test the tools!

Figure 76

Page 107: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 107

Alignment Palette ToolThis tool will help align the objects. Ifthe alignment results are not what youdesired, simply select Edit | Undoimmediately after any of the Alignmentbuttons to return the objects to theiroriginal positions.

The first four buttons justify the tagged objects to match an edge of the first selectedobject. Therefore, it is important which object is selected first.

1. Align tagged objects to the left (left justify)

2. Align tagged objects to the right (right justify)

3. Align tagged objects to the top (top justify)

4. Align tagged objects to the bottom (bottom justify)

The last four buttons equally space the tagged objects. Buttons 5 & 6 space objectsequally between the first and last objects selected. Buttons 7 & 8 space the objectswithin the container object. Buttons 7 & 8 also rearrange and list the objects in the orderthat they are tagged. When spacing more than three objects, it may be better to use theArrange Object tool. This is because when placing the objects evenly within the space ifa remainder exist, the last object cannot be placed correctly.

5. Align tagged objects from top to bottom

6. Align tagged objects from left to right

7. Align tagged objects from top to bottom in parent object

8. Align tagged objects from left to right in parent object

Note: The last two buttons are the only alignment tools that will rearrange the objects in theorder they were selected. This allows you to quickly rearrange objects just by selecting them inthe desired order.

Figure 77 1 2 3 4 | 5 6 7 8

Page 108: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

108 Data Access Corporation

Popup MenusRight Click on anobject. Alignment canbe done from thepopup menu.

] one of the textboxes[ Center[ Horizontally

Figure 78

Page 109: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 109

Arrange Objects Tool

This tool is used to resize and/orspace objects. Activate one orboth parts of the tool with the“Active” checkbox. After youapply the change to the selectedobjects, uncheck the Activecheckbox and your X Y settingsare still available.

Note: The Alignment Palette described earlier can either space the objects between the first andlast tagged object or within the parent object. The Arrange Object tool will leave the first taggedobject in place and then apply the exact X or Y coordinate spacing between other tagged objects.This method will give better results in some situations. This will be noticeable when more thanthree objects are selected and the available free space to divide among the objects cannot bedone equally.

Figure 79X setting adjust left - right

Y settings adjust up - down

Page 110: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

110 Data Access Corporation

Nudge Objects ToolUsed to move or size objects.

Repositioning objects can be done by selecting a group ofobjects and dragging them to a new location or selecting theobjects and using the Nudge Objects tool.

More precision is one advantage of the Nudge Objects tool.Dragging an object to the left or right will often result in asmall up or down movement from the drag. Using the NudgeObjects tool will give you movement in only one direction.Increasing the number in the middle will nudge the object

faster.

Increasing the value will move or size the object faster.

Figure 80

Page 111: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 111

Resolution Check Tool

This tool will help when you are developingan application on a monitor with a differentresolution than that of your customers.

It allows you to see how your application willlook on different resolution screens.

Note: This is an estimate since not all videocards and drivers follow standards

Figure 81

Page 112: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

112 Data Access Corporation

Object-Order Definition ToolThe next tool is a modal popup. You must use it and close it before continuing.

The tab key will move us to the next entryobject in a running application. This toolallows us to change the keyboard navigation ofthe cursor through the objects in our view.Simply select the object and then use theup/down arrow buttons to reposition theobjects. Objects cannot be moved outsidetheir group/container object. When you movea container, all nested objects will move withit.

Tools | Object-Order Definition[ Dept_Dept_Code[ Up Arrow Button until it is the second objectfrom the top[ OKFigure 82

Page 113: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 113

Drag LockThis important feature will protect your view fromaccidental changes of object movement. Drag Lock willlock the objects in place. This will allow you to doubleclick on the objects without accidentally moving them.

You will not be able to drag the objects around with themouse but you will be able to select them and move themwith the arrow keys.

Methods of toggling the Drag Lock

• Menu: Tools | Drag Lock

• Hot Key: Ctrl+L

• Status Bar: Clicking the Lock indicator

The drag lock indicator is an Studio control and once set, itaffects all components in theStudio. The Studio does notstore the setting of thisindicator so it must be seteach time the Studio isopened.

Press the Ctrl+L until the lockis off in the Status Bar

Figure 83

Figure 84

This location will beblank when lock is off.

Page 114: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

114 Data Access Corporation

The remaining options on the Tool’s pulldownmenu will be covered in other lessons. Items areshadowed (not available) depending on if anapplication is opened or closed.

Figure 85

Page 115: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 115

Lost Objects in the Studio (recovering objects not visibleon screen)If not already created -create a dbTabDialogwith two textboxes at thelocations shown

[ dbTabDialog (blackselection markers)

Make the tab pagesmaller so one of theobjects will not show.

/ tab page objectwill bring up the CodeExplorer (Studioeditor)[ on the non-visibleobject in the CodeExplorer object tree

[ Object PropertiesdialogEnter 5,5 for thelocation R

Figure 86

Figure 87 Code ExplorerObject Tree

Page 116: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

116 Data Access Corporation

Cutting & Pasting Objects to Different ContainersObjects cannot be dragged from their parent container. To move or copy objects,

cut/copy them to theclipboard and paste theminto the desiredcontainer. If thecontainer being pastedinto is smaller, theobjects will adjustthemselves to remainvisible in the newcontainer.

] BoxA[ Copy

] the top Container[ Paste

Try cutting and pastingmultiple objects, usingthe Control key to multi-select objects.

Note: For multiplesequential selection, selectthe first item and then, ,hold the shift key downwhile selecting the lastitem. In order to makemultiple randomselections, hold down theControl key while makingadditional selections.

Figure 88

Figure 89

Page 117: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 117

Save and Close theTest_Studioapplication

Briefly, look overthe other pull-downoptions to see whatis available

Figure 90

Page 118: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

118 Data Access Corporation

Anchors & Min/Max SizeAnchors allow automatic resize and location of nested controls when the View orcontainer is resized at runtime.

Here are the basic steps you will need to take

• Allow the Container to be resized. Set the Container’s Border_Style toBorder_Thick (otherwise it cannot be resized)

• Anchor the nested objects within the container. Set with the peAnchor property.

• Determine the Min and Max size limits that the container should be allowed togrow or shrink to and still be useful. Set with the piMinSize and piMaxSizeproperties.

Drag a Button to thebottom right corner

[ TestView Object andchange the Border_Styleto Border_Thick

[ Test -Run Button

When the program comesup running -- Resize theView (MinSize & MaxSize)and notice how theobjects do NOT resize orrelocate

[ “X” Close button andreturn to the Studio

Figure 91Button

TestView Object

Test compile button

Page 119: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Building Views & Components

Data Access Corporation 119

[ TestView Object

Within the ObjectProperties dialog changethe piMaxSize andpiMinSize Plus or Minus100 the Size property

Figure 92

If Size = 170,300then make

Max = 270, 400

Min = 70, 200

Page 120: Discovering Visual DataFlex 9.1

Lesson 3 Building Views & Components Discovering Visual DataFlex

120 Data Access Corporation

[o oButton ObjectWithin the ObjectProperties dialog changethe peAnchors toanBottomRight

[o oDbTabDialog1Within the ObjectProperties dialog changethe peAnchors to anAll

[ Test compile and runcomponent in thedebugger buttonWhen the program comesup running -- Resize theView (MinSize & MaxSize)and notice how theobjects resize & relocate

[ “X” Close button &return to the Studio

Figure 93

Page 121: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Lab Building Views & Components

Data Access Corporation 121

Lesson 3 Lab

Description:

We start by making required selection lists (lookups) and attaching them to theappropriate field. Then we use the MDI Application Wizard to create an outer containerthat will contain the menu bar and status bar. The wizard also creates our first view. Wewill then create the next view manually without the aid of wizards. The third view willuse the View Wizard. We will then test our application.

Tasks:

Creating Selection Lists

If the Studio isclosed restart it,and close all othercomponents.

[[[[ New StandardLookup Button

Figure 94

Page 122: Discovering Visual DataFlex 9.1

Lesson 3 Lab Building Views & Components Discovering Visual DataFlex

122 Data Access Corporation

Tools | DatabaseSelector[[[[ Add DDO button[[[[ DeptDataDictionary[[[[ Select button[[[[ Yes to Main DDO[[[[ Close button

Figure 95

Page 123: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Lab Building Views & Components

Data Access Corporation 123

//// Dept (to expand list)

[[[[ Automatic ClassSelector button

[[[[ Dept_Code field[[[[ Name Field;;;; these fields into thegrid

;;;; the right side of theName column wider

[[[[ Outer Lookup Object

Change the label toDepartment LookupFigure 96

Automatic Class Selector

Outer oLookup Object(the dbModelpanel)

Page 124: Discovering Visual DataFlex 9.1

Lesson 3 Lab Building Views & Components Discovering Visual DataFlex

124 Data Access Corporation

[[[[ Save buttonDeptDepartmentLookupDept_SLG[G[G[G[ Deferred Object[[[[ Save buttonClose all the toolsFile | CloseComponent

There is a MagicWand button intheDataDictionaryBuilder that will

speed up connecting a selection list to a field. We will use this button in the next fewpages. The Magic Wand button can only default these values, if we follow these namingconventions for both the Filename and Object Name:

Suggested Naming ConventionFileName The root database filename. The filename will have the extension of

.SL added but it is not typed into the form when saving.Description A descriptive word for the file (many times just the filename) and the

word Lookup. The word Lookup will flag these components as aSelection List.

Object Name The root database table name with a “_SL” added.

The deferred view checkbox will make our application faster at startup. Instead ofcreating all objects in memory at startup, it will not create the object until it is used forthe first time.

Figure 97

Save Button

Page 125: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Lab Building Views & Components

Data Access Corporation 125

[[[[ New StandardLookup buttonRepeat the abovesteps to create aSelection List(Lookup) for theEmployee fileshowing: Code;Last_Name;First_Name fields.

Save it – Usingnaming conventionlisted in the chartabove

Close all the toolsFile | CloseComponentFigure 98

Page 126: Discovering Visual DataFlex 9.1

Lesson 3 Lab Building Views & Components Discovering Visual DataFlex

126 Data Access Corporation

Attaching Selection Lists in the DataDictionaryNow that our Selection Lists are created we need to attach them to one or more fields inthe DataDictionary.

If the Studio is closed restart it

Database |Database Builder(or the 5th buttonfrom the end onthe button bar)

Figure 99

Page 127: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Lab Building Views & Components

Data Access Corporation 127

File | Open[[[[ Empl file[[[[ Open button[[[[ Field Settings[[[[ Code field[[[[ Validation/LookupTab[[[[ Magic Wandbutton (middlebutton)

If you cannot find the selection list using the Magic Wand – use the “Find Object &Package” (1st) button to locate it.

The same Selection List can be attached to multiple fields. Here is a slightly differentway to attach a list. The Magic Wand will only work if the filename follows thesuggested naming convention.

[[[[ Last_Name field[[[[ Find Object &Package button (1st

button)[[[[ Empl.SL[[[[ Open

[[[[ Save button[[[[ OKFile | Close

Figure 100

Figure 101 Find Object & Package

Wand Button

Page 128: Discovering Visual DataFlex 9.1

Lesson 3 Lab Building Views & Components Discovering Visual DataFlex

128 Data Access Corporation

[[[[ File comboformArrow[[[[ Dept

This will Open theDept file - attach theselection list toCode and Namefields

Save and Return tothe Studio

Figure 102

Page 129: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Lab Building Views & Components

Data Access Corporation 129

Using Application WizardThe ApplicationWizard will allowyou to quicklygenerate the codefor an application.We will create ourfirst view here andthen modify itusing Studio tools.

If an existingprogram is openselect File | CloseProgram

File |New Program

[[[[ OK

Figure 103

Figure 104

Page 130: Discovering Visual DataFlex 9.1

Lesson 3 Lab Building Views & Components Discovering Visual DataFlex

130 Data Access Corporation

CorporationX[[[[ Next

[[[[ Next

Figure 105

Figure 106

Page 131: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Lab Building Views & Components

Data Access Corporation 131

DeptView[[[[ Next

[[[[ Next

Figure 107

Figure 108

Page 132: Discovering Visual DataFlex 9.1

Lesson 3 Lab Building Views & Components Discovering Visual DataFlex

132 Data Access Corporation

[[[[ DepartmentDataDictionary

[[[[ Next

[[[[ Dept_Code field[[[[ Name field[[[[Number_of_empl[[[[ Budget[[[[ Comments[[[[ Next

Figure 109

Figure 110

Page 133: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Lab Building Views & Components

Data Access Corporation 133

[[[[ Finish

Figure 111

Page 134: Discovering Visual DataFlex 9.1

Lesson 3 Lab Building Views & Components Discovering Visual DataFlex

134 Data Access Corporation

/ DeptView

Enlarge theDept_Code Object[[[[ Test compile andrun component in thedebugger button

Notice that you cansave new records butyou cannot deleterecords – we willcorrect this inanother Lesson

Figure 112

Figure 113

Page 135: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Lab Building Views & Components

Data Access Corporation 135

Creating the Empl View – Without Wizards

Close all open views andapplications.

[[[[ New Standard ViewButton

You could also selectFile | New Componentand select the BlankView from the DataEntryView tab page but thatwould take longer.

Tools | DatabaseSelector[[[[ Add DDO button[[[[ EmplDataDictionary[[[[ Select button[[[[ Yes – to make itthe Main DDO

Notice the parentfile (Dept) is alsoopened. Saveoperationspropagate up soparent files willopenautomatically

Figure 114

Figure 115

New Standard View

Page 136: Discovering Visual DataFlex 9.1

Lesson 3 Lab Building Views & Components Discovering Visual DataFlex

136 Data Access Corporation

[[[[ Close button

Using the manytools covered inthis lesson createthe Empl Viewsimilar to thisscreen (do notforget thedbContainer3dobject)

Use the ObjectProperties Tool tochange the ViewLabel to EmployeeView

Enlarge theEmpl.Code &Dept.Dept_Codeobjects

Position theobjects in thelocation shown –using theAlignment Tool

Use the Object-Order Tool tochange thenavigation

Note: Remember what we discussed in the lesson! The related parent field is used in the view,not the child related field. This is because during a save operation DataFlex will do an“Attach” prior to the save. This operation will move the related field from the parent to thechild. If we were to actually use the Empl.Dept field here, then the blank parent record bufferwould be moved to the Child Empl.Dept field causing the Empl.Dept field to be blank. TheStudio will swap the field for us when it generates the code if we use the wrong one.

The reason we continue to make the Dept Code objects larger is that later we will besetting the field option to CapsLock, which will require a larger object.

Figure 116

Don’t forget thedbContainer3d

Page 137: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Lab Building Views & Components

Data Access Corporation 137

From the ControlsPalette; a dbTabDialogto the bottom of theview and resize it

] dbTagDialog (forthe menu popup)[[[[ Add Tab Page[[[[ Add Tab Page

Within the ObjectProperties dialog:[[[[ each tab page(white selectorsquares) & set Labelsto:Personal InformationWork InformationPicture ID

Figure 117

Figure 118

Page 138: Discovering Visual DataFlex 9.1

Lesson 3 Lab Building Views & Components Discovering Visual DataFlex

138 Data Access Corporation

Within DatabaseSelector Tool

; fields toPersonalInformation Tabpage

; fields to WorkInformation Tabpage

Enlarge thePay_Type field – wewill be adding avalidation table to itin another lesson.

Figure 119

Figure 120

Page 139: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Lab Building Views & Components

Data Access Corporation 139

] (right click) PayType[[[[ Object Properties] (right click)Prompt_Button_Mode[[[[ pb_PromptOn

This prompt buttonwill not operate untilthe validation tableis added.

[[[[ Automatic ClassSelector (Wand)button at the top ofthe DatabaseSelector Tool

; Picture_ID fieldto the Picture ID Tabpage

[[[[ Bitmap button atthe top of theDatabase SelectorTool

; Picture_ID fieldto the Picture ID Tabpage

Figure 121

Figure 122

Page 140: Discovering Visual DataFlex 9.1

Lesson 3 Lab Building Views & Components Discovering Visual DataFlex

140 Data Access Corporation

[[[[ dbBitmap Object

Within ObjectProperties Tool[[[[ Initial FolderC:\Program Files\VisualDataFlex9.1\Projects\Class\VDF\CorporationX\Bitmaps

The Initial Folderproperty lists the initialdirectory, which willbe displayed by thecommon file-opendialog. When we runthe program, we willsee this dialog whenwe add a bitmap file toan employee record.

Note: The Initial_Folder property can be set dynamically to the current workspace \bitmaparea. If you don’t want to hardcode the Initial_Folder property add this to the Code Explorer:

Set Initial_Folder of (CurrentBitMapPath (ghoWorkSpace))

Appendix B has examples of code to solve problems when using multiple directories in yourBitmap path and to limit the bitmap filename to 15 characters. If the end-user selecst a bitmapthat is outside the current path, it is suggested that programmably the developer may wish tocopy the bitmap to the current Bitmap path.

Figure 123

Page 141: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Lab Building Views & Components

Data Access Corporation 141

[[[[ Save button andsave as Empl_View[[[[ Close button

Figure 124

Close

Page 142: Discovering Visual DataFlex 9.1

Lesson 3 Lab Building Views & Components Discovering Visual DataFlex

142 Data Access Corporation

Attaching a New View to the Application

If the mainapplication isclosed, reopen it:File | Openprogram |CorporationX

From the CodeEditor:

[[[[ Add a ComponentButton[[[[ Views[[[[ Empl_View.VW[[[[ Add Button[[[[ Close Button

Figure 125

Add a Component

Page 143: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Lab Building Views & Components

Data Access Corporation 143

Compiling Code & Testing

The Compile buttonwill automaticallysave our code first.

[[[[ Compile anddebug-run programbutton (this willcompile and run ourapplication)

After the programcomes up running -Open both views byselecting them fromthe View pull-down

Test the Application noting theitems in the chart

Figure 126

Things to NoticeHow the tab pages switch.Confirmation Messages during a save.How Selection Lists operate.How multiple Views can be opened simultaneously.

Page 144: Discovering Visual DataFlex 9.1

Lesson 3 Lab Building Views & Components Discovering Visual DataFlex

144 Data Access Corporation

Adding Pictures to RecordsAdding pictures to records is accomplished by storing the name of the .BMP file in thedatabase field and storing the physical bitmap file in the \Bitmaps directory of theworkspace. We will be using the Empl.Picture field. We already copied both the \dataand \bitmaps directories from our training CD to our workspace. If you did not do thisplease copy the files now.

Run the application andopen the Empl View

Create a new employeerecord

[[[[ Picture ID tab page

/ the Bitmap object –the popup dialog willallow us to locate ourbitmap file.

Since our initial folderwas set to:C:\Program Files\VisualDataFlex9.1\Projects\Class\VDF\CorporationX\Bitmapsthis is the defaultdirectory that the dialogwill show

Select a .BMP file[[[[ Save ButtonClose program whendone testing

Figure 127

Page 145: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 3 Lab Building Views & Components

Data Access Corporation 145

Did You Discover?

1. What happens if you enter a 2-digit year into a date window such as Term Date?

2. What is Epoch and what has it to do with entering dates in a VDF application?

3. Predict and check the results of entering the following dates, with Epoch turned onand set to 30? 01/01/00

06/20/52

12/25/30

4. What would happen to the tab dialogs if the dialog box was not big enough to holdall three tabs? (add more tabs or shorten the tab dialog box to find out)

5. What would happen if you shortened the length of the last name window so that theentire last name entered wouldn’t fit in the window?

6. Run the program, and type in a last name of “WWWWWWWWWW” (type capitalW’s until you reach the limit (which is the length of the field). Notice that it had toscroll to the right. Clear with the F5 key, and type in a last name of “iiiiiiiiii” (allsmall letters i’s to the limit). How do you determine what the size of a control shouldbe?

Page 146: Discovering Visual DataFlex 9.1

Lesson 3 Lab Building Views & Components Discovering Visual DataFlex

146 Data Access Corporation

7. When using the Object-Order Definition tool, is it important where Textbox objectsare listed?

8. Run our program, and open up the Employee Entry View. Find a Record, then placethe cursor on the parent window (Dept) and press Shift+F2 to delete. Wait! What isgoing to be deleted? The Department or the Employee? Why?

Page 147: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Generated Code

Data Access Corporation 147

Lesson 4Generated Code

We will start to look over all the code that the Studio has generated for us. This will giveus a better understanding of how VDF code works. The Studio editor allows manualcode to be easily added throughout your application.

Topics in this Chapter:♦ Editor’s Full Source Mode

♦ The Big Picture

♦ Activating Views

♦ Creating Templates

♦ Manual Code That the Studio Can Read

♦ Lab 4:

• Creating an Invoice Style View Template

• Adding Manual Code to Objects

• Creating Dept/Empl View – Using View Templates

• Grid Options

• Changing Navigation

Page 148: Discovering Visual DataFlex 9.1

Lesson 4 Generated Code Discovering Visual DataFlex

148 Data Access Corporation

Editor’s Full Source ModeThe Editor has two modes Outline and Full Source mode. Outline will show only thecode added to the selected object. Full Source mode will display all the code within thecode file.

Within the Studioopen the program

]]]] Anywhere withinthe Code Explorer[[[[ Toggle Full Source

Use the code in theeditor to follow alongthe code explanationon the next fewpages

Figure 128

Page 149: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Generated Code

Data Access Corporation 149

The Big PictureLet’s look at our application with all its modular parts. The Use command will includemodular code from separate files into our application. Encapsulation is when our codeis broken down into stand-alone modules. This makes it easier to reuse it.

Here is our CorporationX.SRC Source code file.

//AB/ Project CorporationX //IDE-FileType=ftMdiFrame //AB/ Object oIde_Project is a MdiFrame_Project //AB/ Set ProjectName to "CorporationX" //AB/ Set ProjectFileName to "CorporationX.src" //AB/ Set GenerateFileName to "CorporationX.src" //AB-IgnoreStart Use DfAllEnt.pkg #REPLACE CURRENT$WORKSPACE "Class.VDF.CorporationX" // Project Object Structure // Main is a Panel // Client_Area is a AppClientArea // oAbout is a AboutDialog // Register all objects Register_Object Client_Area Register_Object Main Register_Object oAbout //AB-IgnoreEnd //AB-StoreTopStart Use cApplication.pkg // Set date attributes as needed Set_Date_Attribute sysdate4_State to (TRUE) Set_Date_Attribute Date4_State to (TRUE) Set_Date_Attribute epoch_value to 30 Object oApplication is a cApplication Set psCompany to "My Company" Set psProduct to "My Product" Set psVersion to "1.0"

Ensure all dates areentered as four digits

//DFAllEnt.PKG

Use Windows

...

These three properties can becustomized to your application.Showing your Company;Product; and Version

Page 150: Discovering Visual DataFlex 9.1

Lesson 4 Generated Code Discovering Visual DataFlex

150 Data Access Corporation

//Set psHelpFile To "HelpName.hlp" // Please provide the name of your Windows help file. Procedure OnCreate Send DoOpenWorkspace (CURRENT$WORKSPACE) End_Procedure End_Object // oApplication Use Help_Ids.inc //Developer should provide this file of help context links. Use Std_Help.pkg //AB-StoreTopEnd //AB-IgnoreStart //AB-IgnoreEnd Object Main is a Panel Set Label to "CorporationX" Set Size to 150 300 //AB-MenuAutogen //AB-IgnoreStart DFCreate_Menu Main_Menu #INCLUDE File_PM.inc DFCreate_Menu "&View" ViewPopupMenu is a ViewPopupMenu On_Item "&DeptView \aCtrl+1" Send Activate_DeptView On_Item "&Employee View \aCtrl+2" Send Activate_oEmpl_View End_Pull_Down Set Status_Help To "Available Views" #INCLUDE Navi_PM.inc #INCLUDE Win_PM.inc #INCLUDE HelpA_PM.inc End_Menu //AB-IgnoreEnd //AB-ToolbarPackage Use DefaultToolbar.pkg // Tool-Bar object. //AB-End

Main Panel

Menu Bar and Pulldowns

Notice the two views listed

Page 151: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Generated Code

Data Access Corporation 151

Object Client_Area is a AppClientArea //AB-ViewStart Use DeptView.vw Use Empl_View.VW //AB-ViewEnd End_Object // Client_Area //AB-IgnoreStart On_Key Key_Ctrl+Key_1 Send Activate_DeptView To Client_Area On_Key Key_Ctrl+Key_2 Send Activate_oEmpl_View To Client_Area //AB-IgnoreEnd //AB-StatusBarPackage Use DefaultStatusbar.pkg // Status-Bar object. //AB-End //AB-StoreStart Use DfAbout.pkg Object oAbout is an AboutDialog Set ProductName To "CorporationX" Set Copyright To "Copyright: <add code here>" Set Author To "Author: <add code here>" End_Object Procedure Activate_About Send Popup_Modal of oAbout End_Procedure //AB-StoreEnd End_Object // Main //AB-StoreStart Start_Ui //AB-StoreEnd //AB/ End_Object // oIde_Project

Note: (instructors) This is a good place to point out the corresponding Studio areas from theProgram tree that appear whenever a program is opened.

//Empl.VW

use Empl.DD

//Dept.VW

use Dept.DD

use Empl.DD //Empl.DD

//Dept.DD

At this point the user interface is startedand the activate message is sent to theMain_Menu object, which paints theimage on screen making it the top imageand gives the focus to this object.

//Use the Standard Status barand About packages

Properties to customizeyour about dialog

Page 152: Discovering Visual DataFlex 9.1

Lesson 4 Generated Code Discovering Visual DataFlex

152 Data Access Corporation

Things to note!

• The main program is a shell where modular sections of code are included (via theUSE Command)

• The first file brought in by the USE command is the DFAllEnt.PKG. This Packagefile contains Class definitions (the code to make the tools work). The .PKG files arenot always classes; sometimes they are support packages that perform specialfunctions.

• The View files end with the extension .VW. These View files are the heart and soulof the program. They are modular sections of code that can operate independently.Each can be compiled and run separately within the Studio.

• Also note that all the views have the same command “USE EMPL.DD”. This file isneeded in each view so it will operate correctly when using the view separately in atest program. When all the views are added together in the main program, theEMPL.DD file is only included into the program once! If a change has to be addedto the code in the EMPL.DD file, it only needs to be modified in the one place andafter re-compiling will affect all the views.

• Modular code allows us to use the same code over and over agiain. These modularcode sections seem confusing at first. The real benefit is gained when you modify ordebug your code. This is similar to the fact that it is harder to troubleshoot acomputer that has everything built into the motherboard. If the serial port is aseparate card, you can repair it without worrying about breaking the Disk Controller.However, if everything is on the motherboard, fixing one problem can often breakother parts.

Note: (for everyone) The USE command assumes a .PKG extension, if no extension is given.

Note: (for DataFlex procedural programmers) The Use command is very similar to the#INCLUDE compiler directive that you may have used in your code. The main difference is thatthe #INCLUDE would include a file numerous times, but the USE command will only bring ina file once.

Note: (for DataFlex procedural programmers) A Menu program with RunProgram wait andChain wait commands is comparable to what we now call views.

Page 153: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Generated Code

Data Access Corporation 153

Activating ViewsViews can be activated by the view pulldown menu or by Accelerator keys. The messagename MUST be the same in both the .SRC file and the .VW file.

// This is the .SRC file DFCreate_Menu "&View" ViewPopupMenu is a ViewPopupMenu On_Item "&EMPL VIEW\aCtrl+1" Send Activate_EMPL_VIEW … Object Client_Area is a AppClientArea // Include all views Use EMPL_VIEW.vw … End_Object // Client_Area On_Key Key_Ctrl+Key_1 Send Activate_EMPL_VIEW of Client_Area … Start_UI

// This is the Empl.VW File ... DEFERRED_VIEW Activate_Empl_View FOR ; ; Object Empl_View is a dbView Set Label to "Employee Entry View"

Page 154: Discovering Visual DataFlex 9.1

Lesson 4 Generated Code Discovering Visual DataFlex

154 Data Access Corporation

Creating TemplatesTemplates save time in the design of components. In this example, we create a templatethat can be used when needing multiple views of a standard size. Templates can beLocal or Global: Local meaning they are only accessible to one workspace; Global

meaning will beaccessible to allworkspaces.

[[[[ New Standard Viewbutton from the button bar

Enlarge the view to justinside the 640 x 480 gridlines[[[[ File | Save As Template |Local

Enter file name ofView640x480[[[[ Save buttonClose the View

File | New Component

Notice the new templatelisted[[[[ Cancel Button

Figure 129

Figure 130

Page 155: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Generated Code

Data Access Corporation 155

Manual Code That the Studio Can ReadThe Studio allows manual edits to the source code and is capable of reading the edits aslong as a few rules are followed.

• Use markers //AB-marker_name to flag the edits (creating edits through theOutline mode of the Studio’s Code Editor will add these markers for you)

• Place the markers and the edited code in the correct location (creating these editsthrough the Studio will ensure they are created in the correct location)

Note: The Visual DataFlex language uses double slashes “//” to flag comments in your code.Therefore, these markers will be considered as comments by the Compiler, but have specialmeaning to the Studio.

1. Manual Code in the .SRC file (via the Studio)

Lets look at somecode areas in theeditor.

Open CorporationXapplication:[[[[ Outer-ComponentCode

Notice the Start_UIat the bottom andthe Date _AttributecommandsEnter YourCompany; Product;and Versioninformation

Figure 131

Outer-Component

Page 156: Discovering Visual DataFlex 9.1

Lesson 4 Generated Code Discovering Visual DataFlex

156 Data Access Corporation

2. Manual Code in Visual Objects (via the Studio)

Open the EmplView[[[[ oEmpl_Codeobject

Notice that theselected objectstays in sync withthe shadowedobject in the editor

All objects start with an “Object” command and end with an “End_Object”. The Studiowill add all its code where the Green Line is located. This means you have the ability toadd manual code in the Code Explorer above or below where the Studio places all itsgenerated code, such as the properties from the Object Properties dialog and nestedobjects.

Normally, you can simply add all your custom code below this green line. However,sometimes it is important that the added code is placed at the top of the object. E.g., ifyou were creating a new property that nested child objects would need, it would have tobe created before the nested child objects try to use the new property.

Figure 132

Code addedto the top ofthe Object

Code addedto the bottomof the Object

Selected object willbe highlighted

Page 157: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Generated Code

Data Access Corporation 157

3. Manual Code in the DataDictionary Objects (via the Studio)

Also notice thatthe DataDictionary objectsare alsoaccessible eventhough they arenot visibleobjects. We willbe adding manualcode to manyobjects later, inthe lab[[[[ Close this view

Figure 133

Page 158: Discovering Visual DataFlex 9.1

Lesson 4 Generated Code Discovering Visual DataFlex

158 Data Access Corporation

List of the Studio (AB = Application Builder) markers. Normally you will not need totype these, since the Studio will add these markers for you when you modify withinthe Studio editor in Outline View mode.

Marker Sample Location Manual Edits

Source Code File //AB/ Project project-name First non-blank line in yoursource code

No

Commands for the Studioonly

//AB/ command These are various commands thatthe Studio must understand thatmust be ignored by the compiler

No

Studio generated code forthe compiler only

//AB-IgnoreStart

//AB-IgnoreEnd

The Studio does not use this areabut generates it for the compileronly. Any changes made here willbe overwritten by the Studio.

No

Data-Dictionary ObjectArea

//AB-DDOStart

//AB-DDOEnd

Only definedand registeredData-DictionaryObjects areallowed

Manual-Code-Area //AB-StoreTopStart

//AB-StoreTopEnd

//AB-StoreStart

//AB-StoreEnd

Top and bottom edit area of thevisual objects

Yes

Note: The main edit areas are the bottom code areas and do not have the word “bottom” withinthe marker name but the Top edit area does contain the word “Top” just prior to the Start/End.

Page 159: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Lab Generated Code

Data Access Corporation 159

Lesson 4 Lab

Description

Our next view will need manual code additions. The view style will be an invoice style.This style has a parent (order header) record displayed at the top of the view and a gridbelow filled with the child (order detail) records. Since this style of view is oftenneeded, we will first create a view template that adds the manual code additions to makethe view operate correctly. We will then use this template to create our Dept/EmplView. Then in later lessons we will again use our view template.

Tasks

The order example is a sample application. It may be helpful to run this example tounderstand how it operates.

The order view looks like this:

This step can beskipped if you arefamiliar with theOrder Example.

Window’s Start |Programs | VisualDataFlex 9.1 |SampleApplications | OrderEntry SystemOpen the OrderEntry view & test it

Notice that youcannot enter thegrid unless theheader is saved

Close the exampleand return to theStudio

Figure 134

Page 160: Discovering Visual DataFlex 9.1

Lesson 4 Lab Generated Code Discovering Visual DataFlex

160 Data Access Corporation

Creating an Invoice Style View TemplateWe will create a basic invoice style view, adding only the objects that require manualcode additions.

[[[[ New StandardView Button

Use the ControlsPalette to create the5 objects as shown

Use the ObjectProperties Tool tochange the objectname & object labelsas shown in thechart. Only therequired items thatneed to be renamedare listed.

Type of Object Object Name LabeldbContainer3ddbForm First ObjectdbForm Parent Related ObjdbForm Last ObjectdbGrid oDetail_Grid

Figure 135

Compiler errors will occur ifthis one is not renamed!

Object Name

Label

Page 161: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Lab Generated Code

Data Access Corporation 161

At this point in the manual – DO NOT TO TRY TO UNDERSTAND ALL THEMANUAL CODE ADDITIONS!

We will cover the syntax of code in other lessons – at this point simply concentrateon how the views are working!

Manual code segments that will be added to our Header/Grid (Invoice Style) Templatecan be cut from a file called Code_Mod.TXT located on the CD that came with thismanual.

When manual code is added to a template it is important to make it as generic aspossible. This will increase the usefulness of the template to help us create many newviews. This also means there may be a few items that may require customization to makeour template function in a new workspace with new database tables. You will noticethese types of customizations are described in the remark area within the code.

Manual Code Features that will be added are:

• Custom Save & Delete messages

• Save_Header procedure (ensures header is saved before entering grid)

• Switch Procedure for last object in header

• Append_A_Row (allows entering only at the end of the grid)

• Child_Entering in the Grid (sends the Save_Header procedure)

• Auto_Regenerate_State set to false (table will not resort when new recordsare added)

• Child_Table_State set to true (to ensure the row is always saved)

Page 162: Discovering Visual DataFlex 9.1

Lesson 4 Lab Generated Code Discovering Visual DataFlex

162 Data Access Corporation

Adding Manual Code to ObjectsThis step adds the Custom Save & Delete messages, plus the Save_Header procedures tothe outer view container. The Code_Mod text file will allow us to cut and paste codeinstead of manually typing it.

We will cover manual code in depth in another lesson.

With our newview stillopened.

File | Open File

Use the browsebutton and opentheCode_Mod.txt filefrom the TrainingCD

Note: In the manual code you will start to see the use of “*” and “+” to combine variables andconstaints. Ex:

Move ("Delete Entire" * (psHeaderName(Self)) + “?") to sDel_String

The “*” will leave a space between and the “+” will not.

Figure 136

Lab dividers willshow which lab thecode is for.

Cut & paste dividersshow where to start andend a cut & where topaste it

When cut/pastingbe SURE to cutboth slashes

Page 163: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Lab Generated Code

Data Access Corporation 163

/ the oViewobject (dbView)andCut & Paste thecorrespondingcode into thebottom area

This is the codeto cut & paste.After pastingalways comparethe code printedin the manual tothe code pastedinto the object.

//------------------------------------------------------------------- // Add to the oView object - below the green line // To customize our template set the defaults of top 2 properties: //------------------------------------------------------------------- // Enter the Header descriptive filename // Example: Order --> not OrderHea // The file name will be used to name the view (Order or Transaction) // It will also customize our messages so they will say "Save this Order" // or "Save this Transaction". If the print button is used it will // expect a Crystal report called psHeaderName.RPT --> (Order.RPT) Property String psHeaderName Public "Order" // Enter the File.Field of the header key field // Example: OrderHea.Order_number for the order example Property String psFileField Public "Order.Order_Number"

Figure 137

Before adding any codeNotice the selected object

Page 164: Discovering Visual DataFlex 9.1

Lesson 4 Lab Generated Code Discovering Visual DataFlex

164 Data Access Corporation

Property Integer piKeyFieldnum Public 1 // 1 is the default for the field number Property String psType_Header_Key Public "I" // "I" is the default for the Header Key field type Procedure Activate Forward Send Activate // Determine the field number of the Header's key field // Then update the default setting for the property piKeyFieldnum String sHold String sFile sField Integer hFile iField iLen iPosDot iType Get psFileField to sHold Move (Length (sHold)) to iLen Move (Pos(".", sHold)) to iPosDot Move (Left(sHold, (iPosDot - 1))) to sFile Move (Append (sFile, ".File_number")) to sFile Move (Eval(sFile)) to hFile Move (Right(sHold, (iLen - iPosDot))) to sField Field_Map hFile sField to iField Set piKeyFieldnum to iField // Determine the type of the Header's key field // Example: "I" = Integer or a "S" = ASCII string // This is a small limit to our template but most key fields are either ASCII or Integer // Then update the default setting for the property psType_Header_Key Get_Attribute DF_Field_Type of hFile iField to iType If (iType = DF_ASCII) Set psType_Header_Key to "S" // its default setting is "I" End_Procedure //Activate //----------------------------------------------------------------------- // Change: Create custom confirmation messages for save & delete. // Create the new functions and assign verify messages to them. //----------------------------------------------------------------------- Function Confirm_Delete_It Returns Integer Integer iRetVal String sDel_string Move ("Delete Entire" * (psHeaderName(Self)) + "?") to sDel_string Get Confirm sDel_string to iRetVal Function_Return iRetVal End_Function // Only confirm on the saving of new records Function Confirm_Save_It Returns Integer Integer iRetVal iSrvr iRec

Page 165: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Lab Generated Code

Data Access Corporation 165

String sSav_string Get Server to iSrvr Get Current_Record of iSrvr to iRec If (iRec = 0 ) Begin Move ("Save New" * (psHeaderName(Self)) * "record?") to sSav_String Get Confirm sSav_string to iRetVal Function_Return iRetVal End End_Function // Define alternate confirmation Messages Set Verify_Save_MSG to GET_Confirm_Save_It Set Verify_Delete_MSG to GET_Confirm_Delete_It //------------------------------------------------------------------- // Change: Table entry checking - attempt to save header record // before entering a table (this is called by table. Return // a non-zero if the save failed (i.e., don't enter table) //------------------------------------------------------------------- Function Save_Header Returns Integer Integer iRec bChanged iSrvr String sError_String Get Server to iSrvr // The Header DDO. Get Current_Record of iSrvr to iRec // The current header rec#. Get Should_Save to bChanged // Are there any current changes? // If there is no record and no changes we have an error. If (iRec=0 AND bChanged=0) Begin // no rec Move ("First Create & Save a" * (psHeaderName(Self)) * "Record") to sError_String Error DfErr_Operator sError_String Function_Return 1 // a non-zero return val will stop the save End // Attempt to Save the current Record // Request_Save_No_Clear does a save without clearing. Send Request_Save_No_Clear // The save succeeded if there are now no changes, and we // have a saved record. Should_Save tells us if we've got changes. // We must check the DataDictionary's Current_Record property to see if // we have a record. If it is 0, we had no save. Get Should_Save to bChanged // is a save still needed Get Current_Record of iSrvr to iRec // current record of the DD

Page 166: Discovering Visual DataFlex 9.1

Lesson 4 Lab Generated Code Discovering Visual DataFlex

166 Data Access Corporation

// If no record or changes still exist, return an error code of 1 If (iRec=0 OR bChanged) ; Function_Return 1 End_Function

Page 167: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Lab Generated Code

Data Access Corporation 167

Note: (Everyone) In an Invoice Style view it is important to restrict the user’s navigation intothe grid without first displaying a Parent/Header record in the top of the view. In our templatewe will ensure a header parent record is displayed and saved before allowing the user to enterthe grid. This will be accomplished by the Save_Header procedure, which safeguards againstcreating orphan Child/Detail records.

This step will allow entryinto the parent field onlyif it is a new record.

From the Code_Mod.txtfile, highlight & cut theappropriate code (shownbelow)

[[[[ Parent object to selectit; paste code in thebottom area

//------------------------------------------------------------------- // Add to Parent (odbForm) object - below the green line // If Header record exists, disallow entry in Related Parent window. //------------------------------------------------------------------- Procedure Refresh Integer iMode Integer iSrvr iCrnt Get Server to iSrvr // get the DataDictionary Get Current_Record of iSrvr to iCrnt // get record in DataDictionary // Set displayonly to true if iCrnt is non-zero Set Enabled_State to (iCrnt = 0) Forward Send Refresh iMode // do normal refresh // don't leave us sitting on a displayonly window If (iCrnt and Focus(Self)=Self) Send Next End_Procedure

Figure 138

Page 168: Discovering Visual DataFlex 9.1

Lesson 4 Lab Generated Code Discovering Visual DataFlex

168 Data Access Corporation

This step modifies (overrides) the behavior of the Switch message (sent when we pressthe F6 key or click in the grid). Under some view structures if a user is in the last objectof the header and presses the F6 key, the Switch message would allow them into thetable without a valid parent record. To guard against this we will send the Activatemessage instead of the normal switch message.

From theCode_Mod.txt file,highlight & cut theappropriate code(shown below)

[[[[ Last object toselect it; paste codein the bottom area

//------------------------------------------------------------------- // Add to the Last (oDbForm3) object - below the green line // Normal switch behavior is to attempt to keep looking for additional // objects to switch to. If we can't switch to the detail table, we // want to stop! So just do a simple activate. This solves the problem // of the Save Header not being called if we press F6 (switch) on the // last object. //------------------------------------------------------------------- Procedure Switch Send Activate of oDetail_Grid End_Procedure

Figure 139

Page 169: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Lab Generated Code

Data Access Corporation 169

This step will make the grid operate correctly for our application. The Append_A_Rowwill allow us to add records only to the bottom of the grid. Since we are only addingrecords to the grid bottom there is no need to sort the table after each save, so we will setthe Auto_Regenerate_State off. The Child_Table_State will ensure the row is alwayssaved. The Child_Entering will send our Save_Header procedure.

From theCode_Mod.txt file,highlight & cut theappropriate code(shown below)

[[[[ oDetailGridobject to select it;paste code in thebottom area

//------------------------------------------------------------------- // Add to oDetail_Grid (dbGrid) object - below the green line // Change: Table entry checking. // Set Child_Table_State to True which will // cause table to save when exiting and // attempt to save header when entering. //------------------------------------------------------------------- Set Child_Table_State to TRUE // Saves when exit object // Called when entering the table. Check with the header if it // has a valid saved record. If not, disallow entry. //

Figure 140

Page 170: Discovering Visual DataFlex 9.1

Lesson 4 Lab Generated Code Discovering Visual DataFlex

170 Data Access Corporation

Function Child_Entering Returns Integer Integer iRetVal Delegate Get Save_Header to iRetVal // Check with header to see if it is saved. Function_Return iRetVal // if non-zero do not enter End_Function //------------------------------------------------------------------- // Change: Assign Add-Mode key to Append_A_Row // Create new behavior to support Append_A_Row // Optimize the table refresh //------------------------------------------------------------------- On_Key KAdd_Mode Send Append_A_Row // Hot Key for KAdd_Mode= Shift+F10 // prepare to add new record by Jumping to blank row at end of grid. Procedure Append_A_Row // Q: how would a keyboard do this? Send End_Of_Data // A: Go to end of table and Send Down // down 1 line to empty line End_Procedure // The way this table is set up, items can never be added out // of order. New items are always added to the end of the table. // By setting Auto_Regenerate_State to False we are telling the // table to never bother reordering after adding records. This is // a minor optimization. Set Auto_Regenerate_State to False // table is always in order

Page 171: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Lab Generated Code

Data Access Corporation 171

File | Save as Template |[[[[ GlobalInvoice_Style

[[[[ Save Button

Close this component

Figure 141

Page 172: Discovering Visual DataFlex 9.1

Lesson 4 Lab Generated Code Discovering Visual DataFlex

172 Data Access Corporation

Creating Dept/Empl View – Using View Templates

File | NewComponent[[[[ Invoice_Style[[[[ OK button

Figure 142

Page 173: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Lab Generated Code

Data Access Corporation 173

We will not needthe Parent relatedobject. Right Clickon it (the popupmenu will appear)select Delete

Tools | DatabaseSelector[[[[ Add DDO[[[[ EmplDataDictionary[[[[ Select button[[[[ No to MainDDOpopup question[[[[ Main DDOcombo and SelectDept[[[[ Close button

Figure 143

Page 174: Discovering Visual DataFlex 9.1

Lesson 4 Lab Generated Code Discovering Visual DataFlex

174 Data Access Corporation

] Right Click onthe first object(the popup menuwill appear).Select Properties

Use the ObjectProperties dialogto label the 1st

dbForm to “Code”

[[[[ Database tabpage[[[[ browse (…)button in the DataSource area

SelectDept.Dept_Code[[[[ OK

Repeat the abovesteps on the otherdbForm, changingthe label to“Budget” and thesource toDept.budget field

Figure 144

Browse Button

Page 175: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Lab Generated Code

Data Access Corporation 175

Grid Options

Use the DatabaseSelector tool toadd the remainingfields to both thetop section and tothe grid

] (right click) onthe grid (for thepopup menu)[[[[ Grid Options

Note: All the thingsthat can be done inGrid Options!

[[[[ Hire_Date[[[[ Down Arrow Keyuntil Hire_Date islisted last

Make sure the Mainfile is Empl file andthe index is Index.3

[[[[ OK button

Figure 145

Figure 146

Changing the column sizecan be done by draggingthe line in the grid header

Page 176: Discovering Visual DataFlex 9.1

Lesson 4 Lab Generated Code Discovering Visual DataFlex

176 Data Access Corporation

Changing Navigation

Change the label ofthe View to Dept/EmplView

Change the objectnames (object name,not label) of the firstand last objects tooDept_Code andoDept_Budget

Use the Object-Ordertool to correct thenavigation of theobjects, make themmatch the screen shot[[[[ OK button

Figure 147

Page 177: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Lab Generated Code

Data Access Corporation 177

Here we have to customize the template by setting the default values of four properties.

/ The outer view containerto bring up the editor

Change the default valuesof the two properties asshown in the table below

Property Name Change value from: Change value to:psHeaderName “Order” “Department”psFileField OrderHea.Order_Number Dept.Dept_Code

Figure 148Outer ViewContainer Object

Page 178: Discovering Visual DataFlex 9.1

Lesson 4 Lab Generated Code Discovering Visual DataFlex

178 Data Access Corporation

[[[[ Save the view filling inthe data as shown

[[[[ Test/Run current viewbutton

Attach the view to theoverall application asshown in the previouslab

Warning: If you get ompiling errors such as – “Bad Image Errors”

Look for a single slash /------

And correct the line in code explorer to have a double slash //---------

Test theApplicationnoting the itemsin the chart

A chart ofAcceleratorKeys is listed inAppendix C.

Figure 149

Things to Notice

Activate the Selection ListsNotice the Scroll bars added to all scrollable areasConfirmation Messages for saves and deletes

You should not be able to navigate to the grid until a headerrecord is displayed. Try leaving the header blank and:� Press F6 from the header (F6 is the switch key)� Click into the grid� Press tab from the last object in the headerFind a header record and then in the grid pressing Shift+F10 (theAdd Mode key) will jump to the bottom of the grid.The grid columns can be resized

Page 179: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 4 Lab Generated Code

Data Access Corporation 179

Did You Discover?

1. What is the normal behavior of the “Shift+F10” if the Append_a_Row procedurewas not available?

2. In the DataFlex language, how do you continue a command line to the next line?

3. Within the DeptEmpl View, go to the grid and enter some test data, but do not savewith the F2 key. . . click on a window in the header . . . can you exit the line itemwithout a save occurring? What if you use the down arrow or up arrow? Does thesave occur?

4. When the Studio generates the code for an Object the Green Line in the Code Editorwill be replace with what?

5. When you find a Department record (in the header section), only the employees forthat Department are found and displayed. How does the program know to show onlyrelated records in the dbGrid?

Page 180: Discovering Visual DataFlex 9.1

Lesson 4 Lab Generated Code Discovering Visual DataFlex

180 Data Access Corporation

6. Create a new view with two dbForm controls, one showing the Empl.Code and theother one showing the Empl.Last_Name. Make the dbForm for the Empl.Codecontrol using the Database Selector. Make the dbForm for the Empl.Last_Nameusing the Controls Palette. When you compile and run your new view did both ofyour controls show data when you find records? What extra step do you have to dowith the Controls Palette when creating data-aware controls?

Page 181: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 181

Lesson 5Data Dictionarys Part 1

This lesson covers how to use the DataDictionary Builder utility (which is incorporatedinto Database Builder). This utility will allows you to create and edit the DataDictionaryfiles painlessly. Making selections and setting checkboxes generates most code for you.When reading this lesson, no changes should be made to the files until the Lab at the endof the lesson.

Topics in this Chapter:♦ DataDictionary Classes

♦ Business Rules

♦ DataDictionary Class & ObjectDifferences

♦ Building Data Dictionarys

♦ Field Settings

♦ Field_Options

♦ Field Validation

♦ Modal Objects are Popups

♦ Using Validation Tables

♦ Field Masking

♦ Appearance Tab

♦ Other Tab page

♦ Checkbox Option

♦ Status Help

♦ Simple Default Value

♦ Entry/Exit/Validation Messages

♦ Entry & Exit Messages

♦ Auto-Assigning Numbers

♦ External Structure

♦ Lab 5

• Building Data Dictionarys forAll Database Files

• Setting Field_Options

• Setting Field Validation

• Validation Tables

• Setting Field Masking

• Setting Appearance Tab

• Setting Status Help

• Field_Default_Value

• Auto-Assigning Numbers

• Changing an Object’s Class

Page 182: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

182 Data Access Corporation

DataDictionary Classes – the .DD FileDataDictionarys are our database interface, performing such operations as finds, clears,saves and deletes. This is where our business rules will be located for such things asextra processing before saves and deletes. One large advantage of the DataDictionaryclass is that it allows us to place the rules of the database and the individual fields in onecentral location. Using this class will improve data integrity!

Every database table should have a (DataDictionary Class) .DD file created

We will be creating a .DD file for each of our database files. If a business rule shouldalways apply throughout the application, it will be added to the DataDictionary classdefinition in the .DD file, but if a business rule should only apply to one view, then itwill be implemented in the DataDictionary object within that view.

Note: (for OOP programmers) The same rules we learned in earlier revisions using DataSetswill still apply with DataDictionarys. Our familiar DataSet procedures (creating; update;backout) still apply in the DataDictionary. Your application will work with a mixture of viewsusing DataSets and views using DataDictionarys. Just do not mix DataSets andDataDictionarys in the same view. DataDictionarys are much more powerful. If you haveexisting applications with DataSets, it is recommended to take the time to convert them toDataDictionarys.

Page 183: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 183

Business Rules

Business Rules are rules that must be followed before changes are allowed to thedatabase.

Examples:

• Verify important facts before allowing saves and deletes.

• Do not allow a parent record to be deleted if it has related child records.

• Auto-assign a number for all new records being saved.

Since these are things that happen during saves and deletes, we subclass theDataDictionary Class and add all these rules in our new class.

Business Rules are built into the subclass so they affect ALL views. If the rule shouldonly affect one view then that rule should NOT be in the class, but in the DataDictionaryObject within the view that it should affect.

Page 184: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

DataDictionary Class & DataDictionary ObjectDifferencesThe Class will contain all the constant business rules that should apply to all views.Setting the State field to be DD_Capslock in the Class will ensure that the State field will

be capitalized no matterin which view the datawas entered.

ary

DD_CapslockThis will affectall views

//Customer.DD File Class Customer_DataDictionary is a DataDiction Procedure Define_Fields Set Field_Options Field Customer.State to End_Procedure : End_Class

184 Data Access Corporation

Note: (Procedural programmers) If you are having problems with the concepts of Objects andClasses refer to the appropriate section in Appendix C.

//CallCust.VW Object Customer_DataDictionary is a Customer_DataDictionary End_Object

//CustGrid.VW Object Customer_DD is a Customer_DataDictionary End_Object

//Customer.VW Object Customer_DD is a Customer_DataDictionary : Set Field_Default Field Customer.State to “FL” End_Object : Object Customer_State is a dbForm End_Object

This will only affect this one view

Page 185: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 185

Building DataDictionarys for Database FilesWhen a database file is created, a DataDictionary subclass (.DD file) is automaticallycreated. This DataDictionary file can be read back into the DataDictionary Builder andmodified whenever required. It is suggested that you make your modifications via theDataDictionary Builder but you are also allowed to modify the code using a text editor.

In order to know when and how to use the many options in the DataDictionarys, youmust know what is available. The rest of the lesson exposes you to the many options thatthe DataDictionary can contain. Use this lesson as a reference as you complete the laband when you create future projects.

Note: (everyone) Database Builder is the entire utility. DataDictionary Builder has beenincorporated within Database Builder and is the last four tabs.

• Field Settings

• Methods

• Options

• Structures

Page 186: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

186 Data Access Corporation

Field SettingsThe six tab pages under the Field Setting tab page are settings that are made at the fieldlevel. Be sure to indicate the correct field before setting these options.

Field Options

Warning! If youwish to see thesescreens on yourcomputer, openany file inDatabase BuilderUtility. Nochanges shouldbe made until thelab at the end ofthe lesson or ifyou seecommandsprinted in thisstyle font (with thehorizontal lines atthe top andbottom)!

Example Code Created:

Note: (Prior databasedevelopers) Key fieldsare similar to thePrimary Key concept ofother databases

Figure 150

Procedure Define_Fields Forward Send Define_Fields Set Field_Options Field Empl.Code to DD_AUTOFIND Set Field_Options Field Empl.Code to DD_KEYFIELD Set Field_Options Field Empl.Code to DD_NOPUT :

The KeyField option is normally placedon uniquely indexed fields. When afield is flagged as a KeyField and theProtect_Key_State is True (the default),the user will not be allowed to changethe value of the field.

Page 187: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 187

Note: (Prior DataFlex Users) In prior DataFlex versions we placed the entry options within theDEOs. They are now placed in the DataDictionary (DD File). This will assure data consistencyin our databases. Entry options Range & Check will be covered later in this lesson.

Within DEOs{option}

Within DataDictionary

Set Field_OptionsField

Description

AutoFind DD_AutoFind Find Equal a record automaticallyAutoFind_GE DD_AutoFind_GE Find Greater or Equal a record

automaticallyCapsLock DD_CapsLock Uppercase all data in windowDisplayOnly DD_DisplayOnly No entry and no put to record bufferFindReq DD_FindReq Found indicator must be true to continueForcePut DD_ForcePut Force data from window to record bufferKeyField Set Key_Field_State To protect a field from being changedNoEnter DD_NoEnter No navigation to data-entry window

allowedNoPut DD_NoPut No put of data to record bufferRetain DD_Retain Keep data in window (clearable)RetainAll DD_RetainAll Keep data in window (not clearable)Required DD_Required Requires an entrySkipFound DD_SkipFound Skip entry if found indicator is trueZero_Suppress DD_Zero_Suppress Blanks display if numeric is zeroAutoBack Not Windows behavior* Back up a window on left arrowAutoClear Not Windows behavior* Clear the window if new data is enteredAutoReturn Not Windows behavior* Advance to next window on a full

windowPoints= n done with masking Decimal points set to (0 1 2...n)Thousands done with masking Displays thousands separator in numeric

fields

Page 188: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

188 Data Access Corporation

Field ValidationField Validations areaccomplished uponforward navigation fromthe field and prior to thesave (outside of alocked state).

Validation Description & Example Code Created:

ValidationMethod

A validation message that will get called whenever there is forwardnavigation from this field. Set Field_Validate_Msg Field Cust.St to Ck_State : Procedure Ck_State // add validation code here End_Procedure

SimpleValidation

Will check that the data is a sub-string of the checked string, e.g.;“M|F”. Set Field_Value_Check Field Cust.Sex to “M|F”

RangeFrom

Will check a Numeric or Date Entry is within a specified range Set Field_Value_Range Field Customer.Credit_Limit to 500 90000

ValidationError

Error Number/Message that will display if a Simple Validation, RangeValidation, Validation Table or an incorrect Checkbox Value Validationfails Set Field_Error Field Customer.Credit_Limit to 330 ; “The Credit Limit must be between @PARAM to @PARAM2”

Figure 151

Number is set by developer

@PARAM# will reflect Validation Values

Page 189: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 189

Modal Objects are PopupsModal Objects are objects that require interaction before processing can continue. ASelection List is an example of a Modal object. The F4 key or prompt button is used tosend the popup message. When the Selection list is activated the user is forced tointeract with it. They cannot click on the menu bar or any other object outside of themodal object.

There are many different names for Modal Objects (Popups; Dialogs; Zooms; SelectionLists; Lookups; Prompts). The terminology can be confusing because many of thesenames are interchangeable.

Many classes can operate as modal objects by setting their Modal_State property to true.The ModalPanel and dbModalPanel are two classes that by default already have theirModal_State property set to true. Therefore, most modal objects are created by usingone of these classes.

Modal Objects

• Prompts (i.e.: Selection Lists and Validation Tables)

Activated by pressing F4 or clicking on a designated button

Prompt_Object or Column_Prompt_Object property is set from the calling object

• Dialogs (i.e.: About or Login Dialogs)

Activated by sending Popup_Modal from the calling object

• Zooms (i.e.: a popup data entry dialog)

Activated by pressing Alt+F9

Zoom_Object or Column_Zoom_Object property is set in the calling object

Page 190: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

190 Data Access Corporation

Using Validation TablesValidation Tables normally contain a list of “Codes” and “Descriptions” used to validateentered data and present to the user a list of suggested or required entries. There are fourtypes of validation class tables that can be used.

The Class Hierarchy chart shows the first Validation Class was built from the Arrayclass and then each seceding class has additional functionality and features included. Themain difference among the classes is how the source of the data is being displayed.

Class HierarchyArray

|__ValidationTable (built from static data)

|__DescriptionValidationTable (built from static data)

|__FileValidationTable (built from a database table)

|__CodeValidationTable (built from existing database tables)

Page 191: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 191

Visual Display of Validation Tables:

All of the validation classes will use either a ComboForm or a ValidationList Class asthe visual object to display the data.

This is an exampleof a Validation Tableattached to a fieldand displayed with acomboform class.

If the validationtable is attached toa field built from adbForm class, thevalidation tablewill appear as apopup scrollablelist. It will be builtfrom theValidationListClass.

Note: Creating a parent file and building selection lists (lookups) like those that we created inthe last lesson will basically accomplish the same thing as validation tables.

Figure 152

Figure 153

Page 192: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

192 Data Access Corporation

Types of Validation Tables The source of the displayed data will determine whichclass to use for your validation table.

Type Source of Displayed Data Class to be UsedNone Clears Field_Value_Table property.Dynamic CodeMast & CodeType

data filesCodeValidationTable

Static Static – Hard CodedValues that will not change

DescriptionValidationTable (if Values andDescriptions are loaded) orValidationTable (if only Values are loaded)

Custom Programmer’s specifieddatabase table

One of the Validation table objects createdmanually.

Note: (Everyone) On-line help is always available. Use it for a more complete explanation ofall settings.

Figure 154

Checking “Blanks”will allow blanks or 0as a valid response

Checking Validate willrequire entries to exactlymatch a value in the list

Page 193: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 193

None is to clear the Field_Value_Table.

Note: If you have entered values into the grid for a static type validation table, selecting Nonewill clear the values entered for the Static validation table. This will require you to re-enter thedata if the none option was click by mistake.

Figure 155

Page 194: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

194 Data Access Corporation

Dynamic sets the Validation Table’s class to CodeValidationTable. By default thisclass uses the predefined database files CodeMast and CodeType. The Type Value formshould be filled in to indicate the code type from the CodeMast file.

The Maintain Code File dialog is used to create records for the validation table.

This dialog can bereached from theStudio Workspacepull-down and theCode MasterMaintenance option.

Two empty databasefiles, CodeType andCodeMast are includedin the \Datasubdirectory. Aftercreating the records inthis utility they will beavailable when youcreate DynamicValidation Tables.

Figure 156

Figure 157

“New Type Value”Button allows youto add a CodeTyperecord so it will beavailable in theType Valuecombobox. Butnormally we createthe records first asshown below.

Page 195: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 195

Example Code Created:

Note: a useful property is: Static_State

Set Static_State to True // Will load its list only once in each session.

Set Static_State to False // If application allows editing of the list,

//such as a code Maintenance view

Note: Since CodeMast and CodeType files are being opened as file numbers 207 and 208 thesefile numbers should not be used.

// The default file used with the CodeValidationTable class is "CodeMast.dat & CodeType.dat" // Therefore, code & description fields and the index is known Object Empl_Pay_Type_VT1 is a CodeValidationTable Set Type_Value To "PAYTYPE" End_Object // Empl_Pay_Type_VT1 : Procedure Define_Fields Forward Send Define_Fields : Set Field_Value_Table Field Empl.Pay_Type To (Empl_Pay_Type_VT1(Self)) // used in conjunction with the Validation Tables above

Page 196: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

196 Data Access Corporation

Static Uses staticdata that is hardcoded into theobject. It sets theValidation Table’sclass toDescriptionValidationTable(if Values andDescriptions areloaded) orValidationTable(if only Values areloaded)

Example Code Created:

Figure 158

Object Empl_Pay_Type_VT is a DescriptionValidationTable Set Allow_Blank_State To TRUE Set Table_Title To "Select Pay Type" Procedure Fill_List Forward Send Fill_List Send Add_Table_Value "H" "Hourly" Send Add_Table_Value "S" "Salary" Send Add_Table_Value "P" "Part-Time" Send Add_Table_Value "C" "Contract" End_Procedure // Fill_List End_Object // Empl_Pay_Type_VT: Procedure Define_Fields Forward Send Define_Fields : Set Field_Value_Table Field Empl.Pay_Type To (Empl_Pay_Type_VT(Self)) // used in conjunction with the Validation Table above :

Page 197: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 197

Custom for any other class that you have used for the Validation Table. Normally aFileValidationTable is used. If you select Custom, then Database Builder will not allowyou to configure the Validation Table object and the object will have to be manually

built.

Use this class todisplay/ validatefrom Databasefiles orDataDictionarys.Normally it isbetter to use aSelection Listbecause ofperformance.

Figure 159

Page 198: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

198 Data Access Corporation

Open Chg_Code //Open the new database that will be used Object Charge_Table is a FileValidationTable // Developer creates the Code File therefore // the fields used for Code & Description must be // indicated along with the correct index to use. Set Main_File to Chg_Code.File_Number Set Code_field to 3 // field 3 is the charge card code field Set Description_field to 4 // field 4 is the charge card description field Set Ordering to 1 // index that contain the segments // Chg_Code.Code & Chg_Code.Desc Set Validate_State to True // requires entries to exactly match a value in the list Set Allow_Blank_State to True // will allow blanks or 0 as a valid response End_Object // Charge_Table Procedure Define_Fields Forward Send Define_Fields : Set Field_Value_Table Field Empl.Pay_Type To (Charge_Table(Self)) // used in conjunction with the Validation Table above :

Page 199: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 199

Field MaskingThis powerful feature enables you to define a data-entry template, or mask, for the valuesthat can be entered into a field. Field masks constrain entries to only those characters,digits and special characters that the masks allow, and only in those specific positionswithin a field that you predefine. The mask characters are not saved in the database filesand are mainly for improving the appearance of the displayed data.

1. Default Masks: Most of the time the default Field_Mask_Type settings are all that isrequired. There are four Field_Mask_Type settings. Their defaults will be covered in atable in the next section.

Example Code Created:

Figure 160

Set Field_Mask_Type field Customer.Balance to Mask_Currency_Window

// The following Mask_windows are normally not set since they are the default

Set Field_Mask_Type field Customer.Name to Mask_Window

Set Field_Mask_Type field Customer.Last_Order_Date to Mask_Date_Window

Set Field_Mask_Type field Customer.Age to Mask_Numeric_Window

Page 200: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

200 Data Access Corporation

2. Custom Masks: Sometimes the default masks are not sufficient and customizedmasks must be created. This is done in two steps. First, set the Field_Mask_Typeproperty to the correct type, then customize a mask with the Field_Mask property.Token characters are shown in the tables on the next few pages.

Example Code:

The hyphens in the mask will not be saved to the database. This means that the fieldlength will not need to be increased

Figure 161

Set Field_Mask_Type Field Empl.Soc_Sec_Number To MASK_WINDOW

Set Field_Mask Field Empl.Soc_Sec_Number To "###-##-####"

You can also addcustom masks to arepository to use later.

Page 201: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 201

Non-token characters (defined for the Field_Mask_Type) will be displayed literally.Token characters can be displayed literally by preceding each with a backslash (\).

Field_ Mask_Type Defaults

TokenChar.

Contents of TokenEach token occupies one place

unless notedMask_Window Windows

default#@!*

0 - 9 (or blank)any alphabetic character (no numbers)any punctuation characterany printable character

Mask_Currency_Window&

Mask_Numeric_Window

"$,*;($,*)"

“*"

,.;#*0

insert local thousand separatorinsert local decimal indicatorseparates positive & negative formats0 - 9 (or blank)any number of digits including none0 - 9 (cannot be blank)

Mask_Date_Window default shouldnot be changed

mmm

mmmmmmm

ddd

ddddddd

yyyyyy

/

1 - 1201 - 12Jan - Dec (abbreviated)January - December1 - 3101 - 31Sun - Sat (abbreviated)Sunday - Saturday00 - 991700 - 2900(diagonal is replaced with the localdate separator)

Note: Dates will take Microsoft Windows’ Settings over the mask!

Page 202: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

202 Data Access Corporation

3. Masks in DEOs:

If the mask should only affect one Data Entry Object (DEO) in a view, it can be alteredwith one of the properties shown

4. Changing the default masks:

You can change the global defaults of Currency_Mask_Window andNumeric_Mask_Window. This is done by altering the Default_Currency_Mask andDefault_Numeric_Mask string(s) within the DFBASE.PKG. When you wish to changethe “global” strings for only one application, you can change the string(s) immediatelyafter the "Use DFAllEnt" statement.

Use DFAllEnt Move “,*” to Default_Numeric_Mask

// Set Currency_Mask item_num to integer integer [string] // string is optional // second integer is number of digits to right of decimal // first integer is number of digits to left of decimal Set Currency_Mask 0 to 8 2 “$,*;$,*-“ : : Set Numeric_Mask 0 to 6 0 “*%“

Page 203: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 203

Appearance TabThis tab allows us to set the default class our visualcontrols will be built from in the Studio. The Magic Wandbutton (Automatic Class Selection) on the DatabaseSelector tool defaults dbEdit objects for all TEXT fields;and dbForm objects for all other type fields. Using theAppearance tab page, we can set the type of class thatobjects will default.

We created a StaticValidation type tableon the Pay_Type. Byour setting the VisualControl todbComboForm, theStudio will create adbComboForm (not adbForm) wheneveran object is builtfrom this field. Anyobjects created bythe Studio prior tosetting this option arenot affected.

Example Code:

Set Field_Class_Name Field Empl.Pay_Type To "dbComboForm"

Figure 162

Figure 163

Automatic Class Selection

Page 204: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

204 Data Access Corporation

The Long and Short Labels will be displayed as the visual label when we create an objectfrom the field in the Studio. The short label will be used in all list type objects (such asdbGrids) and the long label will be used as the label in all other types of objects. Thiswill speed the creation of all our views and will keep our labels constant throughout ourapplication. If the labels are not set, then the Studio will use the field name as the label.

Example Code:

Set Field_Label_Long Field Empl.Soc_Sec_Number To "Social Security Number" Set Field_Label_Short Field Empl.Soc_Sec_Number To "SSN"

Note: The Auto_Label_State property will use the Long Label setting. See the on-line help fora full description of this property.

Figure 164

Page 205: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 205

Other Tab pageThis tab page allows us to quickly enter a variety of items for each field in our database.The last item, Short Description allows the programmer to add programming commentsfor each field.

Checkbox OptionThe Checkbox option will make the field into a checkbox. In the Contact sample (asample provided with VDF) we can see that the Studio will create the visual control forthe STATUS field as a checkbox. The values saved to the database will be an “A” foractive (true- checked) or an “I” for inactive (false- unchecked).

Figure 165

Page 206: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

206 Data Access Corporation

Status HelpStatus Help will display at the bottom of the screen whenever the user enters this field.

Example Code:

Set Status_Help Field Empl.Last_Name To "Please enter the employee's last name. "

Figure 166

Page 207: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 207

Simple Default ValueEstablishes the default value that will appear after a clear. It is only a default and can beoverwritten.

Entering values into the Default Value option will add lines into the procedure calledField_Defaults.

Example Code:

Procedure Field_Defaults Forward Send Field_Defaults //DDB-FieldDefaultStart Set Field_Changed_Value Field Empl.St To "FL" //DDB-FieldDefaultEnd End_Procedure // Field_Defaults

Note: (Everyone) This can also be a function such as (MyFunc(Self, parm1 parm2,…)).Functions will be covered in a later lesson.

Figure 167

Page 208: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

208 Data Access Corporation

Entry/Exit/Validation MessagesMany times processing must be done as the user enters into or out of a data entrywindow. The Field Entry, Exit, and Validation messages allow the programmer to senda message to accomplish extra processing.

Data DictionaryProperty

Description

Field_Entry_msg Message sent before entering an item.Returning a non-zero value will stop entry into the item. Set Field_Entry_msg Field Empl.Hire_Date to Current_Date

Field_Exit_msg Message sent before exiting an item.Returning a non-zero value will stop exit from the item. Set Field_Exit_msg Field to Adjust_Ext_Price

Field_Validation_msg

From the Validation /Lookup tab page

Message sent before forward navigation from an item, it iscalled again just prior to the lock of a save operation.Returning a non-zero value will stop forward navigation/save. Set Field_Validation_msg Field Empl.Hire_Date to Current_Date

Class OrderHea_DataDictionary is a DataDictionary Set Field_Entry_Msg Field Empl.Hire_Date To Current_Date // This is our newly created procedure // It adds a default date if the field is blank and not changed Procedure Current_Date Integer iField Date dDate Boolean bChanged Get Field_Changed_State iField to bChanged If ( bChanged=0 AND dDate = 0) Begin SysDate4 dDate Set Field_Default_Value iField to dDate End End_Procedure

These messages will pass theField number and the value of thecurrent DEO.

Page 209: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 209

Entry & Exit MessagesEntry and Exit Methods are a two-step process.

Step 1

Under the“Methods” tabcreate a newprocedure.

Step 2

Under the Othertab page list theprocedure nameto send whenentering thisfield.

Note: You should NOT change the normal navigation during these procedures. If you return anon-zero value it will not allow you to enter/exit. Do not try to have it jump to a new location onscreen – this should be done by augmenting a message like Refresh or Next. Remember thesemessages will affect ALL views and should not contain code with features that should onlyapply to a single view.

Figure 168

Figure 169

Page 210: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

210 Data Access Corporation

Two Arguments are passed with Field_Entry, Field_Exit & Field_Validationmessages:

• Field Number and

• Field Current Value

Example of each (the fields in this example are not the same as our Empl file):

Set Field_Entry_msg Field Empl.Dependents to Default_Dep Set Field_Exit_msg Field Empl.Birthday to Calc_Age Set Field_Validation_msg Field Empl.Age to Check_Age … … Procedure Default_Dep Integer iField Integer iDependents // Default to one if blank, on entering If (iDependents =0) Set Field_Default_Value Field Empl.Dependent to 1 End_Procedure Procedure Calc_Age Integer iField Date dBirthday // Updates Age when Birthday field exited Integer iAge Date dToday Sysdate4 dToday Calc ((DateGetYear(dToday)) - (DateGetYear(dBirthday))) to iAge // If you haven’t had your birthday this year you must decrement iAge If ((DateGetDayofYear(dToday)) < (DateGetDayofYear(dBirthday))) Decrement iAge Set Field_Changed_Value Field Empl.Age to iAge End_Procedure Function Check_Age Integer iField Integer iAge Returns Integer // Validate Age is less then 100 If (iAge > 100) Function_Return 1 // would remain in the age window - shift+tab would work Else Function_Return 0 End_Function

Page 211: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 211

The passing of these arguments (Field_Number and Current_Field_Value) allows us tocall the same procedure from multiple fields. This example calls the same procedurefrom the Customer.First_Order_Date and Customer.Last_Order_Date fields.

Class Customer_DataDictionary is a DataDictionary ... Set Field_Entry_msg Field Customer.First_Order_Date To Default_Today Set Field_Entry_msg Field Customer.Last_Order_Date To Default_Today … Procedure Default_Today Integer iFieldnum Date dDate Integer bChanged Get Field_Changed_State iFieldnum to bChanged //has field been changed? 0=not changed If ( bChanged=0 AND dDate = 0) Begin SysDate4 dDate // put system date into dDate Set Field_Default_Value iFieldnum to dDate // displays current date to screen // but will not toggle Field_Changed_State End End_Procedure //Default_Today End_Class

Page 212: Discovering Visual DataFlex 9.1

Lesson 5 Data Dictionarys Part 1 Discovering Visual DataFlex

212 Data Access Corporation

Auto-Assigning NumbersUse this feature whenyou wish a field ineach new record to beautomatically assignedthe next incrementednumber.

Steps:

1. Select the fieldthat will be auto-assigned

2. Assign theFile.Field toincrement in theAuto Incrementform.

3. If the incrementing file is not part of the DataDictionary structure, list it as anexternal file from the Structures Tab page. This will only have to be verified if the

checkbox aboveis checked.

Figure 170

Figure 171

Step #1 Select the field

Step #3External Lockif needed

Step #2 List file.fieldto increment

For ease of use, havethese checkboxeschecked

Page 213: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 Data Dictionarys Part 1

Data Access Corporation 213

External StructureAll files that are not partof the DataDictionarystructure but will bemanually updated mustbe listed here so theywill be locked properly.

The system file must belocked during the saveoperation so we list it asan “Externally UpdatedFile”.

For optimizationpurposes we only lockthe system file on newsaves and deletes!

Example Code: Open Empl

Open SysFile

// External (System) file structure.............

Send Add_System_File Sysfile.File_Number DD_LOCK_ON_NEW_SAVE

Define_Auto_Increment Sysfile.Last_Empl_Num To Empl.Code

Note: (Everyone) This DataDictionary method supports only one auto-increment field per file.

Figure 172

Figure 173

Page 214: Discovering Visual DataFlex 9.1

Lesson 5 Lab Data Dictionarys Part 1 Discovering Visual DataFlex

214 Data Access Corporation

Lesson 5 LabDescription:

This lab creates and edits the DataDictionary (.DD) files reviewing the many items thelesson covered.

Tasks:

In this lab, we will build more features into the .DD files. Modifications that are maderequire little typing, so these modifications have not been added to the Code_Mod.TXTfile.

Building DataDictionarys for All Database Files

If DatabaseBuilder is closed– reopen it.

File | Open[[[[ Dept[[[[ Empl[[[[ TimeCard[[[[ Wk_Sum[[[[ Open

Figure 174

Page 215: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 LabData Dictionarys Part 1

Data Access Corporation 215

Setting Field Options

In the Empl File:

[[[[ Field SettingsTab[[[[ Code field[[[[ Options Tab[[[[ AutoFind[[[[ KeyField[[[[ NoPutEnter the otherfield Optionsfrom the chartbelow

Figure 175

File Field Entry OptionEmpl Soc_Sec_Number AutoFind

St CapsLockDept CapsLockPay_Type CapsLockLogged CapsLock

TimeCard Reason_Code CapsLock, RequiredDept Dept_Code AutoFind, KeyField,

CapsLock

Page 216: Discovering Visual DataFlex 9.1

Lesson 5 Lab Data Dictionarys Part 1 Discovering Visual DataFlex

216 Data Access Corporation

Setting Field Validation

This validation will be on the Empl.Pay_Rate field. If Pay_Rate does not fall within 5and 100,000 the Error “#330 Rate must be between $5 and $100,000” will be displayed.

In the Empl File:

[[[[Validation/LookupTab[[[[Pay_Rate field

Fill in the RangeFrom/To and theValidation Errorforms as shown

Figure 176

Page 217: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 LabData Dictionarys Part 1

Data Access Corporation 217

Validation Tables

Static Table

[[[[ ValidationTable Tab[[[[Pay_Type field[[[[ Static Type

Fill in the Valueand Descriptioncolumns asshown

Figure 177

Page 218: Discovering Visual DataFlex 9.1

Lesson 5 Lab Data Dictionarys Part 1 Discovering Visual DataFlex

218 Data Access Corporation

Creating Dynamic Tables is a two step process:

1. Create validate records in the Studio using the Code Maintenance view.

2. Create the Validation table in Database Builder

Step #1 Create records in the Studio using the Code Maintenance view.

Save & Close all filesin Database Builderand return to theStudio

[[[[ Workspace[[[[ Code-MasterMaintenanceFill-in & Save thefollowing reasoncode records

Close the CodeMaintenance View

Figure 178

Page 219: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 LabData Dictionarys Part 1

Data Access Corporation 219

Step #2 Create the Validation table in Database Builder

Return toDatabaseBuilder & reopenthe files – theReason Coderecords will notshow up if thefiles are notreopened

[[[[ TimeCard file[[[[ Reason_Codefield[[[[ Field Settings[[[[ ValidationTable Tab[[[[ DynamicRadio[[[[ Type ValueCombo andselect“Reasons”

Figure 179

Page 220: Discovering Visual DataFlex 9.1

Lesson 5 Lab Data Dictionarys Part 1 Discovering Visual DataFlex

220 Data Access Corporation

Setting Field Masking

[[[[ Empl file[[[[ Pay_Rate field[[[[ Field Settings[[[[ Mask Tab[[[[ Mask TypeComboBox[[[[ Currency

Complete themask setting forthe Employee &Dept files from thetable

File.Field to Mask Mask Type Custom MaskEmpl.Phone Text (###) ###-####Empl.Soc_Sec_Number Text ###-##-####Dept.Budget Currency

Figure 180

Page 221: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 LabData Dictionarys Part 1

Data Access Corporation 221

Setting Appearance TabUsing the Visual Control, we set the Pay_Type field to dbComboForm. Now wheneverwe place this field in a view, the Studio will create a dbComboForm object instead of thedefault of a dbForm. This will also make our static validation table that we just builtappear using a dbComboForm.

Within the Emplfile:

[[[[ AppearanceTab[[[[ Pay_Type field[[[[ Visual Control[[[[ dbComboForm

This will set the label. The default is the field name.

[[[[ Soc_Sec_Number field

Social SecurityNumber

Soc Sec Num

Figure 181

Figure 182

Page 222: Discovering Visual DataFlex 9.1

Lesson 5 Lab Data Dictionarys Part 1 Discovering Visual DataFlex

222 Data Access Corporation

Setting Status HelpStatus Help will display the help line at the bottom of the screen whenever the userenters this field.

[[[[ Code field[[[[ Other Tab pageIn Status Help areaType:New employees willbe assigned the nextavailable number.

Create your ownStatus Help lines for afew other fields in thefiles

Figure 183

Page 223: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 LabData Dictionarys Part 1

Data Access Corporation 223

Field_Default_Value Property

[[[[ St field

Enter FL as theDefault Value

Alternatively, we could make this a dynamic default by using the ProcedureField_Defaults under the Method tab page. The added code would look like this:

Procedure Field_Defaults Forward Send Field_Defaults //DDB-Generated-Code-Location Set Field_Default_Value Field Empl.St to Sysfile.Local_State End_Procedure // Field_Defaults

Figure 184

Page 224: Discovering Visual DataFlex 9.1

Lesson 5 Lab Data Dictionarys Part 1 Discovering Visual DataFlex

224 Data Access Corporation

Auto-Assigning NumbersWe will auto-assignEmpl.Code field byincrementing theSysfile.last_empl_numfield

[[[[ Empl.Code field

[[[[ prompt button to theright of Auto Increment[[[[ SysFile[[[[ Last_Empl_Num[[[[ OK

.

This step checks thatthe SysFile is listedcorrectly.

[[[[ Structures TabCheck that the SysFileis listed if not [[[[ 2ndbutton in the ExternalStructure Area & add it[[[[ Lock Button[[[[ Lock on New Save[[[[ OKSave All Files & returnto Studio

Figure 185

Figure 186

If the SysFile is not listed, open theSysFile and check the System Filecheckbox on the Parameters tab page.

This checkbox will do step #2 automatically

Page 225: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 5 LabData Dictionarys Part 1

Data Access Corporation 225

Changing an Object’s Class

Open theEmpl_View in theStudioOpen the ObjectProperties dialog

[[[[ Pay_TypeNote the class typeis dbForm

] Pay_Type[[[[ Change To[[[[ dbComboFormEnlarge the PayType objecthorizontally for thebutton

Compile andTest theApplication

Open the EmplView and notethe items in thechart

Figure 187

Things to Notice

Try to delete an Empl record. An error message will appear! Wewill learn how to solve this problem in the next lesson, when wecover how Saves and Deletes propagate.Create a new Empl record and note the Save validation message.Also, check that the employee code is auto-assigning from thesystem file.Check the ComboForm Validation Table on the Pay_Type fieldCheck for the Error message when Pay_Rate value is out of rangeCheck the Default Value of the state fieldStatus Help lines appear for the Empl.Code field

Page 226: Discovering Visual DataFlex 9.1

Lesson 5 Lab Data Dictionarys Part 1 Discovering Visual DataFlex

226 Data Access Corporation

Did You Discover?

1. Where in the Studio and Database Builder will a right-mouse-click call up a popupmenu?

2. What are the advantages of validation tables over creating a parent related file?

3. What are the advantages of a parent related file over a validation table.

Page 227: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 6 Lab Data Dictionarys Part 2

Data Access Corporation 227

Lesson 6Data Dictionarys Part 2

This lesson covers the more advanced topics of DataDictionarys.

Topics in this Chapter:♦ Methods Tab

♦ Options Tab

♦ Foreign Field Options

♦ Error Handling

♦ Structures Tab

♦ Cascade Delete

♦ Database Explorer

♦ Lab 6

• Methods Tab

• Structures Tab

• Initializing Auto-Assign Number

Page 228: Discovering Visual DataFlex 9.1

Lesson 6 Data Dictionarys Part 2 Discovering Visual DataFlex

228 Data Access Corporation

Methods TabThe Methods Tab allows us to add manual code, such as new procedures or modificationof existing procedures, to the DataDictionary Class. In the lab, we will be modifying theUpdate and Backout procedures to send a new message calledAdjust_Running_Empl_Total that will increment or decrement the running Employeetotal for that department. We could simplify this by eliminating theAdjust_Running_Empl_Total procedure and just put the calculation into the Update andBackout procedures but by adding the new procedure, it demonstrates how to accomplishmore complex running totals.

The list of Unaugmented Methods allows you to quickly add the most often usedprocedures and functions. Double clicking on the procedure name will create a blankprocedure ready for custom code additions

Figure 188

Page 229: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 6 Lab Data Dictionarys Part 2

Data Access Corporation 229

Options Tab

The Options tabpage displaysvarious data-dictionary optionsthat apply acrossall fields in thefile.

Foreign FieldOptionsWhen entering new records into a database the field options from the Field Setting /Options page are enforced. When the data is not of the main file of a view (but data ofthe related parent) it is common that additional options are needed. These options arereferred to as Foreign Field Options and are separated into three groups: Key Fields,Indexed Fields and Default Fields (which include all other fields).

When entering new records for the Empl file, you would want to be able to enter anEmployee’s Soc_Sec_Number, which is an index field. However, in a Time Card view,(where the Empl file is the parent file and not the main file that is being saved) youmight wish to find on this field but you would never wish to change it. This is why youwill use the Find Required and NoPut options on the Indexed Foreign Field Options.

Error HandlingThis is the general error message for all validates that fail and do not have an individualfield error message set (Field Setting/Validation Lookup tab page). The error istriggered when one of the following validations fail: Simple Validation, RangeValidation, Validation Table, or an incorrect Checkbox Value. These Validation ErrorMethods should be a function coded at the class level.

Figure 189

Page 230: Discovering Visual DataFlex 9.1

Lesson 6 Data Dictionarys Part 2 Discovering Visual DataFlex

230 Data Access Corporation

Structures TabMany tasks require the DataDictionarys to communicate among themselves. An exampleis the save operation that propagates up the structure so all running totals are updated. Adelete operation propagates down to delete child records (and then up to update runningtotals). The DD structure linking is normally always the same as the file structure.Therefore, the Magic Wand buttons will check the file relationships and connect missingparent/child files accordingly. The wand will only add to the list, it will not remove filesfrom the list. Therefore, remove all files before using the magic wand.

The Delete andSave StructureMode is used toverify the DataDictionaryStructure. It isnormally safestto leave theseradios tovalidate once(the first time).

Example Code:

Set Main_File To Empl.File_Number Set Foreign_Field_Options DD_KEYFIELD To DD_AUTOFIND DD_NOPUT DD_FINDREQ Set Foreign_Field_Options DD_INDEXFIELD To DD_NOPUT DD_FINDREQ Set Foreign_Field_Options DD_DEFAULT To DD_DISPLAYONLY // Child (Client) file structure................ Send Add_Client_File Timecard.File_Number Send Add_Client_File Wk_Sum.File_Number // Parent (Server) file structure............... Send Add_Server_File Dept.File_Number // External (System) file structure............. Send Add_System_File Sysfile.File_Number DD_LOCK_ON_NEW_SAVE

Figure 190

Page 231: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 6 Lab Data Dictionarys Part 2

Data Access Corporation 231

Cascade Delete

Uncheck theCascade Deleteoption on theEmpl databasetable

Save the file

For tax purposes,we should neverdelete anemployee thathas child(TimeCard)records.

Example Code:

If you try to delete a parent record, which has related child records, this error will begenerated:

“4140” (Cannot delete-related records exist)

Figure 191

Set Cascade_Delete_State to False //unchecked

Check this option to delete all related childrecords whenever a delete is performed.

Unchecking this option will abort thedeletion if any related child records exist.

Page 232: Discovering Visual DataFlex 9.1

Lesson 6 Data Dictionarys Part 2 Discovering Visual DataFlex

232 Data Access Corporation

Database ExplorerThis useful utility can be accessed directly from the Start | Programs | Visual DataFlexmenu or from the Studio’s Database pulldown menu. It will allow you to view andchange your raw data stored in your database tables.

To allow changes to the database tables you must first change a default configurationsetting.

From the Studio

[[[[ Database |DatabaseExplorer

[[[[ Tools |ConfigureEnvironment

[[[[ Open/setdatafilesreadonly(uncheck it)

[[[[ Apply[[[[ Close

Look around atthe manyfeatures in this

utility

You will find MANY uses for this utility. Here are just a FEW tasks that DatabaseExplorer can do:

• View and change raw data stored in your database tables

• Zero the database tables of test data before deploying the application

• Export data to ASCII or XML format

Figure 192

Page 233: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 6 Lab Data Dictionarys Part 2

Data Access Corporation 233

Lesson 6 Lab

Description:

Creating more Business Rules within the DataDictionary.

Tasks:

Methods TabFirst, we willcreate blankprocedures:

Within the DBB,open the Emplfile:

[[[[ Methods TabExpand theUnaugmentedMethods Tag/ Backout/ Update

Figure 193

Page 234: Discovering Visual DataFlex 9.1

Lesson 6 Lab Data Dictionarys Part 2 Discovering Visual DataFlex

234 Data Access Corporation

If theCode_Mod.txtfile is not open –Open it in theeditor (File |Open File).

Add the newprocedure andmodify theUpdate andBackoutprocedures bycutting & pastingthe changes fromthe Code_Mod.txtfile

// this is added to the Methods tab of the Empl DD // Adjust_Running_Empl_Total: Procedure Adjust_Running_Empl_Total Integer iOne_More Calc (Dept.Number_of_Empl + iOne_More) to Dept.Number_of_Empl End_Procedure // Adjust_Running_Empl_Total // This is added to the Update Procedure of the Empl DD Send Adjust_Running_Empl_Total 1 // This is added to the Backout Procedure of the Empl DD Send Adjust_Running_Empl_Total -1

Figure 194

Page 235: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 6 Lab Data Dictionarys Part 2

Data Access Corporation 235

Another business rule is in the TimeCard file. Whenever a TimeCard record is created,we need to update the status of the employee to Logged In or Logged Out.

Open theTimecard file

[[[[ Methods Tab

Expand theUnaugmentedMethods Tag

/ Creating

Modify theprocedure asshown

Save & Close file

// This is added to the Creating Procedure of the TimeCard DD Move TimeCard.In_or_Out to Empl.Logged

Figure 195

Page 236: Discovering Visual DataFlex 9.1

Lesson 6 Lab Data Dictionarys Part 2 Discovering Visual DataFlex

236 Data Access Corporation

Structures TabThe Required Child and Required Parent list should match our file relationship structure.

This step wasaccomplished inLab 2 and canbe skipped ifdone in that lab

If there are anyfiles listed in the“RequiredChild/Parentfile” areasdelete themusing the deletebutton.

[[[[ Magic Wand inthe RequiredChild files

[[[[ Magic Wand inthe RequiredParent files

Repeat this stepfor all filesSave and Closeall the files

Figure 196

Page 237: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 6 Lab Data Dictionarys Part 2

Data Access Corporation 237

Initializing Auto-Assign NumberDatabase Explorer is a separate utility that enables us to view and modify database tablecontents. We will use it here to quickly adjust the raw data in our SysFile table.

This lab has just added an auto increment feature that will increment the current numberin the SysFile.Last_Empl_Num field and assign it to the Emp.Code field of the nextnewly saved record. We have existing records in the Employee file that could create aproblem. If the SysFile.Last_Empl_Num is set to 10 it would try to assign 11 to the nextsaved record. If there was already a record 11 in our database, it would give a“Duplicate records not allowed in file” error.

To avoid duplicating an Empl number we will set the Sysfile.Last_Empl_Num field to anumber larger than any saved record in the Empl file.

Return to the Studio

Database |DBExplorer[[[[ Empl FileNote the largest EmplCode number[[[[ SysFileEnter a CompanyName and Local Statethen in theLast_Empl_Num entera number larger thanany saved Empl.Coderecord

This is a system fileso it should only haveone record created!

Save and Exit

Figure 197

Page 238: Discovering Visual DataFlex 9.1

Lesson 6 Lab Data Dictionarys Part 2 Discovering Visual DataFlex

238 Data Access Corporation

Did You Discover?

1. When using the magic wand button in the Structures tab page of Database Builder –will it remove unneeded files from the required Child/Parent list?

2. What is the difference between the Validation Error No. & Text on the Field Setting |Validation/Lookup Tab and Validation Error No. & Text on the Options tab?

3. In Database Builder under the METHODS tab if you select a method from theUnaugmented list what happens to the Unaugmented and Implemented lists?

Page 239: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 7 Connecting Parts

Data Access Corporation 239

Lesson 7Connecting Parts

Music will never be heard from a multi-unit stereo system if the cables between units areconnected incorrectly. This lesson talks about DataDictionarys (DDs) andDataDictionary Objects (DDOs) and the connections they have. Proper connections ofthe DDs and DDOs in your application are crucial to it operating correctly.

Topics in this Chapter:♦ Differences between the DD Class files and the DDOs

♦ Connecting DDs to DDs within the DataDictionary Class

♦ Connecting DDOs to DDOs within the View

♦ Connecting DEOs to DDOs within the View

♦ Object Nesting

♦ Encapsulation of DDO Structure

♦ Lab 7

• Completing the DDO structure of our Views

Page 240: Discovering Visual DataFlex 9.1

Lesson 7 Connecting Parts Discovering Visual DataFlex

Differences between the DD Class Files and DDOs

1.) DataDictionary Classes (.DD files) - Classes are “tools”:

Using Database Builder, we create a .DD file for every database file. These areSubclasses of the DataDictionary Class.

DataDictionary

Additions in these .DDfiles will affect all views

// Wk_Sum.DD File

Class Wk_Sum_DataDictionary is a

End Class

// TimeCard.DD File

Class TimeCard_Data

DataDictionary

DataDictionary

Dictionary is a

End Class

// Empl.DD F

Class Empl_D

240

We build the bu

DataDictionary

ile

ataDictionary is a

End Class

// Dept.D

Class Dep

siness rules in t

D File

t_DataDictionary is a

End Class

Data Access Corporation

hese files created in Database Builder utility.

Figure 198

Page 241: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 7 Connecting Parts

2.) DataDictionary Objects in the Views:

In our View, we have DDOs that are built from the DataDictionary Class that we createin Database Builder Utility.

OR Empl_View

OR Dept_View

ry

Additions here onlyaffect this single view

// Empl_View.VW

ACTIVATE_VIEW Activate_Empl_View F

Object Empl_View is a dbView

Set Label to "Empl_View"

Set Size to 210 410

Set Location to 6 7

Object Dept_DD is a Dept_DataDictionar

Set Status_Help Field Dept.Code to ;

"F7 & F8 will find all dept records“

End_Object // Dept_DD

Object Empl_DD is a Empl_DataDictiona

Set DDO_Server to Dept_DD

End_Object // Empl_DD

Set Main_DD to Empl_DD

Set Server to Empl_DD

Object Container1 is a dbContainer3d

Set Size to 60 393

Set Location to 5 5

Data Access Corporation

y

ry

// Dept_View.VW

ACTIVATE_VIEW Activate_Dept_View F

Object Dept_View is a dbView

Set Label to "Dept View"

Set Size to 170 354

Set Location to 6 6

//AB-DDOStart

Object Dept_DD is a Dept_DataDictiona

End_Object // Dept_DD

Set Main_DD to Dept_DD

Set Server to Dept_DD

Object Container1 is a dbContainer3d

Set Size to 145 335

Set Location to 5 5

Object Dept_Code is a dbForm

Entry_Item Dept.Dept_Code

241

Page 242: Discovering Visual DataFlex 9.1

Lesson 7 Connecting Parts Discovering Visual DataFlex

242 Data Access Corporation

We move the business rules into our view by adding DDOs through the database Selectortool:

Figure 199

Page 243: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 7 Connecting Parts

Connecting DDs to DDs within the DataDictionary ClassRelated files need their DataDictionarys connected. To properly function, there must bea two-way communication between the DataDictionarys.

Dept.DD

Empl.DD

:

ween

one way.

ructure:

DD to DDd done withnt_Filever_File

File Relationships

The connection betchild-to-parent filerelationship is only

DataDictionary St

The connecting of is bi-directional anthe Send Add_Clieand Send Add_Sermessages.

Data Access Corporation 243

Wk Sum.DDTimeCard.DD

//Sample code showing these methods:

Class Empl_DataDictionary is a DataDictionary

Procedure Define_Fields

// Child (Client) file structure................

Send Add_Client_File Timecard.File_Number

Send Add_Client_File Wk_Sum.File_Number

// Parent (Server) file structure...............

Send Add_Server_File Dept.File_Number

Page 244: Discovering Visual DataFlex 9.1

Lesson 7 Connecting Parts Discovering Visual DataFlex

244 Data Access Corporation

This is where we make the DataDictionary to DataDictionary connection.

Code generated in the Empl.DD file will look like this:

: // Child (Client) file structure................ Send Add_Client_File Timecard.File_Number Send Add_Client_File Wk_Sum.File_Number // Parent (Server) file structure............... Send Add_Server_File Dept.File

Figure 200

Page 245: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 7 Connecting Parts

Data Access Corporation 245

Connecting DDOs to DDOs within the ViewRelated files need their DDOs connected. In order for our database operations to performcorrectly, we link our DDOs together much like our file relationship structure. Saveoperations propagate up and Deletes propagate down. Therefore, both connections arenormally made.

The connecting of DDO to DDO is done by setting the DDO_Server property. Weconnect DDOs when they should act in a coordinated manner. As a general rule, thechild-to-parent file updating links will match the child-to-parent relationships.

Dept

Wk_Sum

Empl

TimeCard

Page 246: Discovering Visual DataFlex 9.1

Lesson 7 Connecting Parts Discovering Visual DataFlex

246 Data Access Corporation

DataDictionary Object Structure:

Once an updating dependency is established, the DDOs "know" about each other and cancommunicate directly among one another.

DEFERRED_VIEW Activate_Order_Entry FOR ; Object Order_Entry is a dbView … Object Dept_DD is a Dept_DataDictionary End_Object // Dept_DD Object Empl_DD is a Empl_DataDictionary Set DDO_Server to Dept_DD End_Object // Empl_DD Object TimeCard_DD is a TimeCard_DataDictionary Set DDO_Server to Empl_DD End_Object // TimeCard_DD Object Wk_Sum_DD is a Wk_Sum_DataDictionary Set DDO_Server to Empl_DD End_Object // Wk_Sum_DD

Page 247: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 7 Connecting Parts

Data Access Corporation 247

Manual Steps to create a DataDictionary Object Structure in the Order Sample:

Step 1 Code an object for each file. Start at the top of the file structure, andwork from left to right and from top to bottom. Listing the DDOs in thisorder will eliminate forward reference problems of referencing a DDOin a Server property before the object declaration.

Step 2 Add the required DDO_Server properties. Each child file will have aServer property for each of their parents

Step 3 Add a constraint block in the child DDO if needed! Not all child filesshould be constrained. Think about your application and add theconstraints where they are required.

Connecting DDOs within the Studio is done from the Database Selector Tool andpressing the DDO Tree button.

Figure 201

Since the Main DDO isOrderHea, all children fileswill be constrained

Page 248: Discovering Visual DataFlex 9.1

Lesson 7 Connecting Parts Discovering Visual DataFlex

248 Data Access Corporation

Connecting DEOs to DDOs within the ViewIn order for our views to operate correctly, each DEO should have a DDO that servicesit, during Finds, Clears, Saves, and Deletes.

The DEO to DDO connection is made on the Database tab in the Object Properties Tool.

If a direct server is not set, then the parent object’s server (Indirect server) is used. Aparent object is just the object in which the current object is contained.

Figure 202

Page 249: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 7 Connecting Parts

Data Access Corporation 249

The Server property is what links the DEOs to their DDO Server.

DataDictionary Objects(DDOs) are objects that actas an interface between thedatabase file and the DataEntry Objects. They areobjects built from thefilename_DataDictionaryclass that we created usingDatabase Builder.Therefore, they will knowabout all the business ruleswe created.

Data Entry Objects,(DEOs) are objects thatallow data entry, such asdbForms, dbGrids, anddbEdits.

Object Customer_DD is a Customer_DataDictionary End_Object // Customer_DD Object Cust_Name is a dbForm Set Server to Customer_DD End_Object // Cust_Name Object Cust_Address is a dbForm Set Server to Customer_DD End_Object //Cust_Address Object Cust_City is a dbForm Set Server to Customer_DD End_Object // Cust_City

Page 250: Discovering Visual DataFlex 9.1

Lesson 7 Connecting Parts Discovering Visual DataFlex

250 Data Access Corporation

Object NestingNesting of Objects is the actual physical positioning of one object inside another objectin the source code. The Studio tool “Controls Palette” has data containers that are usefulin grouping data aware objects.

Notice here that by setting theserver in the parent datacontainer object we do notneed to set it in the individualdata aware objects

DDOs should never containDEOs.

Reasons for nesting DEOs:

• Navigation / Visual Design Changing the cursor navigation through the objectsby adding container objects. Organizing related fields inside a container willallow the use of the F6 key (the switch accelerator key) to jump to the nextcontainer and back.

• Delegation of Messages (i.e.; the setting of the server in the data containerindirectly sets the server of the nested dbForms)

Object Customer_DD is a Customer_DataDictionary End_Object // Customer_DD Object Customer_Info is a dbContainer3d Set Server to Customer_DD Object Customer_Name is a dbForm End_Object // Cust_Name Object Customer_Address is a dbForm End_Object // Cust_Address Object Customer_City is a dbForm End_Object // Cust_City End_Object // Customer_Info

Since these objects do not specificallyset the Server property (DirectServer), they will use their parentobject’s server (Indirect Server)

Direct Server specificallyset in this object

Page 251: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 7

Data Access Corporation 251

Encapsulation of DDO StructuresIn the prior examples, we saw each View having DDOs and DEOs that connect by wayof the SERVER property. Data Entry Objects in each view are served byDataDictionary Objects within their own view. This is what makes each view operateindependently of all other views!

Views should be independent separate units!

If the objects are using different DDOs, then each will work independently of the other.

Figure 203

Different Customer recorddisplaying in each view.This is what we want!

Page 252: Discovering Visual DataFlex 9.1

Lesson 7 Lab Connecting Parts Discovering Visual DataFlex

252 Data Access Corporation

Lesson 7 LabDescription:

Checking the DDO structure of our views so they operate correctly.

Tasks:

Completing the DDO Structure of Our ViewsIn previous lessons, we discovered that we could add records to our views but we couldnot delete records. In this lesson we covered how important the connections betweenDDOs are for the operation of the view. We also learned that Saves propagate up andDeletes propagate down.

Open our three views andfrom the DatabaseSelector tool click theDDO tree button

Check to be sure that theDataDictionarys are alllisted (except for SysFile)and that the main DDO iscorrectMain DDO of Dept View isDeptMain DDO of Empl View isEmplMain DDO of Dept/Empl isDept

Correct anything that maybe incorrect.

Compile a view andcheck that you are able todelete records.

Figure 204

Page 253: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 7 Lab Constraints

Data Access Corporation 253

Did You Discover?

1. If you want two views to always display the same records from the database tables,you should?

Page 254: Discovering Visual DataFlex 9.1

Lesson 7 Lab Connecting Parts Discovering Visual DataFlex

254 Data Access Corporation

Page 255: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 8 Constraints

Data Access Corporation 255

Lesson 8Constraints

Constraining the DataDictionarys will limit the displaying of the records to meet thecriteria of the constraint.

Topics in this Chapter:♦ Constraining Records

♦ Constrain_File Property

♦ OnConstrain Procedure

♦ Lab 8

• Building Constraints in Selection Lists

• Building Constraints that Change

Page 256: Discovering Visual DataFlex 9.1

Lesson 8 Constraints Discovering Visual DataFlex

256 Data Access Corporation

Constraining RecordsConstraining DataDictionary Objects will filter the records that they display.

There are two basic types of Constraints:

• Constrain_File Property for Relational Constraints

• OnConstrain Procedure

Constrain_File Property

When is a relational constraint needed?

We constrain the view so only related child records of the parent can be seen. Thisconstraint is needed in some views and not desired in others.

Page 257: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 8 Constraints

Data Access Corporation 257

Needs a Constraint

In this view, wewant the table tofill only withEmployees (childrecords) that arerelated to the Dept.(parent record).

The Studio will setthis constraint foryou, based on theMainDataDictionary ofthe View.

The figure showshow to set & viewthis constraint inthe Studio.

Figure 205

Figure 206

Page 258: Discovering Visual DataFlex 9.1

Lesson 8 Constraints Discovering Visual DataFlex

258 Data Access Corporation

Does Not need a Constraint

Here we do notwish to limit theviewing of childrecords (Empl)to only thechildren of thefound parentrecord (Dept).

If we didconstrain theEmployee file,after finding thisrecord all otherfinds on anyemployeeindexes wouldonly find TechEmployeerecords.

Notice here there isno constraint.

Figure 207

Figure 208

Page 259: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 8 Constraints

Data Access Corporation 259

Constraining is most commonly done on a child file to show only the related records ofthe parent record currently shown. This type of relational constraint can beaccomplished by a property setting or by an OnConstrain procedure.

Object Empl_DD is a Empl_DataDictionary Set Constrain_File to Dept.File_Number // or replacing the above property with the following procedure will do the same thing // Procedure OnConstrain // Constrain Empl Relates to Dept // End_Procedure End_Object // Empl_DD

Page 260: Discovering Visual DataFlex 9.1

Lesson 8 Constraints Discovering Visual DataFlex

260 Data Access Corporation

OnConstrain ProcedureWe can use constraints to restrict the database viewing in many ways.

Here we limit the view to only TimeCard records with a date greater than 01/01/2000

Multiple Constrain Commands:

Here we limit the view to only TimeCard records with dates greater than 01/01/2000 andEmpl_Code that are greater than 250. If possible, the constraint listed first should be theprimary segment of an index in order to increase performance. It also should be the mostlimiting constraint.

Avoid Expressions:

The above example can also be written like this, but because of the use of expressions itwould not be optimized. For this reason avoid using the “AS” syntax whenever possible.

Procedure OnConstrain Constrain TimeCard.Date GE 01/01/2000 End_Procedure

Procedure OnConstrain Constrain TimeCard.Date GE 01/01/2000 Constrain TimeCard.Empl_Code GE 250 End_Procedure

Procedure OnConstrain Constrain TimeCard as ((TimeCard.Date >= 01/01/2000) and ; (TimeCard.Date <= 06/30/2000)) End_Procedure

Procedure OnConstrain Constrain Timecard as ((Empl.Dept = “TECH”) or ; (Empl.Dept = “PROD”)) End_Procedure

Page 261: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 8

Data Access Corporation 261

Steps to Changing Constraints on the Fly! (While the program runs)

1. Create a property. A property will keep its value as long as the object persists.Properties will be covered in detail in a later lesson.

2. Create an interface that will allow the user to alter the value of the property.

3. Send the message Rebuild_Constraints to the DataDictionary every time the valueof the property changes.

A field in a System File could also be used, but since this field could change it is not avery good method, unless you have a method of sending Rebuild_Constraints wheneverthe field is changed.

Property Boolean pbLimitView False ... Procedure OnConstrain If (pbLimitView(Self)) Constrain Customer.State EQ "FL" End_Procedure // An interface (such as a button that would pop up a form) would be needed to // change the value of the property and Rebuild_Constraints would have to be // sent whenever the property was altered. If the DEO was a dbGrid then // Beginning_of_Data may be required.

... Procedure OnConstrain Constrain Customer.State EQ SysFile.Local_State End_Procedure

Page 262: Discovering Visual DataFlex 9.1

Lesson 8 Lab Constraints Discovering Visual DataFlex

262 Data Access Corporation

Lesson 8 LabDescription:

Modifying the Employee Selection List to constrain the viewing of the records to onlyactive employees.

Tasks:

Constrain the selection list so only active Employees (employees that have theirTermination_Date field blank) will be shown. This can be accomplished in the Studio byopening the Empl.SL file and modifying the DDO.

Page 263: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 8 Lab Constraints

Data Access Corporation 263

Building Constraints in Selection ListsWithin the Studio

File | Open Component[[[[ “Lookups” from thecomboform[[[[ Employee Lookup[[[[ OK buttonAdd the State &Term_Date fields[[[[ Code Explorer[[[[ Empl_DDCut & paste codemodifications fromCode_Mod.txtSave & close thislookup

File | Open Component[[[[ “Views” from thecomboform[[[[ Employee View[[[[ OK buttonCompile & TestEnter a TerminationDate for an Employee &Save – test that it doesnot show in theSelection List

The selection list will no longer show terminated employees.

//------------------------------------------------------------------- // Only show Employees that are not terminated //------------------------------------------------------------------- // Add to the Empl_DD in the Employee Lookup Procedure OnConstrain Constrain Empl.Term_Date EQ 0 End_Procedure

Figure 209Add the Stateand Term_Datefields

Page 264: Discovering Visual DataFlex 9.1

Lesson 8 Lab Constraints Discovering Visual DataFlex

264 Data Access Corporation

Building Constraints that Change

Open theEmployee View[[[[ Empl_DDCut & paste codemodifications fromCode_Mod.txt

Compile & TestUse F7 & F8 keysto view recordsmaking sure onlyemployees with thelocal state appearChange a StateField to somethingother than the localstate & saveYou should nolonger be able tofind the recordusing the F7&F8keys

Use Database Explorer to check the Empl.St field to ensure that the constraints are onlyshowing the correct data.

//--------------------------------------------------------------------------------------- // Only show Employees that match the default state in the SysFile //------------------------------------------------------------------------------------- // Add to the Empl_DD in the Empl_View Procedure OnConstrain Constrain Empl.St EQ SysFile.Local_State End_Procedure

Thus if this application were deployed in Florida, the value of the Local_State fieldwould be “FL”, however in California it would be “CA”.

Figure 210

Empl DD

Page 265: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 8 Lab Constraints

Data Access Corporation 265

Did You Discover?

1. Open any Lookup List (Selection List - SL file) in an editor. The code begins withCD_Popup_Object. What does the “CD” stand for?

Example Code:

CD_Popup_Object Empl_SL is a dbModalPanel

2. If you look in the properties of the selection list, the “Ordering” property (whichindex to use) is set to zero. Why is that?

3. After the constraint in the Employee View is added, can you save an employee thathas a termination date greater than zero?

4. How could you make the Selection List use the same DataDictionary constraints asthe invoking view? (without copying or moving the OnConstrain code from one tothe other)

Page 266: Discovering Visual DataFlex 9.1

Lesson 8 Lab Constraints Discovering Visual DataFlex

266 Data Access Corporation

Page 267: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 267

Lesson 9All about Messages

Love may make the world go round but it is “Messages” that make Object OrientedPrograms go round. The cascade of messages being sent is what makes everythinghappen in an OOP program. Developers must be able to understand and send messagesin order to make their programs operate.

Topics in this Chapter:♦ Link Between Messages

♦ Triggering Messages

♦ Focus Object & Current_Object

♦ Sending a Message

♦ Access Methods

♦ Local Variables

♦ Forwarding & Delegating

♦ Self Access Method

♦ Relaying a Message

♦ Neighborhoods

♦ Broadcast Command

♦ Delegate Send

♦ Documentation - Commands

♦ Changing Behavior of Messages

♦ Augmenting / Canceling/Overriding / Adding Messages

♦ Documentation - Procedures

♦ Documentation-Class Hierarchy

♦ On_Key Commands

♦ Properties (creating)

♦ Properties (Set Get Commands)

♦ Object Properties

♦ Itme Properties

♦ Procedures

♦ Functions

♦ Functions as Expressions

♦ Categories of Messages

♦ Delegation & Container Objects

♦ “On” Procedures (Events)

♦ Using OnClick / OnActivateApp / OnMaxText Events

♦ Creating Buttons

♦ Creating Checkboxes & Radios

♦ Lab 9

• Checking the Servers

• Properties

• Highlighting a Grid Row

Page 268: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

268 Data Access Corporation

The Link Between Messages and Procedures/FunctionsObject Oriented programs send messages to accomplish tasks. These messagescorrespond to procedures or functions with the same name.

OBJECT ORIENTED EXAMPLE:

Send Sound_Alarm // Jumps to a procedure called Sound_Alarm

Procedure Sound_Alarm

Send Bell

Send Bell

Send Bell

End_Procedure

Matching message nameand Procedure name

Page 269: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 269

Triggering Messages (Event Driven)Object oriented programming is ideally suited for supporting “Event Driven”environments. An event has to occur in order for anything to happen.

Event Message Sent triggers other messages

SendsRequest_Savemessage

PressingF2 key Procedure Request_Save

Which Sends

Many other messages

Page 270: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

270 Data Access Corporation

Focus Object & SelfCurrent Object and Focus Object are often confused, mainly because they are often thesame.

• Focus Object is the object interacting with the current user.

• Self is the object where the processing is taking place at that instant. There is aproperty Self that returns the Object ID of the current object (a synonym for Selfis Current_Object).

If the user’s cursor were sitting in the Customer_State dbForm, both Current and FocusObjects would be this Customer_State dbForm. If the user presses the Save Key, theFocus Object remains the same and the Current Object changes according to whichobject is processing the many messages that cascade from the Request_Save message.

You can reference Self in order to get the Object_ID of the current object.

Move Self to hoCurrentObj

Page 271: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 271

Sending a Message

Defaulting to the Current_Object

Sending the message “my_routine” without referencing an object will cause the messageto be sent to the current object (the object currently in control).

Send My_Routine

Directing a message to a specific object

In order to send a message to a specific object, we need the object’s ID. Here we wish tosend the My_Routine message to the oEmplView object. It will find an object namedoEmplView, return the object ID, and then send the My_Routine message to that objectID.

Send My_Routine of oEmplView

You may see old code that uses the syntax “Send MessageName to ObjectID” instead of“Send MessageName of ObjectID”. For consistency, the “of” syntax works better sinceit is the same for properties and procedures and functions.

Set MyProperty of oObjectName to XYZ

Send MyMessage of oObjectName

Get MyFunction of oObjectName to iVal

Note: Code Editor Hint: After you type “Send MessageName of “ the editor will popup a list ofobject names of all objects in the current component.

Page 272: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

272 Data Access Corporation

Access MethodsAccess methods are used to direct a message to a particular object. Access methods arefunctions, which return the object ID.

Types of Access Method:

• Object Referencing

• Current_Object / Self Access Method

• Full Access Method

Object Referencing

This is the simplest and recommended method. You simply list the object name and itwill determine the object ID and send the message to the correct object.

Send Change_Label of oCustomer_Phone

Self or Current_Object Access Method:

This is an older method that required you to add the “current_object or “Self” keywords.

Send Change_Label of (oCustomer_Phone(Self)) // Or Send Change_Label of (oCustomer_Phone(current_object))

Full Access Method:

This method involves listing the full nesting structure of the objects. Using this methodis lengthy and to be avoided if possible.

Send Change_Label of (oCustomer_Phone(oCustomer_View(oClient_Area(oMain(Desktop)))))

This command is read: Send Change_Label to oCustomer_Phone child ofoCustomer_View child of oClient_Area child of oMain child of the Desktop

Note: If you are maintaining old code you may run into the Name_Object access method. Thisis an obsolete command and should not be used.

Page 273: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 273

Forwarding & Delegating (location of methods)

Forward and Delegate are prefixes that can be added to the Send, Get, or Set commands.Simply sending a message will starts with the current object. If we Forward Send themessage it will start looking for the message in the parent class. If we Deligate Send themessage it will start looking for the message in the parent object.

When a message is sent to an object, it does not stop there if the object does not have acorresponding method (procedure or function). It loops through a three-step cycle tryingto find the method. The message cycles through the three steps repeatedly, trying to finda method with the same name as the message being sent. When it finds the method, themethod is executed. These three steps are:

1. Look within the current object

2. Forward the message (forward the message up the inheritance path,through classes)

3. Delegate the message (pass the message through to the parent object).Delegation does not happen automatically in other OOP languages.DataFlex’s default is to automatically delegate.

The next page will demonstrate what will happen if we send a message that does notexist. We will get an error at the desktop but the next page shows all the steps.

Page 274: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

274 Data Access Corporation

Read from the bottom boxes up. Use DFAllEnt.pkg Use CUSTOMER.DD DEFERRED_VIEW Activate_Customer FOR ; Object oCustomer_View is a dbView Object oCustomer_DD is a Customer_DataDictionary End_Object // oCustomer_DD Object oCustomer_Number is a dbForm Entry_Item Customer.Number End_Object // oCustomer_Number Object oCustomer_Name is a dbForm Entry_Item Customer.Name End_Object // oCustomer_Name Object oCustomer_TD is a dbTabDialog Object oAddress_TP is a dbTab page Object oCustomer_Address is a dbForm Entry_Item Customer.Address End_Object // oCustomer_Address … End_Object // oAddress_TP Object oComments_TP is a dbTab page Set Label to "Comments" Object oCustomer_Comments is a dbEdit Entry_Item Customer.Comments On_Key Key_Alt+Key_P send Print_Label End_Object // oCustomer_Comments End_Object // oComments_TP End_Object // oCustomer_TD CD_End_Object // oCustomer_View

Step D1: Check Current_Object

Step D2: Forward

dbView Up Class Hierarchy

Step D3: Delegate to Parent Object

Step C1: Check Current_Object

Step C2: Forwarding

dbTabDialog Up Class Hierarchy

Step C3: Delegate to Parent Object

Step B1: Check Current_Object

Step B2: Forwarding

DbTab page Up Class Hierarchy

Step B3: Delegate to Parent Object

Final Step Runtime Error!

Invalid message MSG_Print_Label

Status <<98>> on line #25119

Pressing Alt-P

Sends the Print_Label message

Step A1: Check Current Object

Step A2: Forwarding

dbEdit Up Class Hierarchy

Step A3: Delegate to Parent Object

Page 275: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 275

Self Access Method Works by DelegationIn the above example if the oCustomer_Comments object wanted to send a message tothe oCustomer_DD DataDictionary this is what would happen.

Send Clear of oCustomer_DD // Object Referencing Access Method

Steps:

1. The oCustomer_DD is first evaluated to find the Object_ID. These are the steps tofind the object ID of oCustomer_DD.

• oCustomer_Comments do you have a child object called oCustomer_DD? No,then forward & delegate

• oComments_TP, do you have a child object called oCustomer_DD? No, thenforward & delegate

• oCustomer_TD, do you have a child object called oCustomer_DD? No, thenforward & delegate

• oCustomer_View, do you have a child object called oCustomer_DD? Yes, thenreturn the Object ID. This will be something like 97.

2. Send Clear of 97 // (97 = the returned Object ID number)

Optimizing your code:

If many messages are to be sent to the same Object it is more efficient to place the objectID into a local variable and send the messages to that variable.

Procedure DoIt Integer hoObjID // Object ID hanble Move oCustomer_DD to hoObjID Send Clear of hoObjID Send Find of hoObjID First_Record End_Procedure

Page 276: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

276 Data Access Corporation

Relaying a Message (Breaking Encapsulation – sort of…)

As noted above, Self is a recommended access method. It will allow us to send messagesto sibling objects, child objects or any object in our delegation path. It however will notallow us to send a message to nested objects of a sibling object or to a grandchild object.This may sound like a bad thing at first, but in reality, it is enforcing encapsulation. Thatis a good thing! We should not be sending messages to these encapsulated objects (onlyto sibling objects, our children objects, or objects in our delegation path).

Messages should NOT flow directly

in these paths

Object oParent

Object oSibling

Object oChild

Object oGrandchild

Page 277: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 277

In our example, the grandchild is an edit object displaying a large text field. If the parentobject wanted the grandchild to jump to the top of the text field, the Beginning_of_Datamessage would be sent to the grandchild.

To correctly send a message without breaking encapsulation – we relay the messagedown to the inner object.

Object oParent ... Send Update_Your_Child of oChild ... Object oChild ... Procedure Update_Your_Child Send Beginning_of_Data of oGrandchild End_Procedure Object oGrandchild is an Edit .... (Beginning_of_Data is received and the Cursor is sent to the top of the Data in this object) End_Object End_Object Object oSibling End_Object End_Object

Sending messages will be made easier when we use neighborhoods!

Page 278: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

278 Data Access Corporation

NeighborhoodsAs you can see from the above topics – sending a message can sometimes becomedifficult. Neighborhoods are used in a limited (almost exclusively by visual objects) butvery useful way. Their main purpose is to hide visual containers. This will makesending messages MUCH easier. Neighborhoods will find the objects that youpreviously could not find by flatting out the visual container objects.

Everything we have covered so far in this lesson still applies. The only difference is theFIRST neighborhood found – if it were a public neighborhood, it would check its list ofneighborhood objects.

Each object has a peNeighborhood property that is set to one of three settings. Thisproperty is available through the Studio’s Object Properties dialog.

• nhPublic: This will flag the object (views, tab-views, modal dialogs) as a publicneighborhood, and will maintain a list of neighborhood objects.

• nhPrivate: This will flag the object (controls, arrays, reports, etc.) as a privateneighborhood and will not maintain a neighborhood list. This is the default formost objects and is the standard black box theory of OOP. This theory statesthat objects are encapsulated by their parent’s black box (will not be accessibleto outer objects). Private neighborhood objects will register themselves in theirparent’s neighborhood but will STOP their child objects from registeringthemselves in a neighborhood (which will make the children hidden).

• nhNo: This setting is used for visual containers. They will register themselvesin their parent’s neighborhood and allow their child objects to also registerthemselves in the neighborhood.

Page 279: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 279

How objects become part of a neighborhood list:

When child objects are created, they will find the first parent object that is aneighborhood (public or private, but only the first neighborhood). If it is a publicneighborhood, it will register itSelf in the neighborhood list.

Note: Neighborhoods do not support duplicate object names (only one duplicate name willappear in the neighborhood list).

Object oView is a dbView

Object oContainer1 is a dbContainer

Object oContainer2 is a dbContainer

Object oForm1 is a dbForm

Object oArray

Public Neighborhood

Member List:

• oContainer1

• oForm1

• oContainer2

Neighborhood set tonhPrivate

Notice it’s childrenare not listed in thepublic neighborhood

Neighborhoodset to nhNo

Object oForm2

Page 280: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

280 Data Access Corporation

Broadcast CommandThe broadcast command allows you to quickly send messages to a group of nestedobjects.

Broadcast Send Do_It //Will send the message to all immediate child objects. Broadcast turns the normal delegation off. Broadcast Recursive Send Do_It //Will send a message to all descendents of an object. //The message will be sent to a child, then to all of that child's children before proceeding to the next child Broadcast Recursive Send Do_It of Desktop //Will send the message to all objects in the program. Broadcast Recursive_Up Send Do_It //Will send the message to the most inner child object then upward to itSelf (excluding itSelf). //This mode is well suited for deactivating child objects or left-right tree navigation, where every //node on the tree is an object. Broadcast No_Stop Get IsSomeoneCelebrating to iAnswer //The No_Stop option allows a Broadcast Get command to continue broadcasting even after an object

//returns a non-zero value for a Get message. When the broadcast finishes, the return value will be that of//the last object to process the message. Normally used when you know several child objects do have a//common method which you want to execute but when you’re not interested in the return value.

A

Y

B C

Z

D

E

F

The command“Broadcast RecursiveSend Do_it” sent fromobject A would be sentto all objects. Sentfrom Y would only besent to object Z.

Page 281: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 281

Delegate SendDelegate Send is used to send the message directly to the parent object. Using it willoptimize performance and will make your intentions clear.

// Both lines accomplish the same thing: Send DoIt of MyParent // here the Parent ID is evaluated Delegate Send DoIt // here the message is directly sent to the parent

Page 282: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

282 Data Access Corporation

Using Online Documentation – CommandsThis is a good time to look at the On-Line Help files. Currently there are two versions ofthe online help files as we update the old Windows help files to the new HTML Helpfiles. You can access the help directly from Start | Programs | Visual DataFlex 9.1 |Visual DataFlex Help.

[ [ [ [ Start [[[[ Programs[[[[ Visual DataFlex 9.1[[[[ Visual DataFlexHelp[[[[ Index Tabtype “bro”[[[[ Display Button

Read the help for thetwo broadcast pages

Look up the Delegatecommand

You can also double click on the “Broadcast Command” instead of the Display button.

Figure 211

Page 283: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 283

Changing Behavior of Existing MessagesThe topics below are methods for creating or changing procedures. Normally theseprocedures should be created in the object that you wish to affect.

Augmenting a MessageAugmenting adds additional functionality to the normal operation of a pre-existingprocedure. “Forward Sending” the message accomplishes this. Augment whenever youwish the normal procedure behavior, but need something extra to happen.

Augmenting a Procedure:

Procedure Request_Save Forward Send Request_Save // do normal save behavior Send Bell // then ring computer bell End_Procedure

If you “Send” instead of “Forward Send” the message – you will get a recursive or Stack faulterror.

Augmenting a Function:

Function Validate_Save Returns Integer Integer iRetVal If (Invt.Qty < 0) Begin Error DFErr_Operator "Insufficient Inventory on hand" // error message will occur after the unlock Function_Return 1 End Forward Get Validate_Save to iRetVal Function_Return iRetVal End_Function

Page 284: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

284 Data Access Corporation

Canceling a MessageCanceling is done to stop an object from performing a procedure. Since your procedureis found before the predefined procedure (in the class or within a parent object), it willlook no further and never find the other procedure.

Procedure Request_Clear End_Procedure

Overriding a MessageOverriding a procedure is changing the normal behavior – We do not forward send theoriginal message so the normal behavior is not done. We position the procedure so it isfound before the pre-existing procedure is found (normally in the current object).

Procedure Request_Delete Send Bell Send Info_Box “NO DELETIONS ALLOWED!” End_Procedure

Adding (creating) a MessageThe above methods alter pre-existing procedures. Adding a message is creating acompletely new procedure. Notice when we create a new procedure we also must createa way of triggering the message. In this case, we use the On_Key command.

.... On_Key Key_Alt+Key_C Send Check_Range .... Procedure Check_Range Date dStart dEnd Get Value of oStart_Date to dStart Get Value of oEnd_Date to dEnd If (dStart > dEnd) Error DFErr_Operator “The ending date must be greater than the starting date” End_Procedure

Page 285: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 285

Using Online Documentation – ProceduresLooking up Predefined Procedures:

Notice that the Request_Save procedure is defined in many classes. Polymorphismrefers to defining a procedure in multiple places. Via forwarding and delegation (as we

learned earlier) the runtimewill execute the first onethat it finds.

Within the on-lineWinHelp:

[[[[ Start | Programs | VisualDataFlex 9.1 | VisualDataFlex Help

[[[[ Index Tabtype “request_s”

Notice all the definingclasses for this message!

Scroll to the dbGrid Class[[[[ Display Button

Remember if the messageis not found in the currentobject it will forward upthe class hierarchy path. Inthis case, it should find itin one of these definingclasses.

Figure 212

Page 286: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

286 Data Access Corporation

Using Online Documentation – Class HierarchyQuestion: If we had an object built from the dbSpinForm class, which defining class

would resolve theRequest_Save message?

Within the online help:

[[[[ Contents Tab[[[[ Class Reference[[[[ dbSpinForm

Notice the dbSpinForm is asubclass of the dbFormclass. The dbForm is adefining class for theRequest_Save message.When the message isforwarded up the classhierarchy path, it will findthe Request_Save messagein the dbForm class.

Figure 213

Page 287: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 287

Local VariablesLocal variables are declared in procedures or functions and only exist within theprocedure or function. Variables declared outside procedures or functions are globalvariables.

Local Variables:

• Used only in Procedures or Functions

• Most common types are: String; Number; Date; Integer, or Real. Others are:Boolean, Time, TimeSpan, DateTime, Handle, plus advanced data types.

• Are Dynamic: They will grow as needed – no length is indicated.

• Destroyed & memory released when the Procedure/Function is terminated

• Since they are destroyed their names can be duplicated in other procedures orfunctions

Note: In prior versions, local variables were always preceded with the word “Local”. This is nolonger needed or suggested.

Note: Try never to use Global variables! They consume memory, cause undesireddependencies, and cause naming conflicts, since Global variable names cannot be used as aLocal variable name!

Page 288: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

288 Data Access Corporation

On_Key CommandsThese are used to send a message from a key combination or from one of the predefinedaccelerator key functions. Adding an accelerator key can act as a shortcut to optionsfrom the menu bar or button.

On_Key key_name send message {of object} {private}

Accelerator Key Functions: (cannot change the hot key associated with them) On_Key KCancel Send Exit_Application On_Key KUpArrow Send Previous

Physical Keys: (three Prefixes Key_Alt+ Key_Ctrl+ Key_Shift+)

On_Key Key_Ctrl+Key_P Send Print_it On_Key Key_Alt+Key_Z Send Update_Records Private

Note: Child objects will inherit accelerator keys (just like messages) through normal delegationunless the Private option is used.

Accelerator key function name or a

physical key combination

Name of the Message

Stops child objectsfrom inheriting

Page 289: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 289

Properties (creating)Syntax

Often we need to store a value from one object and have access to the value from anotherobject. Procedural programmers have a tendency to want to create a global variable butcreating a new property is the correct way to code this.

The solution is to:

1. Create a property in an outer parent object

2. Use the “Set” command to store the data

3. Use the “Get” command to retrieve the stored data

Sample of creating a property: Object oMy_View is a dbView Property integer piClick_Counter 0 // new property created and available to all objects in the dbView Object oMy_Button is a Button Procedure OnClick Integer iClicks Get piClick_Counter to iClicks // Get the current property value Increment iClicks Set piClick_Counter to iClicks // Set the property value Set Label to iClicks End_Procedure End_Object // oMy_Button End_Object // oMy_View

Note: Instead of procedures or functions that pass many arguments – it may be better to createa new class that has new properties. With the Set and Get commands, these properties can beeasily stored and altered, eliminating the need of argument passing.

Property type property_name initial_value

Page 290: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

290 Data Access Corporation

Properties (Set & Get Commands)Properties are attributes of an Object or Item that can be set or retrieved. You can thinkof a property as a variable that contains a value of an object or item.

The Studio sets properties for yousuch as Location, andApplication_Name.

Object PropertiesThese are properties at the object level.

Syntax:

Set property_name {of object} to value {value 2 ...} Get property_name {of object} to return_value

If we leave off the {of object }, it will default to the current object.

Get Border_Style to iVal // gets the object’s Border_Style property Set Label to sLabel // sets the object’s Label

// Set the property with the Set command Set Application_Name to “Ledger” // Retrieve the property with the Get command Get Application_Name to app_name

Page 291: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 291

Item PropertiesThese are properties at the item level. Items are zero-based, so the second item isreferenced as item 1.

Syntax:

Set property_name {of object} {item_number} to value {value 2 ...} Get property_name {of object} {item_number} to return_value

Object DtlGrid is a dbGrid … Set location to 5 10 Begin_Row Entry_Item Invt.Item_id Entry_Item Invt.Description Entry_Item Invt.Unit_price // this column will be shadowed Entry_Item Orderdtl.Price Entry_Item Orderdtl.Qty_ordered Entry_Item Orderdtl.Extended_price End_Row Set Form_Width item 0 to 55 Set Header_Label item 0 to "Item Id" Set Form_Width item 1 to 116 Set Header_Label item 1 to "Description" Set Form_Width item 2 to 55 Set Header_Label item 2 to "Unit Price" Set Form_Width item 3 to 43 Set Header_Label item 3 to "Price" … Set Column_Shadow_State item 2 to true End_Object

The word “item” is no longerrequired and can be left offon all these command lines.

Page 292: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

292 Data Access Corporation

ProceduresProcedures and Functions are very similar. The main difference is that a Function willalways return a value. A procedure can return a value but this is reserved for legacyprocedures. Newly created procedures should not return values.

Syntax:

Note: There is also a procedure {set} option, which is an advanced concept. A full example ofthis can be found in Appendix B.

Example: When the message Authorize is sent it also passes a string argument. Thisargument is placed into a local variable called sUser_Rights.

Object oMyOKButton is a Button Procedure OnClick Send Authorize “SUPERVISOR” End_Procedure End_Object Procedure Authorize String sUser_Rights If (sUser_Rights = "SUPERVISOR") Send Activate of oMain_View End_Procedure ...

Procedure procedure_name {type1 arg1 ... ... typeN argN} variable_type name ... {forward send procedure_name arg1 ... argN} // statements to perform when this procedure is executed End_Procedure Send procedure_name {of object_name } arg1 ... argN to value //

Page 293: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 293

FunctionsFunctions always return a value. Therefore, instead of using the Send command we usethe Get command. This is similar to retrieving the setting of a property.

Syntax:

Sample:

Note: (prior DataFlex Users) Many of your Macro commands can be easily converted intoFunctions. In fact, many DataFlex commands have been replaced with functions, e.g., Appendand Length.

Function function_name {type1 arg1 ... ... typeN argN} returns return_type variable_type name ... {forward get function_name arg1 ... argN to value} : // statements to perform when this function is called Function_Return value End_Function Get function_name {of object_name } arg1 ... argN to value // functions can also be written as an expression Move (function_name (Self, arg1)) to value

Function Wage_Increase Number nWage Returns Number Number nAfter_Raise Calc ( nWage * 1.10 ) to nAfter_Raise Function_Return nAfter_Raise End_Function ... Get Wage_Increase Empl.Wage to nWage_Incr ...

Here we pass the value ofEmpl.Wage to the localvariable called nWage. Thefunction returns the valuenAfter_Raise into thevariable nWage_Incr.

Page 294: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

294 Data Access Corporation

Functions as ExpressionsA Function can be used as an expression, while procedures cannot. This example uses anexpression for an Entry_Item. (the database in this example is not the one in our labs) Object oCustomer_Grid is a dbGrid //AB-StoreTopStart Function DaysSinceOrder Returns Integer DateTime dHireDate dToday TimeSpan tsDiff Integer iDays Move Customer.Last_Order_Date to dHireDate Move (CurrentDateTime ()) To dToday Move (dToday - dHireDate) To tsDiff Move (SpanTotalDays (tsDiff)) To iDays Function_Return iDays End_Function // DaysSinceOrder //AB-StoreTopEnd Set Main_File to Customer.File_Number Set Size to 105 239 Set Location to 12 24 Set Wrap_State to TRUE Begin_Row Entry_Item Customer.Last_Order_number Entry_Item Customer.Last_Order_date Entry_Item (CurrentDateTime()) Entry_Item (DaysSinceOrder (Self)) End_Row

If the function has arguments, they are passed just before the closing parentheses. HereEmpl.wage is passed as an argument.

Ex: Move (Wage_Increase(Self, Empl.wage)) to nWage_Incr

The “Self” keyword is left offon Global Functions

The Self keyword on otherfunctions is used as thelocation. Only use the Selfkeyword as a parameter onGlobal functions.

Page 295: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 295

Categories of Messages

Properties, procedures, and functions fall under three categories.

• Public messages are the most commonly used messages and are intended to be sentor altered in typical programs.

• Protected messages are available for special uses, but not likely to be sent or alteredin typical programs.

• Private messages are used by the class internally to accomplish a goal. They shouldnot be sent or intercepted! Private messages could be removed when a class ismodified.

Page 296: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

296 Data Access Corporation

Delegation & the Importance of Container ObjectsThe augmenting of common messages such as the Request_XX messages(Request_Save; Request_Delete, etc.) would be difficult if we had to augment them inall objects for all fields in an Empl View. Therefore, these common Request_XXmessages can be augmented in the parent object for the child objects to use.

The example on the next page willshow how the Parent Server is usedif the nested objects do notexplicitly set the server.

Figure 214

Page 297: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 297

Visual DataFlex Code:

Here the container is setting the server. The nested objects will use the same server,since they are not setting the server for themselves.

Object oContainer1 is a dbContainer Set Server to oCustomer_DD Object oID_Form is a dbForm Entry_Item to Customer.ID End_Object // oID_Form Object oName_Form is a dbForm Entry_Item to Customer.Name End_Object // oName_Form Object oPhone_Form is a dbForm Entry_Item to Customer.Phone End_Object // oPhone_Form Procedure Request_Delete Forward Send Request_Delete Send Bell End_Procedure End_Object // oContainer1

We would not wish to repeat theRequest_Delete message for allthree dbForms. Therefore, we sendthe Attach_Server in the container(not in the dbForms) andrequest_xx messages sent by childobjects are delegated to the parentcontainer/object with theAttach_Server set.

Page 298: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

298 Data Access Corporation

“On” Procedures (Events)Programmers often desire to add functionality to certain events. “ON” procedures aretriggered (sent) during certain events and allow the programmer easy access to addadditional functionality at the time these events occur.

All Visual DataFlex event names begin with the “On” prefix (some older ones aremissing the “On”prefix). It would bebeneficial to look inthe online help filesand see what isavailable. Do not tryto learn all the “On”procedures. Simplybrowse the list to seewhat is available.Some events maybehave differentlydepending on theDefining Class.

Within online Help

[[[[ Index tab

Type “OnAct” RRRRthis will bring you tothe first “On”-eventprocedure. Browsethe list to see what isavailable

Figure 215

Page 299: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 299

Using OnClick EventAdd this procedure inside a button to exit the application.

Object oExit_Button is a Button : Procedure OnClick Send Close_Panel End_Procedure End_Object

Using OnActivateApp EventThis procedure is added to the View’s main Panel object. The event will fire when theapplication is first activated and every time you switch to the application. This examplewill play a wave file upon activating our application.

Use Wave : Object oMain is a Panel Set Label To "New Program1" //AB-StoreStart Procedure OnActivateApp Playwave "c:\windows\msremind.wav" SND_ASYNC End_Procedure //AB-StoreEnd

Using OnMaxText EventAdd this procedure to an Edit Object to notify that the size limit has been reached.

Object oComments is an Edit : Procedure OnMaxText Send Bell End_Procedure End_Object

Page 300: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

300 Data Access Corporation

Creating ButtonsButtons are another method of triggering a message. Through the OnClick event it givesthe user visual clues to available options.

Object oMy_Button is a Button Set Label to “Cancel” Set Size to 14 50 Set location to 115 36 Procedure OnClick Send Request_Cancel End_Procedure End_Object

Page 301: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 All about Messages

Data Access Corporation 301

Creating Checkboxes & RadiosCheckbox and Radio Classes are selection devices. Used as a group, Checkboxes can beused for multi-selection and Radios for single selection. The Notify_Select_Stateprocedure is called whenever there is a change to them.

Example of a Radio group: Object oRadioGroup1 is a RadioGroup Set Label to "Output Report:" Set Size to 39 56 Set Location to 3 7 Set Current_Radio to 0 Object oRadio1 is a Radio Set Label to "Screen" Set Size to 10 39 Set Location to 11 5 End_Object // oRadio1 Object oRadio2 is a Radio Set Label to "Printer" Set Size to 10 37 Set Location to 24 5 End_Object // oRadio2 Procedure Notify_Select_State Integer iToItem integer iFromItem Forward Send Notify_Select_State iToItem iFromItem If (iToItem = 0) Set Output_Device_Mode to Print_To_Window Else Set Output_Device_mode to Print_To_Printer End_Procedure End_Object // oRadioGroup1

Page 302: Discovering Visual DataFlex 9.1

Lesson 9 All about Message Discovering Visual DataFlex

302 Data Access Corporation

Example of a single Checkbox that toggles the state of a form: Object oFileName_Form is a Form Set Location to 25 65 Set Size to 13 100 Set Label to “File name:” End_Object //oFileName Object oCheck is a CheckBox Set Location to 40 5 Set Label “Print to File” Set Checked_State to true // Shadow file name form if print to file is false Procedure OnChange Integer iState Get Checked_State to iState Set Enabled_State of oFileName_Form to iState End_Procedure End_Object // oCheck

Page 303: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 Lab All about Message

Data Access Corporation 303

Lesson 9 LabDescription

A new view will be created to log employees in, generating a timecard record. We willalso be creating a Property called “psInOut” that will be used to set the label of fourobjects.

Tasks

The TimeCard Log-In view will contain a number of manual code additions. We willuse this same view again as the Log-Out view in another lesson. This is why we willmake many of the labels within the view dynamic. We will do this by creating a propertycalled In_Out. Then procedure Activating will correctly set the label property from theIn_Out property. By using this property to dynamically set these labels, we will later beable to use this same code for the logging out of employees. By simply setting theproperty to “Out” all the labels will also change.

Creating new TC_InView:

[[[[ New View buttonFrom the DatabaseSelector tool, selectthe DDO tree button

Check to be sure thatthe DataDictionarysare all listed and thatthe main DDO iscorrectly set toTimeCard_DD

Figure 216

Page 304: Discovering Visual DataFlex 9.1

Lesson 9 Lab All about Message Discovering Visual DataFlex

304 Data Access Corporation

Objects to Build File.Field to Display Object name LabeldbView oTC_In Logging EmployeesTextbox Employees listed in the

grid are loggeddbGridGrid Options:Main File=EmplIndex =#2

Empl.CodeEmpl.Last_NameEmpl.First_Name

oEmpl_Grid

dbGroup ProcessButton LogdbForm * Empl.First_Name First Name:TextBox AtdbForm * TimeCard.Hours Hours:dbForm * TimeCard.Minutes Minutes:dbForm * TimeCard.Reason_Code Reason Code:dbEdit TimeCard.Memo Memo:

* Set Label_Column_offset to 0 and Label_Justification to JMode_Top

The table on this page lists thefields and other items to modify.

Use the Database Selector andthe Controls Palette tools to makeall the objects.

Use the Object Properties dialogto name the objects and set theirlabels (some labels are set tojMode_Top & 0 offset).

Use the Object-Order DefinitionTool to correct navigation

Figure 217

Page 305: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 Lab All about Message

Data Access Corporation 305

Checking the Servers:

Select the Process object(dbGroup)

From the Object Properties dialog,select the Database Tab

Check that the indirect server iscorrectly set to TimeCard -- if notthen in the Database Selector(DDO button) check that the mainDDO is set to Time_Card

[[[[ on the Grid[[[[ Grid optionsVerify all options

Figure 218

Figure 219

Page 306: Discovering Visual DataFlex 9.1

Lesson 9 Lab All about Message Discovering Visual DataFlex

306 Data Access Corporation

It is important that the view is correct up to this point before adding manual code.

Classroom Environments:Verify your classmate’s work and have them verify yours.Make sure that all objects are created and are the correct type

Self Study:Verify your work with the chart and screen shot (on the priorpages)

Don’t forget to save the view as TC_In

Page 307: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 Lab All about Message

Data Access Corporation 307

Properties – (the global variables)

TC_In

Open the CodeEditor & theCode_Mod.txtfile

Add the manualcode from theCode_Mod.TXTfile to the TOP ofthe TC_In object

Warning: Add code above the green line.

//---------------------------------------------------------- // Add to oTC_In object // The property psInOut must be created before it is used by // the other objects. Therefore, this code has to be place // before the other objects reference the psInOut property // TC_In view set to "IN" TC_Out view set to "OUT" //---------------------------------------------------------- Property String psInOut "IN" //---------------------------------------------------------- // Dynamically set the Label from the psInOut property //----------------------------------------------------------

Figure 220

Here the psInOutproperty is created.

Green Line

Code added tothe oTC_Inobject

Here we retrieve the valueof the InOut property touse in our labels

Page 308: Discovering Visual DataFlex 9.1

Lesson 9 Lab All about Message Discovering Visual DataFlex

308 Data Access Corporation

Procedure Activating String sIO Forward Send Activating Get psInOut to sIO Set Label to ("Logging Employees" * sIO * ":") // "*" will trim & add a space between the strings End_Procedure //---------------------------------------------------------- // Updates the Grid whenever the view takes the focus //---------------------------------------------------------- Procedure Activate Integer iRetVal Forward Send Activate iRetVal Send Beginning_of_Data of oEmpl_Grid End_Procedure

Page 309: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 Lab All about Message

Data Access Corporation 309

Empl_DD:

Add the manualcode from theCode_Mod.TXTfile to theEmpl_DD object

//---------------------------------------------------------- // Add to the Empl_DD in the TC_In view // Only display In or Out Employees depending on first // character of the psInOut property //---------------------------------------------------------- Procedure OnConstrain String sVal Get psInOut to sVal Move (Uppercase(sVal)) to sVal Move (Left(sVal,1)) to sVal Constrain Empl.logged NE sVal End_Procedure

Figure 221

Page 310: Discovering Visual DataFlex 9.1

Lesson 9 Lab All about Message Discovering Visual DataFlex

310 Data Access Corporation

TimeCard_DD:

Add the manualcode from theCode_Mod.TXT fileto theTimeCard_DDobject

//---------------------------------------------------------- // Add to the Timecard_DD in the TC_In view // Remember the DD also has a procedure Creating that moves // the TimeCard.In_or_Out to the Empl.Logged field. This is // one of the times that it is very important that we do not // Forward Send first. //---------------------------------------------------------- Procedure Creating // Since the TimeCard.In_or_Out is only one character long // the psInOut property value will be truncated Move (Uppercase(psInOut(Self))) to TimeCard.In_or_Out Forward Send Creating End_Procedure

Figure 222

Return to Figure 195 toreview this procedure.

Page 311: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 Lab All about Message

Data Access Corporation 311

Textbox Object:

Add the manualcode from theCode_Mod.TXTfile to theoTextbox1object

//---------------------------------------------------------- // Add to the oTextBox1 in the TC_In view // Dynamically set the Label property (opposite to the // value of the psInOut property //---------------------------------------------------------- Procedure Activating String sIO Forward Send Activating Get psInOut to sIO Move (uppercase(sIO)) to sIO If (sIO = "IN") move "Out" to sIO // this will toggle the status from In to Out Else move "In" to sIO // this will toggle the status from Out to In Set Label to ("The Following Employees are logged" * sIO * ":") End_Procedure

Figure 223

Page 312: Discovering Visual DataFlex 9.1

Lesson 9 Lab All about Message Discovering Visual DataFlex

312 Data Access Corporation

Empl_GridObject:

Add the manualcode from theCode_Mod.TXTfile to theappropriateobject

//---------------------------------------------------------- // Add to the oEmpl_Grid // Do not allow any changes in the grid //---------------------------------------------------------- Set Allow_Bottom_Add_State to False Function Row_Save Returns integer Error DFErr_Operator "No Saves allowed to this grid!" Send Refresh Mode_Find_or_Clear_Set Function_Return 1 End_Function Procedure Request_Delete Error DFErr_Operator "No Deletes allowed to this grid!" End_Procedure

Figure 224

Page 313: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 Lab All about Message

Data Access Corporation 313

Process Object:

Add the manualcode from theCode_Mod.TXTfile to thedbGroupappropriateobject

//---------------------------------------------------------- // Add to oDbGroup1 in the TC_In view // Dynamically set the Label from the psInOut property //---------------------------------------------------------- Procedure Activating String sIO Forward Send Activating Get psInOut to sIO Set Label to ("Process" * sIO * ":") End_Procedure

Figure 225

Page 314: Discovering Visual DataFlex 9.1

Lesson 9 Lab All about Message Discovering Visual DataFlex

314 Data Access Corporation

Button Object:

Add the manualcode from theCode_Mod.TXTfile to the Buttonobject

Paste over theexisting OnClickprocedure

//---------------------------------------------------------- // Add to oButton1 // Dynamically set the Label from the psInOut property //---------------------------------------------------------- Procedure Activating String sIO Forward Send Activating Get psInOut to sIO Set Label to ("Log" * sIO * ":") End_Procedure //---------------------------------------------------------- // Process the selected employee saving & refreshing list //---------------------------------------------------------- Procedure OnClick Delegate Send Request_Save // delegate will start the message in the parent object Send Beginning_of_Data of oEmpl_Grid // move to top of grid & remove logged employee from list End_Procedure

Figure 226

Page 315: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 Lab All about Message

Data Access Corporation 315

Highlighting a Grid RowWe will change the color of the entire row in the grid to make it clear which employee is

being logged in.

] Grid object[[[[ Properties

] CurrentCellColor[[[[ Standard Color[[[[ clGreen

] CurrentRowColor[[[[ Standard Color[[[[ clLime

Figure 227

Page 316: Discovering Visual DataFlex 9.1

Lesson 9 Lab All about Message Discovering Visual DataFlex

316 Data Access Corporation

You should have alreadysaved this view but to changethe description or defer theobject you can call up thecomponent property dialog.

Component | Properties

Verify the data in the dialog

[ OK

Figure 228

Page 317: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 Lab All about Message

Data Access Corporation 317

[ Test compile and run component inthe debugger button

Check that:• It compiles without errors• 4 labels displayed correctly• Grid has row highlighted• Lower name object matches grid• Grid disallows saves & deletes

Warning:The view is not complete yet, so do notadd any records!

Exit back to the Studio

Note: (everyone) To fully understand code requires time to study it. As time permits, followthrough the manual code segments at your own pace.

Figure 229

Page 318: Discovering Visual DataFlex 9.1

Lesson 9 Lab All about Message Discovering Visual DataFlex

318 Data Access Corporation

Did You Discover?

1. Do properties forward and delegate like procedures and functions?

2. If you cancel the Request_Clear procedure in a container object that contains manydbForm objects will it affect the Request_Save?

3. What would happened if Forward Send Creating was listed before the Movecommand in TimeCard DD object’s Creating procedure we just added in the lab?

Here is the code:

Procedure Creating // Since the TimeCard.In_or_Out is only one character long // the psInOut property value will be truncated Move (Uppercase(psInOut(Self))) to TimeCard.In_or_Out Forward send Creating End_Procedure

4. Look in the help to find the names of the other Accelerator-Keys.

Page 319: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 9 Lab All about Message

Data Access Corporation 319

5. Name as many ways as you can to make a procedure execute.

6. Create a new view with a grid displaying the Empl.Code; Empl.Last_Name andEmpl.Term_Date fields. Use the RadioGroup Class to set up a dynamic constraint toshow:

� All Employees

� Terminated Employees

� Active Employees

Page 320: Discovering Visual DataFlex 9.1

Lesson 9 Lab All about Message Discovering Visual DataFlex

320 Data Access Corporation

Page 321: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 10 Items & Predefined Classes

Data Access Corporation 321

Lesson 10Items & Predefined Classes

This lesson covers topics such as images and special “On” events that trigger messagesto be sent whenever these events occur.

Topics in this Chapter:♦ Items - Zero-Based

♦ Referencing Items Outside the Current Object

♦ Grid - Column Properties

♦ Lab 10

• Creating Timers

Page 322: Discovering Visual DataFlex 9.1

Lesson 10 Items & Predefined Classes Discovering Visual DataFlex

322 Data Access Corporation

Items - Zero-BasedMost Windows classes only have one item so the item will default to item 0. ForExample, in the case of a dbEdit class, you may have a need to reference each item(line) separately.

Items are zero based, meaning that the first item is item 0. The property current_item isthe item that the user is currently interacting with.

Object Copyright is an Edit Set Size to 100 200 Set Location to 10 10 Set Read_Only_State to True //This will stop the user from making changes to the text Procedure Activating Forward Send Activating Set Value 0 to "Copyright 2004 Data Access Corporation" Set Value 1 to " Data Access Corporation" Set Value 2 to " 14000 S.W. 119 Avenue" Set Value 3 to " Miami, Florida 33186" End_Procedure End_Object

Other multi-item classes are grid, list, edit, menu, dbList, dbGrid, array, and set.

The word “item”can be left off

Page 323: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 10 Items & Predefined Classes

Data Access Corporation 323

Referencing Items Outside the Current Object

Both item reference and current object can be left blank and it will default to the currentitem and current object. There are times in which we must reference an item outside thecurrent object.

Object oCopyright_Object is an Edit Set size to 100 200 Set location to 10 10 Set Read_Only_State to True //This will stop the user from making changes to the text Procedure Activating Forward Send Activating Set Value 0 to "Copyright 2004 Data Access Worldwide" Set Value 1 to " Data Access Worldwide" Set Value 2 to " 14000 S.W. 119 Avenue" Set Value 3 to " Miami, Florida 33186" End_Procedure End_Object Object oPhone is a dbForm On_Key Key_Alt+Key_U Send Add_Phone Procedure Add_Phone String sCurrentVal Integer iLineCount Get Value to sCurrentVal //move the value from this dbForm into sCurrentVal variable Get LineCount of oCopyright_Object to iLineCount // find the max line count of the edit object Set Value of oCopyright_Object iLineCount to sCurrentVal End_Procedure End_Object

These are “item” references orin the case of an Edit object, theline number

Page 324: Discovering Visual DataFlex 9.1

Lesson 10 Items & Predefined Classes Discovering Visual DataFlex

324 Data Access Corporation

Grid - Column PropertiesCheck the on-line help to see the many column properties available. Column properties,like item properties, are also zero-based.

Example:

// Shadowing a column affects both its appearance and its functionality. A shadowed column will be // displayed in the shadowed color (defined by the desktop or its palette). If a user places the selection // cursor on a shadowed column, the column will not respond to the Enter key or any mouse action. Set Column_Shadow_State 4 to True // this will shadow the 5th column // Adding parentheses around it can also return a property value If (Column_Shadow_State(Self,4)) send Extra_Processing

Column properties may be set dynamically, although such usage would be unusual. Ifthe property is changed when the object is active, you will not see a change in theobject’s appearance until you redisplay the object. The following sample would toggle acolumn’s checkbox state and update the dbGrid as required.

Procedure Toggle_CheckBox Boolean bState Get Column_Checkbox_State 4 to bState Set Column_Checkbox_State 4 to (not(bState)) // If the object is active, we must redisplay it to see changes If (Active_State(Self)) Send Display End_Procedure

Note: Column_xxx states must be set after the Entry_Items, in order for it to take effect.(e.g. in the bottom code section – below the comment line in the editor).

Page 325: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 10 Lab Items & Predefined Classes

Data Access Corporation 325

Lesson 10 LabDescription:

Practice using the dfTimer class, by adding all the parts to make this timer a functionalpart of our view. This lesson also duplicates the view and shows how to register anexternal component so the Studio will recognize it. It then adds the new views to theoverall application.

Tasks:

Creating Timers(This is an outline; the detail instructions will follow)

• Add a timer event that will default the time into the TimeCard record. We use theField_Default_Value so we do not trigger the Data Loss message when we close theview.

• We will be using the dfTimer class from the Studio’s Controls Palette Tool (Non-Visible tab page).

• The properties of the dfTimer object will set the frequency that the timer will fireand list which object should be sent what message.

• The Timecard DataDictionary Object will contain the Update_Time message thatwill default the current time into the TimeCard record.

• The Log In/Out button will send the Request_Save message. It will also sendBeginning_of_Data so the selected record in the grid will be removed and our cursorwill be returned to the top of the list.

Page 326: Discovering Visual DataFlex 9.1

Lesson 10 Lab Items & Predefined Classes Discovering Visual DataFlex

326 Data Access Corporation

Within the TC_Inview:

Tools | Controls Palette[ Non-Visible tab page

; dfTimer to the topcorner

In the Object PropertiesSet:Time_out to 400

Timer_Message tomsg_Update_Time

Timer_Object toTimeCard_DD

Figure 230

Timer object

Page 327: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 10 Lab Items & Predefined Classes

Data Access Corporation 327

[ TimeCard_DD

Add the newcode segmentbelow the codealready there.

//---------------------------------------------------------- // Add to the TimeCard_DD object // This procedure triggers the timer. // It sets the date & time values in the TimeCard record. //---------------------------------------------------------- Procedure Update_Time Integer iHr iMin Date dToday SysDate4 dToday iHr iMin Set Field_Default_Value Field TimeCard.Date to dToday Set Field_Default_Value Field TimeCard.Hours to iHr Set Field_Default_Value Field TimeCard.Minutes to iMin End_Procedure

Figure 231

Page 328: Discovering Visual DataFlex 9.1

Lesson 10 Lab Items & Predefined Classes Discovering Visual DataFlex

328 Data Access Corporation

[ Test compile and runcomponent in the debuggerbutton

Check that the timer is updatingtime

Log someone in:Select a Reason code from thecomboform and then press theLog In Button

Were they removed from thelist?

Exit back to the Studio

Warning! The Reason code isa Validated field. An errorwill be generated if you leaveit blank!

We will need two views -one for processing theemployees in and one toprocess them out.Therefore, we will save thisview under two names.

File | Save As

Enter the data as shown[ Save Button

Close this view andFile | Open | View | Time CardOut View

Figure 232

Figure 233

Page 329: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 10 Lab Items & Predefined Classes

Data Access Corporation 329

Page 330: Discovering Visual DataFlex 9.1

Lesson 10 Lab Items & Predefined Classes Discovering Visual DataFlex

330 Data Access Corporation

The closing and reopening of the views will refresh the code explorer.

The psInOut property that we created affects the labels and the constraining of the view.Therefore, the only change that we will have to make to our new view is changing itsdefault property value from “In” to “Out”.

Within TC_Outview:

[ oTC_Out

Change thedefault propertysetting from “IN”to “OUT”

Compile the Viewand make surethe In & Outlabels are correct

Warning! You might have to close the component view and reopen the view in order for the treeview to show the object name change from oTC_In to oTC_Out.

Figure 234

Default setting

Page 331: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 10 Lab Items & Predefined Classes

Data Access Corporation 331

Add the new views to the application.

If the applicationis closed, open it

[ Add aComponentbutton[ Views[ TC_In] TC_Out[ Add button[ Close button[ Compile anddebug-runprogram ButtonTest that the newviews operatecorrectly

Figure 235

Page 332: Discovering Visual DataFlex 9.1

Lesson 10 Lab Items & Predefined Classes Discovering Visual DataFlex

332 Data Access Corporation

Did You Discover?

1. The lesson mentioned dbEdit as a multi-item class. Name other classes that aremulti-item.

2. What information can you get by clicking on "Help/About..." of a running VDFapplication?

Note: (everyone) To fully understand the manual code requires time to just study it. If timepermits, follow through the manual code segments at your own pace.

Page 333: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 10 Lab Items & Predefined Classes

Data Access Corporation 333

Page 334: Discovering Visual DataFlex 9.1
Page 335: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 11 Troubleshooting

Data Access Corporation 335

Lesson 11Troubleshooting

This lesson covers Troubleshooting techniques.

Topics in this Chapter:♦ Studio Databases

♦ Troubleshooting Hints

♦ Compile Each View Separately

♦ Check File Relationships

♦ Check for Unique Index on the Parent Related Field.

♦ Rebuild the DDO tree within the View

♦ Checking the Data

♦ Debug Compiler Errors & Use a .PRN file

♦ Create a Small Test Program

♦ Use the Debugger

♦ Lab 11

• Debugger Breakpoints

• Debugger Watches

Page 336: Discovering Visual DataFlex 9.1

Lesson 11 Troubleshooting Discovering Visual DataFlex

336 Data Access Corporation

Studio DatabasesThe Studio uses two databases, ddData and abData files. The Studio’s Workspacepulldown menu has the Maintain and Reindex options. These options allow you toupdate or reindex the databases. ddData file contains a record for each DataDictionarycreated. abData contains a record for all the subcomponents of the Studio. Knowing

about these filesand how to reindexthem cansometimes solveyour problems.

Workspace |Reindex Studiodatabases (it willquickly reindex thefiles)

Workspace |Maintain Studiodatabases

Press F7 & F8 toview the records

Close the dialog

Figure 236

Figure 237

Page 337: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 11 Troubleshooting

Data Access Corporation 337

Troubleshooting HintsHere is a list of troubleshooting hints that solve many program problems.

1. Compiling each View separately

2. Checking File Relationships

• Matching length/type of related fields

• Matching DataDictionary Required Parent/Child structure

3. Checking for unique index on the parent related field:

4. Rebuilding the DDO Tree within the View

5. Checking the Data

6. Debugging Compiling Errors & using a .PRN file

7. Creating a Small Test Program

8. Debugging – Runtime errors

Page 338: Discovering Visual DataFlex 9.1

Lesson 11 Troubleshooting Discovering Visual DataFlex

338 Data Access Corporation

1. Compile Each View SeparatelyEach view should be tested and compiled separately before it is added to the completeprogram. The ability to conduct stand-alone tests is one of the benefits of OOP. Thiswill make tracking down problems less painful and time consuming. If multiple viewsare not compiling, it may be a DataDictionary error. An error in the DataDictionary willaffect all views that use the common DataDictionary.

To compile a single view, open the view and then click the “Test compile and runcomponent in the debugger” button.

Figure 238

Test compile button

Page 339: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 11 Troubleshooting

Data Access Corporation 339

2. Checking File RelationshipsValid file relationships are critical to the correct operation in Visual DataFlex. Checkingyour relationships has been made easier in Database Builder.

From DatabaseBuilder:

[[[[ Report[[[[ CheckRelationships

U[U[U[U[ Select All[[[[ (uncheck) theDataFlex error file[[[[ Start checking

Figure 239

Figure 240

Page 340: Discovering Visual DataFlex 9.1

Lesson 11 Troubleshooting Discovering Visual DataFlex

340 Data Access Corporation

From this screen,we can print thereport out.However, justreading it onscreen willnormally point usto any incorrectrelationship.

Ensure thereports have noerrors

The following tests are made and all mismatches reported:

• The length & type of each relating child field to the related parent field

• The parent related field is uniquely indexed

• The Required Child and Parent File Structure is correct

Figure 241

Page 341: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 11 Troubleshooting

Data Access Corporation 341

Another way to check that the required Child and Parent DataDictionary structure iscorrect is to remove the references and then use the magic wand to re-add them.

Figure 242

Use the delete buttons toremove all files and then use thetop (magic wand ) buttons toadd back only the files that havea relationship created.

Page 342: Discovering Visual DataFlex 9.1

Lesson 11 Troubleshooting Discovering Visual DataFlex

342 Data Access Corporation

3. Checking for Unique Index on the Parent Related Field

Figure 243

Figure 244

The employee file relates tothe Dept file on theDept_Code field – here wesee that the Main index forthis field is index 1

#2. Check that theDept_Code field isthe only field listed

Page 343: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 11 Troubleshooting

Data Access Corporation 343

4. Rebuilding the DDO Tree Within the View

This dialog is inthe Studio. Openthe Empl View,then press theDDO Tree buttonfrom the DatabaseSelector tool.

If the Studio encounters file relationships in your DDO Tree Structure that are notrepresented in the DD classes, a warning message will appear.

Main_DDO

Changing the Main_DDO will affect how the Constrain File commands will be added.All Child DDOs to Main DDO will have a Constrain_File property. Notice how bothTimecard and Wk_Sum are constrained to Empl, which is the Main_DDO.

Figure 245

Page 344: Discovering Visual DataFlex 9.1

Lesson 11 Troubleshooting Discovering Visual DataFlex

344 Data Access Corporation

Steps to Rebuild a DDO structure:

Rebuilding the DDO tree can solve many oddball behaviors that are caused by anincorrect DDO structure.

• Use the Studio Editor to check for any manual code additions in the DataDictionarys.If there are any edits, cut and paste them somewhere safe. Otherwise, we will losethese additions when we complete the next step.

• Use the Remove button to remove all DDOs.

• Use the Add DDO button to add in the Main_DDO file. This will add the main DDand all ancestors (parent, grandparent, etc.) DDOs to the structure. If you disallowsaves in your view, the ancestor DD files will not be necessary, unless the files areneeded elsewhere in the view.

• Next, use the Add DDO button and add all descendent (child, grandchild, etc.)DDOs. If deletes are disallowed, these descendent DDOs will not be needed unlessthe files are required elsewhere in the view.

Figure 246

Page 345: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 11 Troubleshooting

Data Access Corporation 345

5. Checking the DataDuring development of an application, as file structures and relationships change, invaliddata can be added to the database. This “bad” data can be responsible for the applicationnot operating correctly.

Use Database Explorer to check for these problems:

• Check that System Files only has one record.

• Check that validated fields have valid data. Even if a field is not visible onscreen, when the record is saved, all fields will be validated. If a validationon a field is added, the existing data must be validated against the newbusiness rule.

Use Database Builder to check for these problems:

• Check “Max Records” against “Records Used”. Max Records should be setto about 20% above the estimated maximum size of the database. Thisestimate should be sufficiently large enough to accommodate the expectedfile, but be aware that making it too large will slow down indexperformance.

• Check for orphan records (from the Report pull-down)

Figure 247

Page 346: Discovering Visual DataFlex 9.1

Lesson 11 Troubleshooting Discovering Visual DataFlex

346 Data Access Corporation

6. Debugging Compiler Errors & using a .PRN fileThe new editor in the Studio makes using the PRN files almost obsolete, but it is stillworthwhile to know about this file.

Always compileeach viewseparately.Compiling smallersections makes iteasier to locate theproblem.

Even whencompiling a singleview, an error canstill come fromincluded files (i.e.;.DD; .SL; .PKGfiles).

Figure 248

Test compile button

Page 347: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 11 Troubleshooting

Data Access Corporation 347

Often the errors will direct you to the last addition that you made to the program, sofinding the cause of the error is not that hard. Other times you have no idea whichsection of code contains the error. When this is the case, you may need to look at a .PRNfile.

Tools | ConfigureEnvironment[[[[ General Tabpage

Click in theCompilerSwitches andpress F1 for help

From the helpscreen, scrolldown until youfind the words“CompilerSwitches”printed in green. Clicking on this link will jump you to the full explanation of theswitches. The “F” option will generate the .PRN file.

Figure 249

Switches

Page 348: Discovering Visual DataFlex 9.1

Lesson 11 Troubleshooting Discovering Visual DataFlex

348 Data Access Corporation

This .PRN file can then be loaded into any editor. If we were compiling the entire Orderapplication example, then the .PRN would be called Order.PRN. If you are compiling asingle view, the .PRN file will be named IDETestRun_X.PRN in the \AppSrc directory.After loading the PRN file, you search for the word ERROR:. Your code will be listedhere along with the error messages. The error normally will be located within the twolines of codeabove where theerror message isprinted.

Our error hereis cause by theincorrectspelling ofinteger.

We cannotcorrect the errorin the .PRN file,but we can see that the code is located in the button object, so we return to the Studioand double click on the button to open the editor.

Note (Everyone): With the Studio Editor it is very seldom that looking at a .PRN file is needed.The Studio will open the correct file that contains the error just by double clicking on the error.

Figure 250

Page 349: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 11 Troubleshooting

Data Access Corporation 349

7. Create a Small Test ProgramWhenever you use a new class or try to accomplish something for the first time, create asmall test program. Creating a test program will allow you to experiment with the newproperties, procedures and functions. This will give you a better understanding of thecode and how to use it before including it into a large program.

To do this, look up the new feature in online help. Often there will be sample code thatyou can cut and paste to test.

Bring up theDataFlex on-lineHelp

] F1] Index tabFor_AllLook through bothentries on thistopic

Notice the samplecode that isprovided can becut and pasteddirectly into theStudio.

Figure 251

Page 350: Discovering Visual DataFlex 9.1

Lesson 11 Troubleshooting Discovering Visual DataFlex

350 Data Access Corporation

8. The Debugger – Runtime problems:

Some of the Debugger features:

• tracking down runtime errors

• setting watches

• message tracing

Open theCorporationXApplication

] Compile anddebug-runprogram button

View | Empl View

Resize thedialogs as shown

This willcompile yourapplication withall the debuggingpackages addedand load & runboth thedebugger andyour application.

Figure 252

Page 351: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 11 Troubleshooting

Data Access Corporation 351

Within theDebugger:

Data | WatchesData | LocalVariablesData | GlobalVariablesData | Call stackTracing | ViewMessage Trace

Window | Tile

When starting tolearn thedebugger, younormally want tohave all thecomponents open.

The next step is normally setting breakpoints, which we will do in the lab.

Figure 253

Page 352: Discovering Visual DataFlex 9.1

Lesson 11 Lab Troubleshooting Discovering Visual DataFlex

352 Data Access Corporation

Lesson 11 Lab

Description:

Using the debugger. We will continue using the above example in the lab. If you haveclosed everything, simply refer back a few pages and set up the debugger again.

Tasks:

Debugger Breakpoints

First step is to set breakpoints.All files (views, components, .SLand packages) that make up theview will be available from thedebugger comboform.

Select the Empl.dd from thecomboformScroll down until you find theUpdate & Backout properties[ the dots at the left (of the“Forward Send …” statements) tocreate breakpoints whereindicated

You cannot break on the actualProcedure line, so we break onthe first line of code in theprocedure.

Figure 254

Will turn tored showinga breakpoint

Page 353: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 11 Lab Troubleshooting

Data Access Corporation 353

Debugger Watches

Within the debugger, highlight“Dept.Number_of_Empl” andthen right click on it

Select Evaluate from thefloating menu

[ Watch button

[ Close

Within the running program,find an existing record andchange the Dept code

F2 – to save[ OK & then continue to pressthe “Step into” button andwatch theDept.Number_of_Empl fieldchange as it steps through theBackout and Updateprocedures. List the values inthe chart.

Value of Dept.Number_of_Empl

Before the Backout

After the Backout

Before the Update

After the Update

Your results should show Backout subtracting one from the old department count andUpdate adding one to the new department count.

Start Program Execution Button

Step into

Watch onDept.Number_of _Empl

Page 354: Discovering Visual DataFlex 9.1

Lesson 11 Lab Troubleshooting Discovering Visual DataFlex

354 Data Access Corporation

Did You Discover?

1. What does the Z compiler option do?

2. What does the S compiler option do?

3. If your users launch 3-4 copies of this program at the same time, how much memorywill it use up?

Page 355: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 12 Waves and Bitmaps

Data Access Corporation 355

Lesson 12Waves and Bitmaps

This is a fun lesson that covers sounds and bitmaps and a few other GUI features ofVisual DataFlex. We will add a wave file and bitmap file, adding sound and color to ourapplication.

Topics in this Chapter:

♦ Displaying Bitmaps from a Database File

♦ Displaying Bitmaps as a Backdrop

♦ Wave Files - Applications with Sound

♦ Creating a Wave File

♦ Embedded Resources

♦ Lab 12

Page 356: Discovering Visual DataFlex 9.1

Lesson 12 Waves and Bitmaps Discovering Visual DataFlex

356 Data Access Corporation

Displaying Bitmaps from a Database File

This method was demonstrated in the Quick Start manual (and in our application). TheASCII field,Country.Flagholds the namesof the bitmapfiles. The bitmapfiles are normallystored in the\bitmapsubdirectory.

Objects of the dbBitmap class display the bitmap file named in a database field. Uponreceiving the Entry_Display message from the data dictionary, the bitmap is displayed.These bitmap files store such data as personnel ID photos or inventory pictures.

Steps for Creating a dbBitmap Object

• All bitmaps must be created and assembled together in the bitmap directory.

• Create a dbBitmap from the database selector tool dragging the ASCII field intothe view.

Object oCountry_Flag is a dbBitmap Entry_Item Country.Flag // only the name of the bitmap file is stored Set Border_Style to Border_Dialog // Raised border Set Bitmap_Style to Bitmap_Stretch // Auto-resize bitmap to fit object Set Size to 83 149 Set Location to 12 54 End_Object

Page 357: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 12 Waves and Bitmaps

Data Access Corporation 357

Displaying Bitmaps as a BackdropIn Visual DataFlex, you can set the Bitmap property for any visible object. When theobject is painted on screen, the bitmap file is displayed in the upper left corner of theobject.

You may design your ownbitmaps, or use any*.BMP-format files legallyavailable to you from anysource (*.BMP, or *.RLEfor the compressed bitmapformat). Typically, youwould design a bitmap tofit on, and completelycover, a control. If youwant a panel or dialog tocontain a bitmap, however,the chances are that you

want its size and aspect ratio retained. Therefore, Visual DataFlex resizes bitmaps to fitcontrols, but does not resize bitmaps displayed on panels and dialogs. If you want theexact appearance of a bitmap you are putting on a control to be retained, make sure theratio between the vertical and horizontal dimensions are the same for the bitmap as forthe control.

Many VDF properties can be set to a .bmp file. Always check the help documentationfor graphical file requirements. Some properties require a 24x24-pixel file.

Object Print_Button is a Button Set Size to 10 10 Set location to 20 20 Set BitMap to “printer.bmp” Procedure OnClick Send Print Report End_Procedure End_Object

Page 358: Discovering Visual DataFlex 9.1

Lesson 12 Waves and Bitmaps Discovering Visual DataFlex

358 Data Access Corporation

Some common properties and functions are:

Properties / Functions Descriptionbitmap — string — filename This property identifies the file containing the

bitmap image for this object.bitmap_style — integer —BITMAP_ACTUAL|BITMAP_STRETCH|BITMAP_CENTER|BITMAP_TILE

This property specifies the position, size, orshape in which the bitmap image for this object isto be displayed. BITMAP_STRETCH fills theobject with the image.

bitmap_height returns integer —function

This function returns the height of the imagecontained in the file named by bitmap.

bitmap_width returns integer —function

This function returns the width of the imagecontained in the file named by bitmap

Note: Bitmaps can also be used as Icons. They can also be captured to and from the Windowsclipboard – a complete explanation of this is in the Language Guide

Page 359: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 12 Waves and Bitmaps

Data Access Corporation 359

Wave Files - Applications with SoundAdding sound to your application is easy and fun. All you need is a sound card and awave file.

Syntax: PLAYWAVE WaveFilename PlayOption

The WaveFilename is the name of a wavefile (.WAV).

PlayOptions DescriptionSND_SYNC Play synchronous. Plays from beginning to end. Will not

interrupt (default setting)SND_ASYNC Play asynchronous. Interrupt playing by pressing a key.SND_NODEFAULT Does not play system default sound in the case that the

specified file is not found. This must be Or'ed with eitherSND_SYNC or SND_ASYNC.

SND_LOOP Play in a loopSND_NOSTOP Play non-stop

Use Wave // include the Wave.PKG … Procedure OnChange PlayWave “c:\windows\media\Chimes.wav" SND_ASYNC //issue the Playwave command End_Procedure

Page 360: Discovering Visual DataFlex 9.1

Lesson 12 Waves and Bitmaps Discovering Visual DataFlex

360 Data Access Corporation

Creating a Wave FileThis section is for reference only. It requires sound cards, microphones, and speakers.Its purpose is to show how to use and create wave files.

Windows soundrecorder allowsyou to record yourown . Wav filesthat you may thenuse in yourapplication.

[ [ [ [ Start button[[[[ Programs[[[[ Accessories

In Window 98, ME2000 & XP:[[[[ Entertainment[[[[ Sound Recorder

In Windows NT[[[[ MultiMedia[[[[ Sound Recorder

The sound recorder buttons work verymuch like the buttons on a realrecorder.

File | New[[[[ Record Button and record a messageFile | Save AsGive this file a name and save it underour\Bitmaps directory

Figure 256

Figure 257

Page 361: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 12 Waves and Bitmaps

Data Access Corporation 361

Embedded BitmapsDataFlex can include bitmap files and icons into the Exe as native resources as itcompiles your source code. This will increase speed of loading bitmaps and eliminatethe need of copying these as separate files during deployment.

The Compiler uses the Programname.cfg file to determine what items to embed. Thisfile can be directly edited but it also can be modified via the Studio from the Program |Properties Dialog.

Programs | Properties[[[[ Bitmaps tab page[[[[ Scan for images[[[[ Yes Button[[[[ Yes Button[[[[ OK ButtonClose the Dialog

Figure 258

Page 362: Discovering Visual DataFlex 9.1

Lesson 12 Waves and Bitmaps Discovering Visual DataFlex

362 Data Access Corporation

Within the Studio:

File | Open fileBrowse to the \AppSrcdirectory[[[[ CorporationX.cfg

Close the file after you lookover the contents

Figure 259

Page 363: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 12 Lab Waves and Bitmaps

Data Access Corporation 363

Lesson 12 LabDescription:

This lab uses one of the event procedures to add a picture as a background.

Tasks:

Open theapplication in theStudio

[[[[ Client_Area

Cut & past thecode modificationfrom theCode_Mod.txt file

Compile & Test

The “CorpLogo.BMP” file is located in the workspace \Bitmap directory, which wascopied earlier from the training CD.

// Add to the bottom of the Client_Area object

Set Bitmap to "CorpLogo.BMP"

Figure 260

Page 364: Discovering Visual DataFlex 9.1

Lesson 12 Lab Waves and Bitmaps Discovering Visual DataFlex

364 Data Access Corporation

Did You Discover?

1. How can you make the TC_In view automatically display when the program isexecuted?

2. How can you create an icon on the desktop to automatically run this application?

3. After completing this lab, will you have to move the CorpLogo.BMP whendeploying your application? What would you suggest be done?

Page 365: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 13 DD’s Local Buffers & Procedures

Data Access Corporation 365

Lesson 13DD’s Local Buffers & Procedures

This lesson covers some of the most commonly used DataDictionary procedures and howthe DataDictionary’s Local Buffers operate.

Topics in this Chapter:

♦ Changing Field Values – DD Local Buffers

♦ Optimizing Field_Exit_msg

♦ Important DataDictionary Procedures

♦ Procedure Creating

♦ Procedure Update & Backout

♦ Functions Validate_Save & Validate_Delete

♦ Procedures Save_Main_File & Delete_Main_File

♦ Lab 13

Page 366: Discovering Visual DataFlex 9.1

Lesson 13 DD’s Local Buffers & Procedures Discovering Visual DataFlex

366 Data Access Corporation

Changing Field Values - DataDictionary’s Local BuffersThe DataDictionarys keep a local buffer that is synchronized with the data on the screen.Developers will find that the DataDictionary’s local buffers are easier to access.

Without Data Dictionarys: there are three work areas

With Data Dictionarys: The Screen buffer and DD Local Buffer areas are alwayssynchronized. Change one and the other one automatically updates.

These are always synchronized.

Screen Buffer Area /DEO items

Set Changed_Value 0 to sVal

DD Local Buffer Area

Set Field_Changed_Value ;

field Customer.St to sVal

Record Buffer Area// in a locked state to file.field

Move sVal to Customer.St

Hard Disk

Save Customer

Screen Buffer Area /DEO items

Set Changed_Value 0 to sVal

Record Buffer Area// in a locked state to file.field

Move sVal to Customer.St

Hard Disk

Save Customer

Page 367: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 13 DD’s Local Buffers & Procedures

Data Access Corporation 367

Setting data entry object values vs. setting DataDictionary buffers:

Within the DEO Within the DDSet Value to “FL” Set Field_Current_Value;

field Customer.State to “FL”This only sets the value.Without theField_Changed_State set totrue, the data will not bemoved into the databaseduring the save!

Set Item_Changed_State to True

Set Field_Changed_State; field Customer.State to True

Flags the field as changed, soit will saved to the databaseduring a save operation.

Set Changed_Value to “FL”

Set Field_Changed_Value; field Customer.State to “FL”

A short-cut. It is acombination of the twoproperties above

The Set establishes the property value. To retrieve property values use the Getcommand.

Get Value to sVar Get Field_Current_Value field Customer.State to sVar

Note: Many field properties are also available in the format file_field. These will set/get thevalue from a parent file:

Get File_Field_Current_Value File_Field Customer.Name to sVar

Page 368: Discovering Visual DataFlex 9.1

Lesson 13 DD’s Local Buffers & Procedures Discovering Visual DataFlex

368 Data Access Corporation

Optimizing Field_Exit_MsgThe prior page covered the differences between Field_Current_Value andField_Changed_State. Field_Current_Value changes only the value on screen. If a saveoccurred, the data would not be moved to the database. This may lead one to believe thatusing Field_Changed_Value all the time would be correct, but this is not always the case.

The following two examples will both result in updating the extended_price. However,in grids, the Field_Current_Value is more efficient. The following pages will show youwhy.

Using Field_Current_Value procedure: Set Field_Exit_msg Field Orderdtl.Qty_Ordered To Adjust_Display_Total Procedure Adjust_Display_Total Integer iQty Number nAmnt Get Field_Current_Value Field Orderdtl.Qty_Ordered to iQty Get Field_Current_Value Field Orderdtl.Price to nAmnt Set Field_Current_Value Field Orderdtl.Extended_Price to (nAmnt * iQty) // Note we set Current_Value, but not Changed_State! // Since Changed_State is not true, a save will not move the new value to the database // To update the field value we recalc it in procedure Update of the DataDictionary End_Procedure

Using Field_Changed_Value procedure: Set Field_Exit_msg Field Orderdtl.Qty_Ordered To Adjust_Display_Total Procedure Adjust_Display_Total Integer iQty Number nAmnt Get Field_Current_Value Field Orderdtl.Qty_Ordered to iQty Get Field_Current_Value Field Orderdtl.Price to nAmnt Set Field_Changed_Value Field Orderdtl.Extended_Price to (nAmnt * iQty) // note Field_Changed_State will set the Current_Value and the Changed_State End_Procedure

Note that the field isagain updated in theUpdate procedure.

Page 369: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 13 DD’s Local Buffers & Procedures

Data Access Corporation 369

Negative side effects of using Field_Changed_Value in Grids:

When using a dbForm there is no big benefit of one procedure over the other. The bigdifference is when we are using a dbGrid.

• Accessing a blank row will create a record with only the Orderdtl.Extended_Pricefield filled in.

• Because the Field_Changed_Value sets Field_Changed_State to true, a save willtake place EVERY time you navigate up or down the Quantity column, even thoughno user input took place. Using this property forcing saves, a LOT of unnecessaryI/O traffic can be generated if the user scrolls in the Qty column.

Change the Studio’sworkspace to “OrderEntry SampleApplication”

Open OrderDtl inDatabase Builder andclick on the methodstab page

Scroll down to theAdjust_Display_Totalprocedure andchangeField_Current_ValuetoField_Changed_Value

// This updates the extended price field, which will update any // display balances. This is only done for display purposes. The actual // amount is updated to the field during the save. Procedure Adjust_Display_Total Integer iQty Number nAmnt Get Field_Current_Value Field Orderdtl.Qty_Ordered to iQty Get Field_Current_Value Field Orderdtl.Price to nAmnt Set Field_Changed_Value Field Orderdtl.Extended_Price to (nAmnt * iQty) // note we set value, but not changed state! End_Procedure

Figure 261

Page 370: Discovering Visual DataFlex 9.1

Lesson 13 DD’s Local Buffers & Procedures Discovering Visual DataFlex

370 Data Access Corporation

Save and return to theStudio

File | Open | View |Order Entry

Double click on thedbGrid and add theRow_Save functionfrom Code_Mod.txt file

Save and Compile theview

// Add to the top of the OrderDtl_Grid Function Row_Save Returns integer Integer iRetVal Send Info_Box "Save Operation being Called" Forward Get Row_Save to iRetVal Function_Return iRetVal End_Function

Figure 262

Page 371: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 13 DD’s Local Buffers & Procedures

Data Access Corporation 371

Click F8 (to find thefirst record)Click on the first rowof the Qty Column

Move down the QtyColumn – withoutchanging any values– Note that a save isbeing triggeredbecause of theField_Changed_Valueproperty.

Continue down theQty Column until youcome to the firstblank row

When you try to leave this blank row, a save is again attempted; but this time it will generatea Status 90 error because other columns are required fields in the DataDictionary.

Click OK in the error dialog & Close the running application.

Open Database Builder and return Field_Changed_Value to Field_Current_Value.

Leave the other changes in place, recompile and run the application.

Move down the Qty Column, without changing any values. Note that no saves are beingtriggered. This is because the change to the Field_Current_Value property alone did notcause the line to save. The Field_Changed_State remains false and therefore no save istriggered.

This time the blank line problem we experienced earlier does not happen.

Figure 263

Page 372: Discovering Visual DataFlex 9.1

Lesson 13 DD’s Local Buffers & Procedures Discovering Visual DataFlex

372 Data Access Corporation

We now see the benefits of using Field_Current_Value in dbGrids. However, sinceField_Current_Value only sets the value, if we make a change to the Qty, how is the Qtyfield and the Extended price being saved to the database?

Open OrderDtl inDatabase Builder andclick on the methodstab pageScroll down to theUpdate ProcedureNote that Update willrecalculate theExtended_Price fieldevery time a saveoccurs

Figure 264

Page 373: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 13 DD’s Local Buffers & Procedures

Data Access Corporation 373

Important DataDictionary Procedures

DataDictionarys handle the reread and unlocking of the file during the save and deleteoperations. It is imparitive to allow the developer to add custom code at numeriouspoints throughout these operations. Many DataDictionary procedures have been createdfor the developer to use as “hooks”. These hooks allow the developer to code at keypoints during the Save or Delete operations.

There are many common procedures and functions listed in the “Methods” tab ofDatabase Builder. We will cover the four basic procedures that are used most often.These procedures are always called in a locked state, thus it is safe to access the recordbuffers.

Sends Sends Sends

Normally

Mirror Images of each other

Note: When you are outside of a locked state, reference item windows or the DD local buffers.Inside a locked state, reference file.fields (record buffers). Never add code in a locked state thatwould wait for user intervention.

ProcedureBackout

Procedure

Update

ProcedureDeleting

ProcedureCreating

New Save Edit Save Delete

Page 374: Discovering Visual DataFlex 9.1

Lesson 13 DD’s Local Buffers & Procedures Discovering Visual DataFlex

374 Data Access Corporation

Procedure CreatingThis procedure is only called when saving a New Record. Here we are adding the user’sID to the newly created record so we can track who created the record.

The Creating procedure (and other procedures covered here) is an empty hook (emptyprocedure) within the basic class package. When the procedure is an empty hook in theClass, it is not required to Forward Send. Although it is a good practice to alwaysForward Send, since we may someday add new subclass layers that would then requirethe Forward Send.

Note: (DataFlex 3.1 Object Oriented Programmers) The Destroying procedure is obsolete, giventhe new transaction processing feature.

Procedure Creating Forward Send Creating Move (UserID(Self)) to Empl.Created_By End_Procedure // Creating

Page 375: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 13 DD’s Local Buffers & Procedures

Data Access Corporation 375

Procedure Update & BackoutUpdate is called during a new save and Backout is called during a delete. Bothprocedures are called during an edit save. These procedures can be used to maintainrunning totals. Typically, the procedures will be mirror images of one another, Updateadding to the running total and Backout subtracting from the total.

To fully understand how these two procedures work so harmoniously together during anedit save, we must remember that both are called during the same locked state and thatEntry_Update (which moves the data from the image to the record buffer) is calledbetween these two procedures.

STEPS:

• ReRead Locks files and refreshes the record buffer

• Backout Subtracts the original timecard amount from the running total

(this is like deleting out the original record)

• Entry_Update Moves new data values from the screen to the record buffer

• Update Adds new timecard amount to the running total

• Save Moves data from record buffer to disk

Procedure Update Forward Send Update Add TimeCard.Pay to Empl.YTD_Pay End_Procedure Procedure Backout Forward Send Backout Subtract Timecard.Pay from Empl.YTD_Pay End_Procedure

Page 376: Discovering Visual DataFlex 9.1

Lesson 13 DD’s Local Buffers & Procedures Discovering Visual DataFlex

376 Data Access Corporation

Functions Validate_Save & Validate_DeleteThese functions are intended to check for such things as possible data-integrity violationsor other checks just prior to the writing of the record to the disk. If the function returns azero, the save/delete is allowed. Returning a non-zero will prevent the operation.

// Will give an error if the inventory is not sufficient to cover the order. // This function would normally go inside the Order detail DataDictionary Function Validate_Save Returns Integer Integer iRetVal If (Invt.Qty < 0) Begin Error DFErr_Operator "Insufficient Inventory on hand" // error message will occur after the unlock Function_Return 1 End Forward Get Validate_Save to iRetVal Function_Return iRetVal End_Function

// before deleting Customer record, check if needed for end of year taxes via an active field Function Validate_Delete Returns Integer Integer iRetVal Forward Get Validate_Delete to iRetVal If (iRetVal <> 0) Function_Return iRetVal // the delete has failed, no need to continue If (Customer.Status = "Y") Begin Error DFErr_Operator "Cannot delete an Active Customer" // error will not show until unlock occurs Move 1 to iRetVal // to stop the delete End Function_Return iRetVal End_Function

Validate_Delete is called from alocked state. The error message willnot appear until the operation iscompleted and the file is unlocked.

Page 377: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 13 DD’s Local Buffers & Procedures

Data Access Corporation 377

Procedures Save_Main_File & Delete_Main_FileThese procedures by default perform a save/delete operation on the main_file. They areintended to be augmented or overridden.

In both of these examples, the extra Hist file is not part of the DataDictionary structure.To have the file locked and reread with the other files, we would add it to the ExternalStructure in the DataDictionary.

// Purpose: To collect a record of all save operations made to the main file into a history file. Procedure Save_Main_File // clear, move the fields into the history file & save Clear Hist Move Employ.ID to Hist.ID Move Employ.Name to Hist.Name ... SaveRecord Hist Forward Send Save_Main_File End_Procedure // Save_Main_File

// Purpose: Before deleting an employee record, save the data to a history file Procedure Delete_Main_File // clear, move the fields into the history file & save Clear Hist Move Employ.ID to Hist.ID Move Employ.Name to Hist.Name ... SaveRecord Hist Forward Send Delete_Main_File End_Procedure // Delete_Main__File

Page 378: Discovering Visual DataFlex 9.1

Lesson 13 Lab DD’s Local Buffers & Procedures Discovering Visual DataFlex

378 Data Access Corporation

Lesson 13 LabDescription:

This lab will not list all keystrokes. It lists general instructions. It is a good review ofmany of the topics covered so far in the manual. It uses the procedures that we havelearned in this lesson. It also adds an additional Company file. When an additional fileis added to the File/DataDictionary structure, many steps need to be taken to make sureall existing files are updated correctly.

Tasks:

• Open the Empl file in Database Builder and review how we maintained the runningtotals for the Number of Employees in the Dept file.

Review theUpdate andBackoutProcedures

Figure 265

Page 379: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 13 Lab DD’s Local Buffers & Procedures

Data Access Corporation 379

• Using Database Builder, create a new Company file (file number = 1). Then createthe needed index so this can be used as a parent file. (For help, review the rules offile relationships located in Appendix C).

Company; Filenumber = 1

Fields Type Length Field SettingsCompany_Code ASCII 4 AutoFind

CapsLockKey Field

Name ASCII 25 AutoFind

Total_Budget Numeric 8.2 Currency Mask

Index #1 = Company_Code

Index #2 = Name

• Open the Dept file:

• Add a field in the Dept file called Company_Code (this field must be calledCompany_Code for a future Lab to work!).

• Relate the Dept.Company_Code field to the Company.Company_Code field(both fields must be the same size and type to relate them!).

• Create a new Index #3 with the new Company Code field and the Dept Codefields as the index segments. Both uppercase checkboxes should be checked.

• (Did you remember to verify the structures tab on both Company & DeptDataDictionarys?)

Page 380: Discovering Visual DataFlex 9.1

Lesson 13 Lab DD’s Local Buffers & Procedures Discovering Visual DataFlex

380 Data Access Corporation

• Select File | New Component and use the Invoice Style template that was created in aprior lesson. Create a small view called CoDept that will show the Company data atthe top and all the related Dept records in a dbGrid below. You may wish to reviewthe prior Lab where we used the Invoice_Style template to create the DeptEmplview. The steps below will walk you through all the steps.

• Update the two default properties within the template.

“Company”

“Company.Company_Code”

• Set the Main_DDO to Company in this new view.

• Delete the Parent Related Object

• Attach the Company.Code and Company.Total_Budget fields to the first and lastdbForms

• Add labels to these objects

• Add the Company.Name field

• Adjust the Object-Order to correct navigation among these three objects.

• Add Dept fields to the dbGrid. Hint: comment (text) fields cannot be placed indbGrids.

• Align objects

• Compile and Test the view. Create a company record with the company code of“DAW”. Before you create this record, first press Ctrl+F5 to clear the grid. Thedepartment records already created will be showing up in the grid as orphanrecords. This is because their Company_Code field is blank in all these records.Do not correct this now. We will correct this in a batch process in anotherlesson.

Page 381: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 13 Lab DD’s Local Buffers & Procedures

Data Access Corporation 381

• The Dept DataDictionary file will need Update and Backout procedures to collectthe running total in the Company.Total_Budget field. Review the Update andBackout procedures just covered in this lesson and the one just reviewed at the startof this lab as a model. The OrderDtl.DD in the Order sample is an excellent exampleto study. If you need more help, see the completed DataDictionarys in the “FinishedExample” workspace.

• Add the new view to the CorporationX Application.

• What did we learn about which DataDictionarys are required in a view? (Bothparent and child DataDictionarys are needed to save and delete records in the mainDDO). What will happen when we go to save a record in the other views? (Theywill not be able to save, unless all parent DataDictionarys are present. This isbecause Save operations propagate up – so all parent DataDictionarys are requiredin all views.). Make the needed changes in all views to add the CompanyDataDictionary using the DDO button on the Database Selector tool. Close theDatabase Selector tool every time you switch between views.

• Update the DeptView by adding the Company.Company_Code field to the view.

• Update Dept/Empl View by adding the Company.Company_Code field to the view.This object should be the related parent object that was created in the Invoice_Styletemplate but we already deleted it in the prior lab. The code is listed below and inCode_Mod.txt under lesson 13. Cut and paste it into this object. This code willshadow the parent object when you find an existing record.

• Save, Compile & Test – you may need to review the Troubleshooting lesson.

//------------------------------------------------------------------- // Add to Parent (dbForm) object - below the green line // If Header record exists, disallow entry in Related Parent window. //------------------------------------------------------------------- Procedure Refresh Integer iMode

Page 382: Discovering Visual DataFlex 9.1

Lesson 13 Lab DD’s Local Buffers & Procedures Discovering Visual DataFlex

382 Data Access Corporation

Integer iSrvr iCrnt Get Server to iSrvr // get the DataDictionary Get Current_Record of iSrvr to iCrnt // get record in DataDictionary // Set displayonly to true if iCrnt is non-zero Set Enabled_State to (iCrn = 0) Forward Send Refresh iMode // do normal refresh // don't leave us sitting on a displayonly window If (iCrnt and Focus(Self)=Current_Object) Send Next End_Procedure

Page 383: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 13 Lab DD’s Local Buffers & Procedures

Data Access Corporation 383

Did You Discover?

1. In the lab, we sent the Adjust_Running_Empl_Total message from the Update andBackout procedures. We are only adding one or/and subtracting one employee to theDept.Number_of_Empl field. Creating is only called on a New save and Deleting isonly called on a Deletion of the Empl Record. Could Creating and Deletingprocedures been used instead?

2. Can you write a business rule so that a company must have a "NAME" (must not beblank?)

3. Can you write a business rule so that a company record can never be deleted?

4. In the Dept Backout and Update, we do not explicitly say "Save Company". Whenyou delete or save a Dept record, is the Company total budget updated and saved?Why?

Page 384: Discovering Visual DataFlex 9.1

Lesson 13 Lab DD’s Local Buffers & Procedures Discovering Visual DataFlex

384 Data Access Corporation

Page 385: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 14 Classes Within the Studio

Data Access Corporation 385

Lesson 14Classes Within the Studio

This lesson covers the creating of new classes. These classes are then made accessiblevia the Studio.

Topics in this Chapter:♦ Building New Subclasses

♦ Switching Classes the Studio Uses

♦ Creating SubClass Layering

♦ Templates

♦ DFS Files

♦ DFO Files

♦ Using Subclasses in the Studio

♦ Local & Global directories

♦ Lab 14

• Steps to Add a New Class to the Controls Palette

Page 386: Discovering Visual DataFlex 9.1

Lesson 14 Classes Within the Studio Discovering Visual DataFlex

386 Data Access Corporation

Building New SubclassesBuilding a new class is like building a new tool that you can then use to build objects.You start with an existing class and build your subclass from it.

Let’s look at the DataDictionary class. The DataDictionay Class is the most commonsubclassed. This was done within Database Builder when we created each file. The DDfile contains this subclass. This allows us to have one centralized file that holds all therules for an individual database. If all our views use this new subclass, then we will haveconsistent behavior throughout our application. A new business rule added to the classwill affect all views!

The DataDictionary class is not the only class that we can subclass. If we continuallyhave to modify an object – it is a good indication that we should subclass.

Syntax for creating a Class:

Class subclass is a Super_Class Procedure Construct_Object Forward Send Construct_Object // declare new properties // initialize properties (with the SET command) // define child objects // define accelerator keys / or modify them End_Procedure // Procedure & Functions are added here End_Class

Page 387: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 14 Classes Within the Studio

Data Access Corporation 387

Here we create a new subclass. In addition to the behaviors already present in theAppClientArea Class, it sets the corporate logo as a background and creates a newproperty called pRestrict_Rights. Objects built from this new class will have thecorporate logo displayed and can “SET” or “GET” the value of the pRestrict_Rightsproperty.

// Stored in cCorp_AppClientArea.pkg file in the \PKG (global) or AppSrc (local) directory: Class cCorp_AppClientArea is a AppClientArea Procedure Construct_Object Forward Send Construct_Object Set Bitmap to “CorpLogo.bmp” Property Integer pRestrict_Rights 0 End_Procedure End_Class

Note: The DataDictionary class uses a special constructor procedure called Define_Fields.Other subclasses use the Construct_Object syntax.

Page 388: Discovering Visual DataFlex 9.1

Lesson 14 Classes Within the Studio Discovering Visual DataFlex

388 Data Access Corporation

Switching Classes the Studio UsesThis dialog allows you to change the default class that the Studio uses when buildingobjects. In turn, this affects the objects built from the Controls Palette and other tools.

Within the Studio:

Tools | ConfigureEnvironment[[[[ Classes tab page[[[[ Close the dialog

Figure 266

Page 389: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 14 Classes Within the Studio

Data Access Corporat

Creating SubClass LayeringWhen developing your applications, it is a wise decision not to use Data Access’ssupplied classes directly but, instead, to use your own subclasses of them.

The Studio will create two basic layers of subclasses, a Global layer that affects all workareas and an individual Workspace layer for each workspace. This means you can finetune each workspace for the individual customer, but if a feature should affect allworkspaces, it would be added to the Global layer.

As a development stdirectly from the supsubclass the Global

This diagram outlin

Take the Button clahierarchy would loo

Button (Visual Data

+-cMyButton (Glo

+-cWsButton (W

In your applicationsclasses: you would uButton class (as DatcMyButton class thainclude setting defau(changing colors, foclasses, or new featuchanges specific to subclasses, they wil

F Packages

space Lay

VD

i

r

l

e

sk

F

,

a

n

al

lobal Layer

G

. . .space space Layer

Work er Work

on

ategy, you will create plied classes. Then, foayer to create a Works

s the hierarchy of class

s as an example and us:

lex Supplied base clas

bal subclass – here the

orkspace subclass – th

you would not create ose only the cWsButton Access would do that

t you wanted all your Wlts different from thosets, etc.), and they coulres. You would chang Workspace. As these automatically have all

Layer Work

389

a Global layer of subclasses, descendedr each Workspace that you create, you willpace layer.

es that will then exist:

ing the supplied defaults, this is how the

s)

size could be globally changed)

e color could be changed for each customer)

bjects from the Button or cMyButton. You would never make changes to the), but you would make changes to the global

orkspaces to include. These changes would supplied that are appropriate for your workd even include bug fixes to those suppliede the Workspace cWsButton to includeclasses are derived from the Globalthe changes of the Global subclasses.

Page 390: Discovering Visual DataFlex 9.1

Lesson 14 Classes Within the Studio Discovering Visual DataFlex

390 Data Access Corporation

When creating a subclass layer, you merely need to provide a few details and the Studiowill automatically create all files that are needed to support the subclass layer.

In a working developmentarea, it is highly suggestedthat you create both Globaland workspace layers.

Creating Global Layer:

Tools | Create Globalsubclass layer

Warning! If you do not wish tocreate a global area (becauseyou already have one createdor for other reasons) then pressCancel button and do notcomplete the step below. Onthe next page, make sure youcheck the Original DAW –installed classes.

[[[[ Preview[[[[ OK[[[[ OK

This will take a little timeto complete

Note that it will replaceall “c” prefix with“cMy”

Figure 267

Figure 268

Page 391: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 14 Classes Within the Studio

Data Access Corporation 391

Creating WorkspaceLayer:

Workspace | Createsubclass layer

[[[[ Preview[[[[ OK[[[[ OK

Note that it will replaceall “cMy” prefix with“cWs”

Figure 269

Figure 270

check this radioONLY if you did NOTcreate a global layer

Page 392: Discovering Visual DataFlex 9.1

Lesson 14 Classes Within the Studio Discovering Visual DataFlex

392 Data Access Corporation

Templates (Speeding Development)Manual code additions are often required to enforce business rules and to ensure theview operates correctly. Creating Templates will eliminate the repeating of customadditions that we want standardized within all our objects, views and/or applications.There is no reason to re-create the wheel each time we create a similar section of code.

The Studio will support templates at global and local levels:

1 Sub-component templates (a group of objects that can be saved & reloaded)

• DFS DF Sub Components

2 Component templates (Lesson 4 created a View640x480 and Invoice_StyleView templates)

• TPV Template View files

• TPR Template Report files• TPL Template List files• TPD Template Dialog files

Sub-component templates: A sub-component is any group of objects that can be saved toa file and reused in a component. What we are really doing is sort of a cut and paste intothe component code.

Component templates: Any component (View, Report, Lookup list, Dialogs) can besaved as a template.

Page 393: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 14 Classes Within the Studio

Data Access Corporation 393

DFS filesA .DFS file is a DF Sub-component template. DFS files can be saved as Global or Localworkspace files, stored in the \Visual DataFlex 9.1\Usr\Global\IdeSrc or local workspace\IdeSrc directory.

Create a view & draga RadioGroup fromthe Base Containerstab

Change the Grouplabel to “SendReport to:”Change the Radioslabels to “Screen”;“Printer” & “File”

Cut & paste themanual code fromthe Code_Mod.txtfile to the RadioGroup within theNotify_Select_Stateprocedure

We now have a component template that could be used for Crystal report views.

//----------------------------------------------------------------------- // Add to the Notify_Select_State procedure of the Radio_Group //----------------------------------------------------------------------- Case Begin Case (iToItem =0) Set Output_Device_Mode To PRINT_TO_WINDOW Case Break Case (iToItem =1) Set Output_Device_Mode To PRINT_TO_PRINTER Case Break Case (iToItem =2) Set Output_Device_Mode To PRINT_TO_FILE Case Break Case End

Page 394: Discovering Visual DataFlex 9.1

Lesson 14 Classes Within the Studio Discovering Visual DataFlex

394 Data Access Corporation

Saving a DFS:

[[[[ RadioGroup

Component | Saveobject Sub-Component| Local

EnterCrystal_Print_Radio[[[[ Save

Close the VIEWwithout saving

Figure 272

Page 395: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 14 Classes Within the Studio

Data Access Corporation 395

Inserting a DFS

[[[[ the New StandardReportView button

Component | Insertobject Sub-Component | Local

[[[[Crystal_Print_Radio.dfs[[[[ Open

Save this new reportas RptRadio thenclose the view andreopen it

Notice ourRadioGroup has thelabels and the addedcode in the editor

Figure 273

New Standard ReportView

Page 396: Discovering Visual DataFlex 9.1

Lesson 14 Classes Within the Studio Discovering Visual DataFlex

396 Data Access Corporation

DFO FilesA .DFO file is also known as an object preference file. This file can be used to setproperties, add custom source code, or to create additional child objects. When a newobject is created by the Studio, the object's preference file is processed and added to theobject. DFO files can be saved as Global or local workspace files, stored in the \VisualDataFlex 9.1\Usr\Global\IdeSrc or local workspace \IdeSrc directory.

Close all othercomponents[[[[ New StandardView button

Drag acWSDbForm fromData tab

Change the objectname to oName1and the LabelName1

Figure 274

Page 397: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 14 Classes Within the Studio

Data Access Corporation 397

We will be changing the Form_Border.

File | New File

Cut the followingcode fromCode_Mod.txt andpaste it into thisnew file.

Save the file ascWsDbForm.dfo inthe workspace\IdeSrc directory

//AB/ OBJECTDEF Object Set Form_Border to Border_None //AB-StoreStart //Procedure //End_Procedure //AB-StoreEnd End_Object

Figure 275

Anything between the //AB-StoreStart&End markers willbe added to the object andaccessible in the CodeExplorer.

Page 398: Discovering Visual DataFlex 9.1

Lesson 14 Classes Within the Studio Discovering Visual DataFlex

398 Data Access Corporation

Drag anothercWsDbForm intothe view

Change the objectname to oName2and the LabelName2

/ Name2 to bringup the CodeExplorer (thecomments fromthe DFO shouldshow)

Save as“TestNewDFO”then close the view

Figure 276

Page 399: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 14 Classes Within the Studio

Data Access Corporation 399

Using Subclasses in the StudioSubclasses are new tools that are built from existing classes adding or changing thefeatures of the superclass.

Basic Steps to Create a Subclass to be used in the Studio:Step #1 Create a new subclass.

Create a new subclass and save it as a .PKG file

Step #2 Create .DFC file

The .DFC file informs the Studio how to handle your new class. Include the line SetClassPackage To "Classname.pkg" OR add Use ClassName.pkg line to yourDFAllEnt.pkg and pre-compile it. Creating .DFC file will be demonstrated in the lab.

The Studio can now display simple comments for each property in the Property Window.This is accomplished by changing the property declarations in a class's DFC file. Thegeneral syntax is to add the comment at the end of the property declaration after a "//".

For example:

Property Complex Size 150 300 // Object Size (Complex: height, width)

Several special comment markers are allowed.

Marker Description// - This means delete any comment that might exist from the super class.

Comment will be blank.Note required space between // and -. Only the single - is allowed

// + xxxxxxx Append text following the + to any existing superclass comment. Old andnew comment will be separated by a space. Note required space between// and +No comment or Use super class comment. Normally, just leave thecomment //

// xxxxxxxx Replace existing comment

Page 400: Discovering Visual DataFlex 9.1

Lesson 14 Classes Within the Studio Discovering Visual DataFlex

400 Data Access Corporation

Step #3 Updating the Studio’s Controls Palette Tool

(required only if class should be visible on the Controls Palette tool)

Copy the required 24X24 bitmap (to be used on the button in the Controls Palette) to the\IdeSrc area. Add your new subclass information to Maintain Class-List (located on theTools pull-down of the Studio).

Note: Naming Convention - Use the same name for the class, the package file, the descriptionfile(dfc) and the bitmap file. The Maintain Class-List dialog is optimized for this notation.

Ex: BigButton

1. Class BigButton is a Button . . .

Save the DataFlex class in a file called BigButton.pkg

2. Create the Studio class file as BigButton.dfc

3. Create a bitmap to be displayed on the Controls Palette, called BigButton.bmp

Page 401: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 14 Classes Within the Studio

Data Access Corporation 401

Local & Global directories

Most of the files discussed in this lesson are stored in the IdeSrc directory. Local filesare used only by the local workspace. Global files are used by all workspace.

Files Fileextensions

Local Workspace Global

Sub Components &

ComponentTemplates

.DFS

.TPV

.TPR

.TPL

.TPD

\IdeSrc \Usr\Global\IdeSrc

Object Preference .DFO \IdeSrc \Usr\Global\IdeSrc

Sub Classes .DFC

.PKG

\IdeSrc

\AppSrc

\Usr\Global\IdeSrc

Page 402: Discovering Visual DataFlex 9.1

Lesson 14 Lab Lesson 14 Lab Discovering Visual DataFlex

402 Data Access Corporation

Lesson 14 LabDescription:

This lab creates a new class and adds it to the Controls Palette for use within the Studio.

Tasks:

Steps to Add a New Class to the Controls PaletteStep #1. Create the new subclass

Our example is alarge print buttonwith a printer.bmpdisplayed on it.

Create a new fileFile | Open New

Cut the followingcode fromCode_Mod.txt andpaste it into a new filein the Code Editor.

Save it ascWsPrint_Button.PKGin the workspace\AppSrc directory

// Add to the new file called cWSPrint_Button.PKG // cWsPrint_Button class is a print button // that has a printer bitmap displayed on it. Class cWsPrint_Button is a Button Procedure Construct_Object Forward Send Construct_Object Set Bitmap to "cWsPrint_Button.bmp" Set Size To 28 30 End_Procedure End_Class

Figure 277

Page 403: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 14 Lab Lesson 14 Lab

Data Access Corporation

Step #2a Create .DFC file

The .DFC file tells the Studio how to use the new class

//AB/ CLASSDEF // Add to the new file called cWSPrint_Button.DFC Class cWsPrint_Button is a Button Set ClassPackage to “cWsPrint_Button.pkg” Inherit Property No_Visible No_Generate String Bitmap “cWsPrint_Bu Property Complex Size 28 30 End_Class

Step #2b Create .DFO file (this is not require)

The .DFO file tells the Studio how to use the new class

//AB/ OBJECTDEF Object //AB-StoreStart Procedure OnClick End_Procedure // OnClick //AB-StoreEnd End_Object

File

llowing

.txt andto the Code

Button.DFCkspaceectory

tton.bmp”

FFFile | New

Cut the focode fromCode_Modpaste it inEditor

Save it ascWsPrint_in the wor\IdeSrc dir

File

lowing code_Mod.txtit into ther

utton.DFOspacectory

FFFile | New

Cut the folfrom Codeand paste Code Edito

Save it ascWsPrint_Bin the work\IdeSrc dire

403

Page 404: Discovering Visual DataFlex 9.1

Lesson 14 Lab Lesson 14 Lab Discovering Visual DataFlex

404 Data Access Corporation

The class .PKG file would have to be added and pre-compiled in your DFAllEnt.PKG, ifthe “Set ClassPackage” line is removed from the .DFC.

The DFC options arefully described in theon-line help. Quicklylook over this section

Open the WinHelp File

[[[[ Studio[[[[ Advanced Topics[[[[ Using Your OwnSubclasses[[[[ Anatomy of StudioSubclasses[[[[ IntroductionLook up “Inherit” andthe other lines thatwere used in our .DFC

**

Figure 278

Page 405: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 14 Lab Lesson 14 Lab

Data Access Corporation 405

Step #3 Updating the Studio’s Controls Palette Tool

Close programs andcomponents in theStudio

[[[[ Tools[[[[ Configure Class-List[[[[ Workspace tab[[[[ Add button

Enter the data for thenew class

[[[[ Add button[[[[ OKFrom Windowsexplorer copy thecWsPrint_Button.bmpfrom the training CD tothe workspace\Bitmaps directory

The order of our tab pages and controls are in the same order shown in this list. TheGlobal list is created first and then the workspace ones. Therefore, our new tab pageshould be created last.

Figure 279

Page 406: Discovering Visual DataFlex 9.1

Lesson 14 Lab Lesson 14 Lab Discovering Visual DataFlex

406 Data Access Corporation

Create a new viewusing your newcontrol

Save view asTestbutton

Compile and testyour new control –remember theOnClick will not worksince it is empty.

Notice that thebitmap property isno longer displayedin the ObjectProperties dialogand the button sizeis larger

Figure 280

Page 407: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 14 Lab Lesson 14 Lab

Data Access Corporation 407

Did You Discover?

1. Why create Subclasses?

2. A few classes listed in the Configure Class-List have the Image and Page columnsempty. Why?

3. In many lessons, we have discussed ways that make developing faster and easier.Can you name the files extensions that are created to speed development?

4. In an earlier lesson, an Invoice_Style template was created in the Global area. Whatwould have to be done to remove this global template?

Page 408: Discovering Visual DataFlex 9.1

Lesson 14 Lab Lesson 14 Lab Discovering Visual DataFlex

408 Data Access Corporation

Page 409: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 15 Batch Processing

Data Access Corporation 409

Lesson 15Batch Processing

This lesson covers Business Process Objects (BPOs). They are used whenever batchprocessing of records is required.

Topics in this Chapter:♦ Business Processing Objects (BPO)

♦ Batch Process using DDOs

♦ Lab 15

• BPO to Update Company Fields in Dept Records

• BPO to Log Employees Out at End of Day

Page 410: Discovering Visual DataFlex 9.1

Lesson 15 Batch Processing Discovering Visual DataFlex

410 Data Access Corporation

Business Process Objects (BPO)When we added the Company File in the prior lab, we created orphan records in the Deptfile. We need to update these Dept Records so they contain valid data in the Companyfield. We use Business Process Objects (BPO) for batch processing of records. Here isa code segment that will read all Dept records and save them with the DAW companycode in them.

Object oUpdateRecords_BP is a BusinessProcess Set Location to 15 51 Set Process_Caption to "Update_Records" //AB-StoreStart Open Dept // use these to keep track of process Property Integer piChanged_Count 0 Property Boolean pbProcess_Completed_State False Set Allow_Cancel_State to True // We will not use a DDO structure. // This is because we are updating orphan records. // The datadictionary would try to do an "Attach" during the save. // Create the process. Procedure OnProcess Boolean bExit Repeat // scan records. Clear Dept Find GT Dept.Company_Code // Will not have to seed the Index since we are // looking for blank Dept.Company_Code If (Dept.Company_Code <> "") Break // Jump out of index - all blanks have been updated Send Update_Status ("Updating data" * String(Dept.RecNum)) ReRead Dept Move "DAW" to Dept.Company_Code SaveRecord Dept Unlock Set piChanged_Count to (piChanged_Count(Self)+1) // count items changed Get Cancel_Check to bExit // check for cancel of status panel Until (bExit)

Page 411: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 15 Batch Processing

Data Access Corporation 411

// if the process was canceled roll back If bExit ; Send Log_Status "Process was Canceled" Else Begin Set pbProcess_Completed_State to True End End_Procedure // This message runs the process. // We augment this to print a status dialog when finished Procedure DoProcess Boolean bDone String sChgCount Set piChanged_Count to 0 Set pbProcess_Completed_State to False Forward Send DoProcess Get piChanged_Count to sChgCount Get pbProcess_Completed_State to bDone Send Info_Box (If(bDone,"Process Completed", "Process was canceled") + ; "\n\n Logged " * sChgCount * "Dept Records Changed!") // the "\n\n" will start a new line End_Procedure //AB-StoreEnd End_Object // oUpdateRecords_BP

Page 412: Discovering Visual DataFlex 9.1

Lesson 15 Batch Processing Discovering Visual DataFlex

412 Data Access Corporation

Batch Process using DDOsThe following BusinessProcess object will be used to log all the employees out at theend of the day. The process will start from the OnClick event of a Button sending theDoProcess message.

Object oEveryoneGone_BP is a BusinessProcess Set Location to 62 22 Set Process_Caption to "Update Records" //AB-StoreStart //Use these to keep track of process Property Integer piChanged_Count 0 Property Boolean pbProcess_Completed_State False Set Allow_Cancel_State to True // we need a complete DDO structure // If deleting records all child DDOs - Deletes propagate down // If saving records all Parent DDO - Saves propagate up Object Company_DD is a Company_DataDictionary End_Object // Company_DD Object Dept_DD is a Dept_DataDictionary Set DDO_Server to Company_DD End_Object // Dept_DD Object Empl_DD is a Empl_DataDictionary Set DDO_Server to Dept_DD Procedure Update Forward Send Update Move "O" to Empl.logged End_Procedure End_Object // Empl_DD // Create the process. Procedure OnProcess Handle hoDD Boolean bExit Move Empl_DD to hoDD // object id of empl dd Repeat // scan all records.

Page 413: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 15 Batch Processing

Data Access Corporation 413

Send Clear to hoDD Send Find to hoDD GT Index.4 // Will not have to seed the Index // Empl.logged field should only contain "I" or "O" If (Empl.logged = "O") Break // Jump out of index Send Update_Status ("Updating data" * Empl.Last_name) Send Request_Save to hoDD Set piChanged_Count to (piChanged_Count(Self)+1) // count items Get Cancel_Check to bExit // check for cancel of status panel Until (bExit) If bExit ; Send Log_Status "Process was Canceled" Else Begin Set pbProcess_Completed_State to True End End_Procedure // This message runs the process. // We augment this to print a status dialog when finished Procedure DoProcess Boolean bDone String sChgCount Set piChanged_Count to 0 Set pbProcess_Completed_State to False Forward Send DoProcess Get piChanged_Count to sChgCount // use counter to report records changed Get pbProcess_Completed_State to bDone Send Info_Box (If(bDone,"Process Completed","Process was canceled") + ; "\n\n Logged " * sChgCount * "Employees Out!") // the "\n\n" will start a new line End_Procedure //AB-StoreEnd End_Object // oEveryoneGone_BP

Page 414: Discovering Visual DataFlex 9.1

Lesson 15 Lab Batch Processing Discovering Visual DataFlex

414 Data Access Corporation

Lesson 15 LabDescription:

The two BPOs covered in the lesson will be used in this lab. Both will be attached tobuttons that will start the processes. When we created the new Company file and addedthe new Company_Code field in the Dept file, this created a problem that this field wasblank. This lab will correct the problem by inserting a company code into all blankDept.Company_Code fields.

Tasks:

BPO to Update Company Fields in Dept Records

Create a new viewDrag a BPO (BusinessProcess) and a button objectto the view

Set the button object name tooStart_Process and the labelto Start Process

Cut and paste the code fromCode_Mod.txt to the Button’sOnClick procedure

// add this code to Start_Process button Send DoProcess of oUpdateRecords_BP

Figure 281

Page 415: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 15 Lab Batch Processing

Data Access Corporation 415

Set the BP object nameoUpdateRecords_BPSet theProcess_Caption toUpdate_Records

Cut and paste the codefrom Code_Mod.txt to theBP – Replacing allexisting code andcomments (EXCEPT forgreen line)

Save as UpdateCoCompile & Test

Verify all records areupdated with DatabaseExplorer

//---------------------------------------------------------- // Add to the oUpdateRecords_BP Open Dept // use these to keep track of process Property Integer piChanged_Count 0 Property Boolean pbProcess_Completed_State False Set Allow_Cancel_State to True // We will not use a DDO structure. // This is because we are updating orphan records. // The datadictionary would try to do an “Attach” during the save. // Create the process. Procedure OnProcess Boolean bExit Repeat // scan records. Clear Dept Find GT Dept.Company_Code // Will not have to seed the Index since we are

Figure 282

Page 416: Discovering Visual DataFlex 9.1

Lesson 15 Lab Batch Processing Discovering Visual DataFlex

416 Data Access Corporation

// looking for blank Dept.Company_Code If (Dept.Company_Code <> "") Break // Jump out of index - all blanks have been updated Send Update_Status ("Updating data" * String(Dept.RecNum)) ReRead Dept Move "DAW" to Dept.Company_Code SaveRecord Dept Unlock Set piChanged_Count to (piChanged_Count(Self)+1) // count items changed Get Cancel_Check to bExit // check for cancel of status panel Until (bExit) // if the process was canceled roll back If bExit ; Send Log_Status "Process was Canceled" Else Begin Set pbProcess_Completed_State to True End End_Procedure // This message runs the process. // We augment this to print a status dialog when finished Procedure DoProcess Boolean bDone String sChgCount Set piChanged_Count to 0 Set pbProcess_Completed_State to False Forward Send DoProcess Get piChanged_Count to sChgCount Get pbProcess_Completed_State to bDone Send Info_Box (If(bDone,"Process Completed", "Process was canceled") + ; "\n\n Logged " * sChgCount * "Dept Records Changed!") // the "\n\n" will start a new line End_Procedure

Page 417: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 15 Lab Batch Processing

Data Access Corporation 417

BPO to Log Employees Out at End of Day

This new button willallow us to quicklylog all remainingemployees out at theend of the day.

Open TC_Out viewAdd a Button and BPobjectSet the button Labelto Everyone Goneand the object nameto oGoneButtonCut and Paste code tothe button

// add this code to the Everyone Gone button Send DoProcess of oEveryoneGone_BP Send Beginning_of_Data of oEmpl_Grid

Figure 283

Page 418: Discovering Visual DataFlex 9.1

Lesson 15 Lab Batch Processing Discovering Visual DataFlex

418 Data Access Corporation

Label the BP objectoEveryoneGone_BPSet these properties:Process_Caption toUpdate_Records

Cut and Paste codeto the BP replacingcode already there(EXCEPT for greenline)

Compile & Test view

If you do not haveany employees thatare logged in, youmay have to compilethe entire programand log in someemployees first.

// Add to oEveryoneGone_BP // use these to keep track of process Property Integer piChanged_Count 0 Property Boolean pbProcess_Completed_State False Set Allow_Cancel_State to True // we need a complete DDO structure // If deleting records all child DDOs - Deletes propagate down // If saving records all Parent DDO - Saves propagate up Object Company_DD is a Company_DataDictionary End_Object // Company_DD Object Dept_DD is a Dept_DataDictionary Set DDO_Server to Company_DD End_Object // Dept_DD

Figure 284

Page 419: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 15 Lab Batch Processing

Data Access Corporation 419

Object Empl_DD is a Empl_DataDictionary Set DDO_Server to Dept_DD Procedure Update Forward Send Update Move "O" to Empl.logged End_Procedure End_Object // Empl_DD // Create the process. Procedure OnProcess Handle hoDD Boolean bExit Move Empl_DD to hoDD // object id of empl dd Repeat // scan all records. Send Clear to hoDD Send Find to hoDD GT Index.4 // Will not have to seed the Index // Empl.logged field should only contain "I" or "O" If (Empl.logged = "O") Break // Jump out of index Send Update_Status ("Updating data" * Empl.Last_name) Send Request_Save to hoDD Set piChanged_Count to (piChanged_Count(Self)+1) // count items Get Cancel_Check to bExit // check for cancel of status panel Until (bExit) If bExit ; Send Log_Status "Process was Canceled" Else Begin Set pbProcess_Completed_State to True End End_Procedure // This message runs the process. // We augment this to print a status dialog when finished Procedure DoProcess Boolean bDone String sChgCount Set piChanged_Count to 0 Set pbProcess_Completed_State to False Forward Send DoProcess Get piChanged_Count to sChgCount // use counter to report records changed Get pbProcess_Completed_State to bDone

Page 420: Discovering Visual DataFlex 9.1

Lesson 15 Lab Batch Processing Discovering Visual DataFlex

420 Data Access Corporation

Send Info_Box (If(bDone,"Process Completed","Process was canceled") + ; "\n\n Logged " * sChgCount * "Employees Out!") // the "\n\n" will start a new line End_Procedure

Page 421: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 15 Lab Batch Processing

Data Access Corporation 421

Did You Discover?

1. Will the Business Process still work if you remove the DoProcess Procedure?

2. Can you still use procedural code instead of BPO to process records?

Page 422: Discovering Visual DataFlex 9.1

Lesson 15 Lab Batch Processing Discovering Visual DataFlex

422 Data Access Corporation

Page 423: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 16 Reporting

Data Access Corporation 423

Lesson 16Reporting

This lesson covers the creating of reports via the report wizards and adding report viewsto your VDF application.

Crystal is a powerful report writer that allows you to quickly create .RPT files that canbe called from a VDF program. You will need Crystal Reports installed to completesome of the features covered in this lesson.

Topics in this Chapter:o Comparing the Reporting Methods

o BasicReport Class

o WinReport (WinPrint)

o CrystalReport Class

o Lab 16

• Using WinPrint Report Wizard

• Using Crysal Report Wizard

• Adding a Print Button to an Entry View

Page 424: Discovering Visual DataFlex 9.1

Lesson 16 Reporting Discovering Visual DataFlex

424 Data Access Corporation

Comparing the Reporting Methods

BasicReport ClassThis class will produce a report that is similar to the procedural Report macro. It islimited in its capabilities (formatting and fonts). It is useful to produce reports that willbe printed to dot matrix printers. Since the output is limited it will not be covered in thismanual, see the on-line help and the Developing Visual DataFlex Applications manualfor a full description of this class.

WinReport (WinPrint)WinReport is a subclass of the BasicReport so there are many similarities to theirstructure. WinPrint is capable of font changes and record selection. The WinPrintReport Wizard will use this class when generating code.

CrystalReport ClassCrystalReport is a class that will use a .RPT file that was created using the CrystalReport Writer software. This report writer will generate great looking reports in minimaltime. Crystal is full of features such as adding bitmaps, changing fonts and color, recordselection and sort order. The Crystal Report Wizard will use this class when generatingcode.

The Crystal product can be purchased separately. Combined with the DataFlexConnectivity Kit for Crystal Reports, it can access DataFlex databases. Afterinstallation, you will be able to produce the .RPT files that the CrystalReport Class willrun. Your customers will not be required to purchase the Crystal product. The .RPTfiles will be launched from your VDF application.

Page 425: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 16 Lab Reporting

Data Access Corporation 425

Lesson 16 Lab

Description:

Creating a WinPrint and Crystal report using the report wizards.

Tasks:

Using WinPrint Report Wizard

File | New | Report[[[[ WinPrint ReportWizard[[[[ OK button

Figure 285

Page 426: Discovering Visual DataFlex 9.1

Lesson 16 Lab Reporting Discovering Visual DataFlex

426 Data Access Corporation

Dept_Budget[[[[ Next

[[[[ Next

Figure 286

Figure 287

Page 427: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 16 Lab Reporting

Data Access Corporation 427

[[[[ DEPT

[[[[ Next

[[[[ Next

Figure 288

Figure 289

Page 428: Discovering Visual DataFlex 9.1

Lesson 16 Lab Reporting Discovering Visual DataFlex

428 Data Access Corporation

[[[[ Name[[[[ Budget[[[[ Company_Code[[[[ Next

Figure 290

Page 429: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 16 Lab Reporting

Data Access Corporation 429

[[[[Dept.Company_Code[[[[ Next

[[[[ Index 3[[[[ Next

Figure 291

Figure 292

Page 430: Discovering Visual DataFlex 9.1

Lesson 16 Lab Reporting Discovering Visual DataFlex

430 Data Access Corporation

[[[[ Finish Button

Be sure yourapplication isopened. (File |Open Program)

[[[[ Code Explorer[[[[ Add Component[[[[ Reports (toexpand)[[[[ Dept_Budget.rv[[[[ Add[[[[ Close

Figure 293

Figure 294

Code Explorer’sAdd Componetbutton

Page 431: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 16 Lab Reporting

Data Access Corporation 431

Compile and run yournew report

Leaving the selectioncriteria blank will printall records.

You may wish to addmore records so yourreport has more toprint.

Open the reportcomponent andlook over thegenerated code.

If you look at theabove Screen shotof the report – Youmay notice a smallproblem with theheader ofCompany_Code. Itis missing the last“e”

To correct thislookup thecommandDFWritePos andenlarge theMaxLength to 2.50

Figure 295

Figure 296

Page 432: Discovering Visual DataFlex 9.1

Lesson 16 Lab Reporting Discovering Visual DataFlex

432 Data Access Corporation

Using Crystal Report WizardThe wizards make creating the reports very easy. Study the code after it is generated tolearn valuable coding skills. Review the reports that are available in the examples. The

Order sampleprogram has manygood reports.

File | New | Report[[[[ Crystal ReportWizard[[[[ OK

[[[[ Next button

Figure 297

Figure 298

Page 433: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 16 Lab Reporting

Data Access Corporation 433

[[[[ browse (…) button

From the workspace\data directory selectthe Department.RPTfile

[[[[ Open

[[[[ Next button

enter DepartmentReport (Crystal)

[[[[ Next button

Figure 299

Figure 300

Page 434: Discovering Visual DataFlex 9.1

Lesson 16 Lab Reporting Discovering Visual DataFlex

434 Data Access Corporation

[[[[ Next button

[[[[ Dept[[[[ Dept_Code[[[[ Add button[[[[ Next button

A user selection is notalways needed. Thisscreen can be leftblank.

Figure 301

Figure 302

Page 435: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 16 Lab Reporting

Data Access Corporation 435

[[[[ Next button

Indexed fields have ared mark on the icon.This report is groupedby Dept. Therefore, itis limited to what fieldscan be used to sort.The best way todetermine this is to seeif Crystal would allowthe field as the Sortorder. This is true onmany of the options ofthe wizard.

Check all the outputdestinations

[[[[ Next button

Figure 303

Figure 304

Page 436: Discovering Visual DataFlex 9.1

Lesson 16 Lab Reporting Discovering Visual DataFlex

436 Data Access Corporation

[[[[ Finish button

Note: Crystal does not have to be installed on the end users’ machine in order to run theCrystal reports (just needed .dll files). It is necessary to have Crystal installed in order to createthe reports.

Figure 305

Page 437: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 16 Lab Reporting

Data Access Corporation 437

Attach the report tothe application. Openthe application

[[[[ Add Componentbutton[[[[ Reports[[[[ DepartmentReportCrystal.rv

[[[[ Add Button[[[[ Close ButtonCompile and Test

Open the ReportComponent & Studythe code that wasgenerated.Figure 306

Page 438: Discovering Visual DataFlex 9.1

Lesson 16 Lab Reporting Discovering Visual DataFlex

438 Data Access Corporation

Adding a Print Button to an Entry ViewThis step adds a print button and procedure for the print button that will print the currentrecord.

Open theDeptEmpl.vwAdd the Printbutton from theCustom tab page

Set the objectname tooPrintButton

Figure 307

Page 439: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 16 Lab Reporting

Data Access Corporation 439

Open theCode_Mod.txt filein the Studio CodeExplorer

/ the View object(dbView) to bringup the editorCut & Paste thecorrespondingcode into the topareaCut & Paste thecorrespondingcode into thebottom area(below the codethat is alreadythere)

//------------------------------------------------------------------- // Add to the top of the DeptEmpl object // This package will be needed to run the Crystal report //------------------------------------------------------------------- Use CrystalReport.pkg

// Add to the bottom of the DeptEmpl object // Create Crystal report to print the current header record. // Object's access method is: Send Print_It iHeaNumber Object Single_Record_Report is a CrystalReport Property Integer piHeaderNumber 0 Property String psHeaderNumber // need two properties (ASCII & integer) Procedure onInitializeReport

Figure 308

Before adding any codeNotice the selected object

Page 440: Discovering Visual DataFlex 9.1

Lesson 16 Lab Reporting Discovering Visual DataFlex

440 Data Access Corporation

// set the Report titles and selection formula -- toggle the string/integer properties If ((psType_Header_Key(Self)) = "I") Begin Set ReportTitle to ("Print " * (psFileField(Self)) * (piHeaderNumber(Self))) Set SelectionFormula to ("{" + (psFileField(Self)) + "} = " + (piHeaderNumber(Self))) End Else Begin Set ReportTitle to ("Print " * (psFileField(Self)) * (psHeaderNumber(Self))) Set SelectionFormula To ("{" + (psFileField(Self)) + "} = '" + (psHeaderNumber(Self)) + "'") End End_Procedure // pass Header to print Procedure Print_It string sNum Integer iNum If ((psType_Header_Key(Self)) = "I") Begin Move sNum to iNum Set piHeaderNumber to iNum End Else Set psHeaderNumber to sNum Send Run_Report End_Procedure End_Object // print the current order. This message will be sent // by the print button Procedure PrintCurrentRecord Handle hDD Integer iNum iFieldNum String sNum sRepFileName sFileField Get Server to hDD // this will be the header_file DD If (Current_Record(hDD)) Begin // only do this if record exists Move ((psHeaderName(Self)) + ".Rpt") to sRepFileName Set Report_Name of Single_Record_Report to sRepFileName Get psFileField to sFileField Get piKeyFieldnum to iFieldNum // There is a limit here since we expect the psType_Header_Key to be an "I" or "S" (Integer/ String) If ((psType_Header_key(Self)) = "I") begin Get Field_Current_Value of hDD iFieldNum to iNum Move iNum to sNum Send Print_It to Single_Record_Report sNum End Else Begin

Page 441: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 16 Lab Reporting

Data Access Corporation 441

Get Field_Current_Value of hDD iFieldNum to sNum Send Print_It to Single_Record_Report sNum End End End_Procedure // Dynamically set the label Procedure Activating String sLabel_it Move ((psHeaderName(Self)) + " Entry View") to sLabel_it Set Label to sLabel_it End_Procedure

Page 442: Discovering Visual DataFlex 9.1

Lesson 16 Lab Reporting Discovering Visual DataFlex

442 Data Access Corporation

This step will shadow the Print button so it will not be available if there is no record toprint.

From theCode_Mod.txt file,Highlight & Cut theappropriate code(shown below)

/ the First Objectto bring up theeditorPaste code in thebottom area

//------------------------------------------------------------------- // Add to the bottom area of the Dept.Dept_Code dbForm // We want to disable the print button if there is no current record. // The DD notifies all DEOs of any record change. // We can augment any DEO's refresh message to see if a current // record exists and set the Enabled_State of print button accordingly. //------------------------------------------------------------------- Procedure Refresh Integer iMode Integer iRec Forward Send Refresh iMode // if record exists, enable the print button. Get Current_Record of (Server(Self)) to iRec Set Enabled_State of oPrintButton to (iRec>0) //(iRec>0)evaluates to True/False End_Procedure

Page 443: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Lesson 16 Lab Reporting

Data Access Corporation 443

This step will add the OnClick procedure to the print button.

From theCode_Mod.txt file,Highlight & Cutthe appropriatecode (shownbelow)

/ the buttonobject to bring upthe editorPaste code in thebottom area.Paste over theexistingprocedure

Compile and Test(Remember thebutton will beshadowed until arecord is found)

// Added to the bottom of the oPrintButton Procedure OnClick Delegate Send PrintCurrentRecord // defined in view object End_Procedure

Fi 310

Page 444: Discovering Visual DataFlex 9.1

Lesson 16 Lab Reporting Discovering Visual DataFlex

444 Data Access Corporation

Did You Discover?

1. Can you print the selection range in the header of a Crystal report?

Workshop Project:

If time permits and you need a challenge - add the code that would create a Wk_Sumrecord whenever a TimeCard record is saved/deleted.

Page 445: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix A “Did you Discover” Answers

Data Access Corporation 445

Appendix A“Did you Discover” Answers

Page 446: Discovering Visual DataFlex 9.1

Appendix A “Did you Discover” Answers Discovering Visual DataFlex

446 Data Access Corporation

Lesson 1 - Discover Answers1. Which Appendix in this manual has more basic information on the DataFlex

language?

Answer:

Appendix C.

• New DataFlex Users Appendix C “DataFlex Core Information”

• Procedural Programmers Appendix C “OOP Core Information”

• DOS Object Oriented Programmers Appendix C “OOP Core Information”

• Prior VDF Users Appendix C “Prior VDF Users”

2. Create names for the following items:

Sample NameA Local Boolean Variable bVarA Local Integer Variable iVarA Global Integer Variable giVarA Global String Variable gsVarA Class cMyEditAn Object oMyEditAn Integer Property piMyPropertyA String Property psMyPropertyA Variant Property pvMyPropertyA Constant C_MyCounterA Local Integer Variable (used to holdan object ID)

hoObjID

Page 447: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix A “Did you Discover” Answers

Data Access Corporation 447

Lesson 2 - Discover Answers1. Printed in this lesson was a DEF for the TimeCard file that shows its file structure.

Without modifications to the TimeCard file can it have a child file attached to it?Why or Why not? (look in the Appendix C for relationship rules for help)

Answer

No. One of the rules for relationships is that the parent file must be uniquely indexed.Since there are no unique indexes – this file cannot be a parent file, with a child filerelating to it.

2. The lock in the upper right corner must be green to make changes to the first threetab pages. When opening a file it always comes up in red - Is there a way to defaultit to green?

Answer:

Yes, within DDB – the File menu, Configure option and Database Builder tab page thereis a checkbox for “Open tables in normal mode. Normal mode is when the lock is red(non-exclusive rights to the database). Uncheck the option for Exclusive (exclusive lockon the database) showing a green light for database changes.

3. When adding a new field in Database Builder, are the “Add” and “Insert” buttonsrequired to add a new field?

Answer:

No, you can simply type directly into a blank field row. The Insert button will allow youto insert a field between existing fields and the Add button will jump you to bottom of thegrid on the first blank row.

4. When loading a complete file structure (with many relationships) into a newFilelist.CFG, is it important to load the .DEF files in any special file numberposition? Why?

Page 448: Discovering Visual DataFlex 9.1

Appendix A “Did you Discover” Answers Discovering Visual DataFlex

448 Data Access Corporation

Answer: Yes, This is because of file relationships – if the child is pointing to file 4 andyou change the parent’s position in filelist to 9 the file relationship will not be loadedcorrectly. Therefore you will have to load the files in the same file number position. It isalso recommended to add parent files before child files so the parent file number iscreated before the child attempts to relate to the file number.

5. Write down 3 different ways to open a database file in DDB. (open, not create)

Answer:

• From the menu, select File|Open

• From the combo box

• Open As

6. What is End User Mode and how do you set up Database Builder in End User Mode?(hint look this up in the on-line help under the index tab)

Answer:

In this mode, Database Builder cannot modify any file structures, indexes, or DataDictionarys. You can only print file status reports and access the file-maintenanceoptions.

End User Mode allows your application users to access functions such as re-indexing,repair data, and other maintenance functions. Users will be locked out of all otherfunctions.

To place Database Builder in End User Mode, set the window’s registry setting of VDFDefault tag “dbAdminMode” variable as follows: dbAdminMode = OFF

Page 449: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix A “Did you Discover” Answers

Data Access Corporation 449

Lesson 3 - Discover Answers

1. What happens if you enter a 2-digit year into a date window such as Term Date?

Answer:

The year will automatically change to a 4-digit year!

2. What is Epoch and what has it to do with entering dates in a VDF application?

Answer:

EPOCH_VALUE sets the two-digit year value equal or above which dates areconsidered to be in the 1900s and below which dates are considered to be in the 2000s.

The Set_Date_Attribute and Epoch_Value determines if it will add 1900 or 2000 to ayear that was entered as two digit. This setting can be changed easily in the code createdin the Studio. Open a program, and look at the code in the “Program Code” area. Thedefault setting can be changed from the Tools | Configure Environment menu in theGeneral tab page.

3. Predict and check the results of entering the following dates, with Epoch turned onand set to 30? 01/01/00

06/20/52

12/25/30

Answer:

They are automatically converted based on the epoch setting selected.

01/01/2000

06/20/1952

12/25/1930

Page 450: Discovering Visual DataFlex 9.1

Appendix A “Did you Discover” Answers Discovering Visual DataFlex

450 Data Access Corporation

4. What would happen to the tab dialogs if the dialog box was not big enough to holdall three tabs? (add more tabs or shorten the tab dialog box to find out)

Answer:

The tab pages will wrap. There are properties (like Tabwidth_Mode and Mutliline_State)that can alter tabs.

5. What would happen if you shortened the length of the last name window so that theentire last name entered wouldn’t fit in the window?

Answer:

It will scroll to fit as many characters as the length of the data field.

6. Run the program, and type in a last name of “WWWWWWWWWW” (type capitalW’s until you reach the limit (which is the length of the field). Notice that it had toscroll to the right. Clear with the F5 key, and type in a last name of “iiiiiiiiii” (allsmall letters i’s to the limit). How do you determine what the size of a control shouldbe?

Answer:

Window applications can alter fonts styles which makes this difficult. Plus the fact thatyou do not know that will be entered (all W or i letters). The Studio will create a size bydefault that is a very good estimate for the correct size of a control based on the currenttypeface. If you know what the value of a control and need to alter the size at runtime,use the Text_Extent property. Below is a sample of this.

Procedure Activating Forward Send Activating Send AutoSize "WWWWWWWWWWWWWWWWWWWW" End_Procedure Procedure Autosize String Val Integer iExt iHt iWd Get Text_Extent Val To iExt Move (hi(ext)) to iHt Move (low(ext)) to iWd

Page 451: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix A “Did you Discover” Answers

Data Access Corporation 451

Set Guisize To (iHt+3) (iWd+2) Send Adjust_Logicals End_Procedure

7. When using the Object-Order Definition tool, is it important where Textbox objectsare listed?

Answer:

No, they are non-focusable controls so they have no affect in the view navigation.

8. Run our program, and open up the Employee Entry View. Find a Record, then placethe cursor on the parent window (Dept) and press Shift+F2 to delete. Wait! What isgoing to be deleted? The Department or the Employee? Why?

Answer:

Remember that the Accelerator keys send messages (in this case Request_Delete). Themessage will travel by delegation to the dbView, and then (because the dbView has it'sserver set to the Main_DD) the Request_Delete message travels to the Empl_DD. Then,since deletes travel downwards (in the DDO tree), the Employee record is deleted - Notthe Dept. You cannot delete a parent record in most VDF programs unless theprogrammer explicitly codes it.

Page 452: Discovering Visual DataFlex 9.1

Appendix A “Did you Discover” Answers Discovering Visual DataFlex

452 Data Access Corporation

Lesson 4 - Discover Answers

1. What is the normal behavior of the “Shift+F10” if the Append_a_Row procedurewas not available?

Answer:

Normal behavior for the On_Key kAdd_Mode (which is what Shift+F10 sends) is toinsert a blank line in the grid where the cursor is located. Our view made the Add-Modekey send the Append_A_Row that jumps us to the end of the table, and then down onerow (Append_A_Row procedure).

2. In the DataFlex language, how do you continue a command line to the next line?

Answer: Using the semicolon “;” will allow you to continue a command to the next line.

3. Within the DeptEmpl View, go to the grid and enter some test data, but do not savewith the F2 key. . . click on a window in the header . . . can you exit the line itemwithout a save occurring? What if you use the down arrow or up arrow? Does thesave occur?

Answer:

Earlier, we set the Child_Table_State of the dbGrid to true. This enforces a saveoperation before navigation outside the current line is allowed.

4. When the Studio generates the code for an Object the Green Line in the Code Editorwill be replace with what?

Page 453: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix A “Did you Discover” Answers

Data Access Corporation 453

Answer:

With all the Object’s properties set in the Object Properties Tool for this object and anynested objects contained by this object.

5. When you find a Department record (in the header section), only the employees forthat Department are found and displayed. How does the program know to show onlyrelated records in the dbGrid?

Answer:

With the Studio running and the DeptEmpl View open, click on the Database Selectoricon, and choose DDO Tree. Click the “+” sign next to EMPL_DD and take note of thesettings . . . The “DDO_Server” means Empl is related to Dept but it is the Constrainfile that will only allow related records to be displayed (a filter).

6. Create a new view with two dbForm controls, one showing the Empl.Code and theother one showing the Empl.Last_Name. Make the dbForm for the Empl.Codecontrol using the Database Selector. Make the dbForm for the Empl.Last_Nameusing the Controls Palette. When you compile and run your new view did both ofyour controls show data when you find records? What extra step do you have to dowith the Controls Palette when creating data-aware controls?

Answer:

If you are using the Database Selector the connection to the File.Field is already made.If you use the Controls Palette to make Data-aware controls you will have to use theObject Properties dialog (Database tab) and connect to the file.field.

Page 454: Discovering Visual DataFlex 9.1

Appendix A “Did you Discover” Answers Discovering Visual DataFlex

454 Data Access Corporation

Lesson 5 - Discover Answers

1. Where in the Studio and Database Builder will a right-mouse-click call up a popupmenu?

Answer:

The Right Click popup menu is available from almost every entry control in each dialogin Database Builder & the Studio. These menus are helpful for many things includingcutting and pasting.

2. What are the advantages of validation tables over creating a parent related file?

Answer:

Fewer database tables are needed (with the static option there are no database tablesused). Database Builder makes the creation and updating of validation tables very easy.

3. What are the advantages of a parent related file over a validation table.

Answer:

Advantage:

Accessing the data for reports can sometimes be easier. Ex:In Crystal Reports, it wouldbe easier to access the data when it is in a related parent file.

Disadvantage:

A related file would require its own separate file. Data in Validation Tables can becombined into a single file.

Page 455: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix A “Did you Discover” Answers

Data Access Corporation 455

Lesson 6 - Discover Answers

1. When using the magic wand button in the Structures tab page of Database Builder –will it remove unneeded files from the required Child/Parent list?

Answer:

No! It will only add to the list – it will not remove extra files that are already listed –that is why it is important to remove all files before using the button. The Magic WandButton will add to the list any Required Child and Required Parent files that match thefile relationships that are not already in the list.

2. What is the difference between the Validation Error No. & Text on the Field Setting |Validation/Lookup Tab and Validation Error No. & Text on the Options tab?

Answer:

The setting on the Field Setting | Validation/Lookup Tab is only for one field. Thesetting on the Options Tab creates a Field_Error property where ifield is set to -1, whichwill then apply this error setting to every field in the file, applying this Error and Text toall fields that are not individually set.

3. In Database Builder under the METHODS tab if you select a method from theUnaugmented list what happens to the Unaugmented and Implemented lists?

Answer: The selected method is removed from the Unaugmented list and added to theImpliemented list. A timer event fires and updates both lists.

Page 456: Discovering Visual DataFlex 9.1

Appendix A “Did you Discover” Answers Discovering Visual DataFlex

456 Data Access Corporation

Lesson 7 - Discover Answers

1. If you want two views to always display the same records from the database tables,you should?

Answer: Combine the views into one so they both use the same DataDictionarys. Viewsshould operate independent of each other.

Page 457: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix A “Did you Discover” Answers

Data Access Corporation 457

Lesson 8 - Discover Answers

1. Open any Lookup List (Selection List - SL file) in an editor. The code begins withCD_Popup_Object. What does the “CD” stand for?

Example Code:

CD_Popup_Object Empl_SL is a dbModalPanel

Answer:

CD means Create/Destroy. Selection lists are created only when they are “poped up”and destroyed upon exiting. This is done to speed in application load time. In aprogram, which contains many selection lists, this lets the program quickly load intomemory when it starts. Note: Views are not CD-type objects. Views use aDeferred_View command. This will create the view when first activated, but does notdestroy them upon exiting.

2. If you look in the properties of the selection list, the “Ordering” property (whichindex to use) is set to zero. Why is that?

Answer:

Selection lists automatically re-sort themselves based on the field (column) that has thefocus.

3. After the constraint in the Employee View is added, can you save an employee thathas a termination date greater than zero?

Answer:

Yes, you can save an employee with a termination date but after it is saved you will notbe able to bring the record up in the view again. Constrains only affect the finding anddisplaying of records.

Page 458: Discovering Visual DataFlex 9.1

Appendix A “Did you Discover” Answers Discovering Visual DataFlex

458 Data Access Corporation

4. How could you make the Selection List use the same DataDictionary constraints asthe invoking view? (without copying or moving the OnConstrain code from one tothe other)

Answer:

The Auto_Server_State property is exposed in the Studio from the Object Propertiesdialog. If you set this property to “True” in your Lookup it will use the DataDictionaryof the invoking view and be identically constrained.

Page 459: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix A “Did you Discover” Answers

Data Access Corporation 459

Lesson 9 - Discover Answers

1. Do properties forward and delegate like procedures and functions?

Answer:

Yes

2. If I cancel the Request_Clear procedure in a container object that contains manydbForm objects will it affect the Request_Save?

Answer:

Yes, the Request_Save cascades many messages – one of them is the Request_Clearmessage so now when you save it will not clear.

3. What would happened if Forward Send Creating was listed before the Movecommand in TimeCard DD object’s Creating procedure we just added in the lab?

Here is the code:

Procedure Creating // Since the TimeCard.In_or_Out is only one character long // the psInOut property value will be truncated Move (Uppercase(psInOut(Self))) to TimeCard.In_or_Out Forward Send Creating End_Procedure

Answer:

The Empl.Logged field would be blank. Why . . .

If you have a Creating procedure in the DDO of the view and a Creating procedure inthe .DD file, Both will be executed if the DDO does a “Forward send Creating”.Looking at the DataDictionary Creating procedure it “Move TimeCard.In_or_Out toEmpl.Logged” this means if the Forward Send Creating is done first there would benothing in the TimeCard.In_or_Out field to move to the Empl.Logged field.

Page 460: Discovering Visual DataFlex 9.1

Appendix A “Did you Discover” Answers Discovering Visual DataFlex

460 Data Access Corporation

4. Look in the WinHelp to find the names of the other Accelerator-Keys.

Answer: Select the Search key and type Accelerator then select Accelerator – Key-Message and Assignments of the Accelerator-Key-Message-Names.

5. Name as many ways as you can to make a procedure execute.

Answer:

Commands:

Send

Forward Send

Delegate Send

Broadcast Send

On_Key ( and predefined Accelerator keys)

Classes: (many classes can send messages)

Buttons

Radios

List

Events:

Timers (will cover in the next lesson)

Keyboard (as we type)

Mouse

Page 461: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix A “Did you Discover” Answers

Data Access Corporation 461

6. Create a new view with a grid displaying the Empl.Code; Empl.Last_Name andEmpl.Term_Date fields. Use the RadioGroup Class to set up a dynamic constraint toshow:

� All Employees

� Terminated Employees

� Active Employees

// This would be added to the Empl_DD object Property integer piConstrainVal 0 Procedure OnConstrain Integer iConVal Get piConstrainVal to iConVal If (iConVal = 1) Constrain Empl.Term_Date GT 0 If (iConVal = 2) Constrain Empl.Term_Date EQ 0 End_Procedure

// This would be added to the Empl View – built with the Studio. Object RadioGroup1 is a RadioGroup Set Label to "Change Constraints:" Set Size to 39 56 Set Location to 3 7 Set Current_Radio to 0 Object Radio1 is a Radio Set Label to "All Empl” Set Size to 10 39 Set Location to 11 5 End_Object // Radio1 Object Radio2 is a Radio Set Label to "Terminated Employees" Set Size to 10 37 Set Location to 24 5 End_Object // Radio2 Object Radio3 is a Radio

Page 462: Discovering Visual DataFlex 9.1

Appendix A “Did you Discover” Answers Discovering Visual DataFlex

462 Data Access Corporation

Set Label to "Active Employees" Set Size to 10 37 Set Location to 24 5 End_Object // Radio2 Procedure Notify_Select_State Integer iToItem integer iFromItem Forward Send Notify_Select_State iToItem iFromItem Set piConstrainVal of Empl_DD to iToItem Send Rebuild_Constraints of Empl_DD Send Beginning_of_Data to oEmpl_Grid End_Procedure End_Object // RadioGroup1

Page 463: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix A “Did you Discover” Answers

Data Access Corporation 463

Lesson 10 - Discover Answers

1. The lesson mentioned dbEdit as a multi-item class. Name a few other classes that aremulti-item.

Answer:

Grid/dbGrid

List/dbList

Edit/dbEdit

2. What information can you get by clicking on "Help/About..." of a running VDFapplication?

Answer:

You can see how much memory is being used by the current applications. Note: You cancustomize your own about package: see DFAbout.Pkg

Page 464: Discovering Visual DataFlex 9.1

Appendix A “Did you Discover” Answers Discovering Visual DataFlex

464 Data Access Corporation

Lesson 11 - Discover Answers

1. What does the Z compiler option do?

Answer:

It will compile using the debug packages. This will allow you to use the debugger withyour running application.

2. What does the “S” compiler option do?

Answer:

Compiling your code with the “s” symbol option will help in debugging. This option willcreate a larger compiled file because it creates a symbol table in the .EXE file. Nowinstead of a runtime error message that just has the message number – it will give themessage name.

Without the -s option: Invalid message MSG_####

With the -s option: Invalid Message MSG_Print_Label

3. If your users launch 3-4 copies of this program at the same time, how much memorywill it use up?

Answer:

About 2% of system recourses for each copy: not very much! (VDF uses very few systemresources).

Page 465: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix A “Did you Discover” Answers

Data Access Corporation 465

Lesson 12 - Discover Answers

1. Can you make the TC_In view automatically display when the program is executed?

Answer:

Open the “CorporationX Application.Src” program to see how it activates each view.Copy the activate message. Open the Studio to the Program/Code dialog and paste thecommand in just before the line "Start_UI".

2. How can you create an icon on the desktop to automatically run this application?

Answer:

Open the Window Explorer and Drag the compiled .EXE program to the desktop – Thiswill create a shortcut to the program.

3. After completing this lab, will you have to copy the CorpLogo.BMP when deployingyour application? What would you suggest be done?

Answer:

Yes you would have to copy the CorpLogo.BMP file when deploying the applicationbecause we did not list the new file in the CorporationX.cfg. To correct this we wouldadd the file via the Program |Properites dialog and then recompile.

Page 466: Discovering Visual DataFlex 9.1

Appendix A “Did you Discover” Answers Discovering Visual DataFlex

466 Data Access Corporation

Lesson 13 - Discover Answers

1. In the lab, we sent the Adjust_Running_Empl_Total message from the Update andBackout procedures. We are only adding one or/and subtracting one employee to theDept.Number_of_Empl field. Creating is only called on a New save and Deleting isonly called on a Deletion of the Empl Record. Could Creating and Deletingprocedures been used instead?

Answer:

No, At first it would look like it is working because the adding and deleting of employeeswould keep the running count correct but if we change an employee from one dept toanother the running totals would not be correct on this edit save, resulting in both depttotals being incorrect.

2. Can you write a business rule so that a company must have a "NAME" (must not beblank?)

Answer:

Augment Validate_Save in the Company Data Dictionary to make sure the field is notblank or simply set the field option to REQ.

3. Can you write a business rule so that a company record can never be deleted?

Answer:

If you always use DataDictionarys, you can set the No_Delete_State property to true oraugment Validate_Delete of the Company Data Dictionary so that it always returns avalue of 1(so the delete will fail). It could also give a message to the customer that tellsthem what is happening. This will not stop manual deletes that do not useDataDictionarys.

Page 467: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix A “Did you Discover” Answers

Data Access Corporation 467

4. In the Dept Backout and Update, we do not explicitly say "Save Company". Whenyou delete or save a Dept record does the Company total balance get updated andsaved? Why?

Answer:

Yes, it will be saved. In the view, the "tree" of connected Data Dictionarys makes thishappen. The SAVE message propagates up from the main-dd, saving all parent files.The Delete message will propagate downward in the DataDictionary structure, deletingall child records, and then deleting itSelf (as long as the Cascade_Delete_State is true).A SAVE is then sent upwards, saving all the parent files which will save all updates(running totals) to the parent records.

Page 468: Discovering Visual DataFlex 9.1

Appendix A “Did you Discover” Answers Discovering Visual DataFlex

468 Data Access Corporation

Lesson 14 - Discover Answers

1. Why create Subclasses?

Answer:

To create new tools which will speed development, enforce business rules and tomaintain consistency throughout the program.

2. A few classes listed in the Maintain Class-List have the Image and Page columnsempty. Why?

Answer:

These are classes that the Studio will not allow you to drag and drop (such as aDataDictionary) from the Controls Palette tool. Therefore they will not need an image orbe listed under any of the Palette Pages.

3. In many lessons, we have discussed ways that make developing faster and easier.Can you name the files extensions that are created to speed development?

Answer:

TPV - Template ViewsTPL – Template LookupsTPD – Template DialogsTPR – Template ReportsDFS - DatFlex SubComponentsDFO - DataFlex Object PreferencesDFC - DataFlex Classes for the StudioPKG - Package Files storing Classes and support code

A full description of these files is listed on the next few pages.They can be stored Global or Locally: (local) workspace name\IdeSrc\filename (global) VDF 9.1\\usr\global\IdeSrc\filename

Page 469: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix A “Did you Discover” Answers

Data Access Corporation 469

Files that speed Studio development: More Information/Sample

Template Views can be reused tospeed developmentTPV - Template ViewsTPL – Template LookupsTPD – Template DialogsTPR – Template Reports

Loaded by: File | New ComponentSaved by: File | Save as Template

// Entire template view//Lab #4 did this creating the Hdr_Grid.TPV

DFS Files:DatFlex SubComponents

Loaded by: Component | Insert object Sub- ComponentSaved by: Component | Save object Sub- Component

//AB/ SUBCOMPONENTObject Setup is a Button Set Label to "Printer Setup" Set Location to 63 122

//AB-StoreStart Procedure OnClick Integer iReportObj Get Report_Object_ID To iReportObj Send DFPrintSetup To iReportObj End_Procedure //AB-StoreEnd

End_Object // SetupDFO Files:DataFlex Object Preferences

Used to add extra code into the Studiocreated object. The sample to the rightwill add the Procedure OnClick to theobject so it will not have to be entered.

//AB/ OBJECTDEFObject oButton is a Button //AB-StoreStart Procedure OnClick

End_Procedure // OnClick //AB-StoreEndEnd_Object

Page 470: Discovering Visual DataFlex 9.1

Appendix A “Did you Discover” Answers Discovering Visual DataFlex

470 Data Access Corporation

DFC Files:DataFlex Classes

To add your subclass to the ControlsPalette takes 3 steps1. Create your subclass package .pkg2. Create the .DFC file3. Copy the required 24X24 bitmap

used by the Controls Palette to the\bitmap area. Add the subclass tothe Maintain Class-List under theTools pull-down.

//AB/ CLASSDEFClass Button IS A AbstractControl Button ; ABMetaButtonMixin ; DefineABMetaButtonMixin // inherit is removed on purpose Property String Label Property NO_EXECUTE Boolean ; Default_State False Property String Bitmap Property Complex Size 14 50 Property Complex Location 0 0 Property String Status_HelpEnd_Class

PKG Files:Package Files storing Classes

// saved in a MyButton.pkg fileClass cMyButton is a Button Procedure Construct_Object Set Size to 30 30 End_ProcedureEnd_Class

4. In an earlier lesson, an Invoice_Style template was created in the Global area. Whatwould have to be done to remove this global template?

Answer:

File | New Component – select the template and press delete button.

Or you can go to the \VDF 9.1\User\Global\IDESrc directory and directly delete theInvoice_Style.tpv file

Page 471: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix A “Did you Discover” Answers

Data Access Corporation 471

Lesson 15 - Discover Answers

1. Will the Business process still work if you remove the DoProcess Procedure?

Answer:

Yes, DoProcess simply supplies the progress line, the main process is done in theOnProcess event.

2. Can you still use procedural Code instead of BPO to process records?

Answer:

Yes, you can still do any of the procedural loops or For_All methods – BUT they do notuse DataDictionarys so your business rules are not being followed. This is why BPOsare the suggested method. In our lab was an example of when DataDictionarys couldnot be used because we were correcting the relationship field between two files after anewly created relationship was created.

Page 472: Discovering Visual DataFlex 9.1

Appendix A “Did you Discover” Answers Discovering Visual DataFlex

472 Data Access Corporation

Lesson 16 - Discover Answers

1. Can you print the selection range in the header of a Crystal report?

Answer:

Yes you can. In Crystal Reports, create a Parameter. A parameter will prompt the userfor information used in running the report. For example, you can create a date parameterthat asks the user for a date at runtime, such as invoice date > 1/1/2002 for all this yearssales. When you create the selection formula within Crystal Reports, you can chooseinvoice date > (?parameter name). The parameter name will appear on the dropdownbrowse list with a ? in front of the name. Then create a text field in the report header andinsert that parameter in the test field. This will print whatever selection entered as theparameter. If you don't want the user to enter a parameter, just set the default amount tobe whatever you want it to be when you set the parameter up. If you need more info,check the Crystal Reports manual.

Page 473: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix B Problems & Solutions

Data Access Corporation 473

Appendix BProblems & Solutions

Page 474: Discovering Visual DataFlex 9.1

Appendix B Problems & Solutions Discovering Visual DataFlex

474 Data Access Corporation

Popup Messages/QuestionsProblem:

What is the quickest way to ask a yes/no question?

Solution:

If you are simply asking a Yes/No question usethe Confirm function found in dfconfirm.pkg:

Other popup boxes are Info_Box and Stop_Box(both in the Msgbox.pkg).

TheYesNoCancel_Box isalso available.

Figure 311

Get Confirm “Do you wish to Continue?” to RetVal

Figure 312

Figure 313

Figure 314

Send Info_Box "You do not have rights to this area!" Send Stop_Box “It is strongly suggested you \n create a backup before continuing” Get YesNoCancel_Box “Do you wish to save the current setup profile?" to iRetVal

Page 475: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix B Problems & Solutions

Data Access Corporation 475

On_Key {to object} parameter

Problem:

I sometimes have problems using the {of object} parameter with the On_Key command.

Solution:

The command is evaluated at Compile time, NOT runtime. Therefore the receivingobject MUST already be created (adding a Register_Object command will not solve theproblem).

Syntax: On_Key keyname send message {of object} {private}

Workarounds:

1. Move the On_Key command to the bottom of the view so the object is alreadyconstructed.

2. Create a dummy message that then sends the message

On_Key Key_Alt+Key_T send Do_It of Customer_Form

On_Key Key_Alt+Key_T send Dummy Procedure Dummy Send Do_It of Customer_Form End_Procedure

Page 476: Discovering Visual DataFlex 9.1

Appendix B Problems & Solutions Discovering Visual DataFlex

476 Data Access Corporation

Auto Activate First ViewProblem:

I have one view that is the main view. Is it possible to have it activate whenever theapplication starts?

Solution:

To auto-activate, a view you should:

1. Find the activate access method for the desired view (looking at themainprogram.SRC file will show how it activates the views). For example, theaccess method for a Customer_Entry view would most likely beActivate_Customer_Entry.

2. Add the following line to the end of your program right before the Start_UIcommand. You may add this code within the Studio by editing the bottom-code areaof your program.

Send Activate_oCustomerView of (Client_Area(Main))

This assumes that your main program has been created by the Studio and the main outerpanel object’s name is Main and its child client-area object’s name is Client_Area.

You can auto-activate as many views as you wish using this method. The last viewactivated will be the view that takes the focus.

Page 477: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix B Problems & Solutions

Data Access Corporation 477

ToolTip

Problem

Can I set a ToolTip_Value on my buttons to explain when to use them?

Solution:

At the present time you would have to create your own classes to do this. - but futureversions of VDF may support this.

Page 478: Discovering Visual DataFlex 9.1

Appendix B Problems & Solutions Discovering Visual DataFlex

478 Data Access Corporation

Multiple directories in a Path

Problem:

The Initial_Folder property can only contain one directory, but my bitmap path containsmultiple directories. How can I strip the first directory path from a bitmap path thatcontains many directories?

Solution:

This sample will allow you to set the initial folder to the first listed directory that is listedin the bitmap path. If the directory you wish is not the first one then PathAtIndexfunction of the cWorkspace object can help filter out the N-th path.

Procedure Activating Integer hoWorkspace String sBitmapPath Get phoWorkspace of ghoApplication to hoWorkspace Get psBitmapPath of hoWorkspace To sBitmapPath Get PathAtIndex of hoWorkspace sBitmapPath 1 To sBitmapPath // Take the first path entry Set Initial_Folder To sBitmapPath Forward Send Activating End_Procedure // Activating

Page 479: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix B Problems & Solutions

Data Access Corporation 479

Checking filename is only 15 CharactersProblem:

The bitmap filename needs to be limited to 15 characters to function correctly. How do Ilimit the user from selecting a file with more than 15 characters?

Solution:

This sample ensures that the bitmap filename entered is limited to 15 characters.

Function Select_Bitmap Returns String String sBitmapFileName

Integer iFieldLength iFileNameLength iField

Forward Get Select_Bitmap To sBitmapFileName

Get_Fieldnumber Empl.Picture_id To iField

Get_Attribute DF_FIELD_LENGTH Of Empl.File_Number iField To iFieldLength

Move (Length(sBitmapFileName)) To iFileNameLength

If (iFieldLength < iFileNameLength) Begin

Error 130 ("Filename '" + sBitmapFileName + "' too long (size=" + ;

String(iFileNameLength) + ") for picture field (max=" + ;

String(iFieldLength) + ;

")\nFilename and therefore selection will not be used!")

Move "" To sBitmapFileName

End

Function_Return sBitmapFileName

End_Function // Select_Bitmap

Page 480: Discovering Visual DataFlex 9.1

Appendix B Problems & Solutions Discovering Visual DataFlex

480 Data Access Corporation

Procedure SetProblem

Why do some procedures act like a property?

Solution:

This is because they have been created as a “procedure set” instead of simply aprocedure. “Procedure set” is a short cut – it builds a property and procedure in one. Sowhen you set the property it also calls a procedure at the same time. Here is an example:

Procedure Set Item_Options_DisplayOnly integer item# integer state �----------| // two things were passed the item# which in our case T_Date## =1 | // and state which is Crnt (true if non_zero & false if 0) | Set Item_Option Item Item# to NoPut state | Set Item_Option Item Item# to NoEnter state | End_Procedure | | // if transaction header exist, disallow entry in date window | Procedure Refresh integer iMode | Integer iSrvr iCrnt | Get Server to iSrvr // get the data_set | Get Current_Record of iSrvr to iCrnt // get record in data_set | // Set DisplayOnly to iCrnt (is true if non_zero | // DispalyOnly = Noput & NoEnter | // Date## has already been defined by entry_name_item | Set Item_Options_DisplayOnly T_Date## iCrnt -------------------------------------------| Forward Send Refresh iMode // do normal refresh // Don’t leave us sitting on a DisplayOnly Window If ((iCrnt and (Current_Item (Self) = T_Date##) Send Next End_Procedure

When I was learning OOP and using the old OOP Reference manual I was alwayslooking at the beginning of this book at the property chart and then finding what I waslooking for was under the procedure chart – as a procedure set. Take a look at thesecharts in the old manual, you will find lots of procedure sets! Or look in the on-line help.

Page 481: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix B Problems & Solutions

Data Access Corporation 481

Retrieving data from the Windows RegistryProblem:

How do I check the values in the windows registry?

Solution:

This sample will create a file called environ.txt and put the value data of .doc found inWindows Registry.[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Extensions] in a text file called environ.txt. This is normally not needed! Windows registrysetting should really be altered within an interface program like the one found fromwithin

use windows // In previous revisions of DataFlex (3.05x), the command “Get_Foreign_Profile_String” returned values from .INI files. // Visual DataFlex uses the same command but now retrieves values from the window’s registry. // The Get_Foreign_ProfileString will copy values from the registry (regedit.exe). This is similar to Export // Registry File from the registry pull down. It will provide all parameter values. Care must be taken when // parsing the string into acceptable arguments. Incorrect values that are NOT found will return a null string // not an error. This command will NOT change any registry settings. To change settings use the

Set_Foreign_Profile_String command. // [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Extensions] string sValData sRegPath sKey sValueName // Must set the registry root to first two branches. set_registry_root to HKEY_LOCAL_MACHINE 'Software' // Include as arguments : path to registry key, key, value name to return value data move 'Microsoft\Windows\CurrentVersion' to sRegPath move 'Extensions' to sKey move '.doc' to sValueName get_foreign_profile_string sRegPath sKey sValueName to sValData direct_output 'environ.txt' writeln '.doc value is ' sValData close_output

Page 482: Discovering Visual DataFlex 9.1

Appendix B Problems & Solutions Discovering Visual DataFlex

482 Data Access Corporation

Deployment

Problem:

How do I deploy my application?

Solution:

There is a white paper that explains the deploying of VDF applications. You candownload it from our web site at http://www.dataaccess.com/.

Page 483: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix B Problems & Solutions

Data Access Corporation 483

Saving Resources:

Problem:

I have a fairly large application and to make different views look a little different Istarted adding lots of fonts – my application is now running much slower.

Solution:

Changing colors does not use up your resources, so do this freely. Changing fonts; fontstyles (bold/italics) or sizes uses up resources FAST, so do this very sparingly.

Page 484: Discovering Visual DataFlex 9.1

Appendix B Problems & Solutions Discovering Visual DataFlex

484 Data Access Corporation

Customizing error messages: Class GL_Accts_Data_Set is a Data_Set … Procedure Construct_Object integer img# Forward Send Construct_Object img# Set Main_File to GL_Accts.File_Number : Property string Old_Key_ID 0 : End_Procedure // This procedure is called whenever a new record is found Procedure New_Current_Record integer iOldRec# integer iNewRec# Forward Send New_Current_Record iOldRec# iNewRec# Set Old_Key_ID to MyFile.Key_Field End_Procedure // This procedure is called whenever a record is saved Function Validate_Save returns integer String sOldID // Integer iRec# iRetVal Get Current_Record to iRec# Get Old_Key_ID to sOldID // this is our new property! // If an edit (existing record) and the key changed don’t save If (iRec# <> 0 and Myfile.Key_Field <> sOldID) Begin Send Operation_Not_Allowed 301 // custom error message Function_Return 1 End Forward Get Validate_Save to iRetVal If (iRetVal) Function_Return 1 End_Function // augmented for customized error messages (errors generated from the DS) Procedure Operation_Not_Allowed integer iErr# If (iErr# = 301) Error iErr# “Cannot change a GL number” Else (If iErr# = 4140) Error iErr# “Cannot Delete –Account has child records” Else Forward Send Operation_Not_Allowed iErr# End_Procedure

Page 485: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix B Problems & Solutions

Data Access Corporation 485

Adding your own UtilitiesAdding an external program to the Utility pull-down will make accessing it easy fromwithin the Studio.

Utilities | ConfigureUtilities

[[[[ Add button

If you have anexternal program addit to the right side ofthe dialog –otherwise presscancel

Adding a “—SEPARATOR—“ will insert a line in the pull-down.

When entering the command line use the browse button to find the program to run.When typing in the command line use quotes around the entered data so directory namescontaining spaces will not be confused with command line partameters.

Figure 315

Page 486: Discovering Visual DataFlex 9.1

Appendix B Problems & Solutions Discovering Visual DataFlex

486 Data Access Corporation

Maintain Class-Lists

The last item on the tool pull-down allows us toadd or edit subclasses (tools) that the Studio willuse.

The order of the tab pages in the Controls Palettecan be altered by changing the order of the classesin the “Maintain Class List” tool.

The Global tab page lists classes the Studio willuse in all workspaces. The Workspace tab page lists classes used only in the currentworkspace. Each time you change workspaces the Studio rereads this file.

If the “Page” column has anentry the Studio will addthe class in the ControlsPalette tool. The order ofthe Controls Palette tabpages are determined by theorder in the list. If you adda new page name a tab pagewill be created with thatname.

In this example the tabpages would be listed Base;Data; Base Containers; andData Containers. Thecontrols listed under the tab

pages will also be in the order found in the Class-List.

Figure 316

Figure 317

Page 487: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix B Problems & Solutions

Data Access Corporation 487

Field_Default_Value PropertyThis property is used to set defaults. Field_Entry_msg procedures (described later) andField_Defaults procedures (described below) are the most common places theField_Default_Value property is used.

This example is from the OrderHea DataDictionary of the Order Sample.

ProcedureField_Defaults isavailable from the“Method” Tab.

Note (prior OOPprogrammers) Thisprocedure is similar tothe Entry_Defaultsprocedure in the DEOs.

The Field_Defaults procedure sets the field value without setting the DSO’sChanged_State. This will allow the default to show in grids without creating unwantedrecords in the database upon entering and exiting a blank row.

Class OrderHea_DataDictionary is a DataDictionary … Procedure Field_Defaults Forward Send Field_Defaults Date dDate SysDate dDate Set Field_Default_Value Field Orderhea.Date to dDate Set Field_Default_Value Field Orderhea.Terms to “CASH” End_Procedure //Field_Defaults

Figure 318

Page 488: Discovering Visual DataFlex 9.1
Page 489: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 489

Appendix CCore Information

Page 490: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

490 Data Access Corporation

Accelerator Keys

FunctionKey

Function Key SSSS +

Function Key

CCCC +

Function Key

AAAA +

Function Key

1 Help User Key 1

2 Save Record Delete Record User Key 2

3 Exit Function Trace Mode * Trace on/off *

4 Prompt Print Screen Exit Application

5 Clear Panel Refresh Screen Clear all Panels Calculate

6 Switch to NextArea

Switch to Prev.Area Switch Prev. Panel * Switch NextPanel *

7 Find Previous Superfind Previous

8 Find Next Superfind Next

9 Find Superfind Zoom

0 Switch to ActionBar

Add Mode on/off *

R Accept Clear and Return

F Next item Previous item

Z Insert/OvertypeToggle

X Delete Character

l Cursor Left Skip Word Left

r Cursor Right Skip Word Right

t Cursor Up Beginning of Panel

b Cursor Down End of Panel

s Selection Toggle

B DestructiveBackspace

Erase to End of Line Non-WP Bksp

h Beginning of Line Beginning of Data

e End of Line End of Data

Page 491: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 491

FunctionKey

Function Key SSSS +

Function Key

CCCC +

Function Key

AAAA +

Function Key

u Scroll Page Up Scroll Page Left

d Scroll Page Down Scroll Page Right

E Cancel

/ Mark

+ Paste

- Copy Cut

* = Defined only in Data Access packages – see package documentation

Page 492: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

492 Data Access Corporation

Studio Hot Keys

Feature Hot KeyToggle between Visual Designer and Component Explorer F12Toggle between Outline and Full Source in ComponentExplorer

F11

Find in Files Ctrl + 1Database Selector Ctrl + 2Object Properties Ctrl + 3Controls Palette Ctrl + 4Alignment Palette Ctrl + 5Arrange Object Ctrl + 6Nudge Objects Ctrl + 7Drag Lock Ctrl + LOpen Component Ctrl + ONew Component Ctrl + NPrint Ctrl + PSave Ctrl + SHelp F1CLIPBOARD Undo Ctrl + ZCut Ctrl + XCopy Ctrl + CPaste Ctrl + VDelete DelCOMPILE & RUN Compile and debug-run program F7Debug-run program F8Compile and debug-run component F9Compile Ctrl + F7

Page 493: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 493

Run Ctrl + F8EDITOR Code-List Ctrl + SpaceCode-Expand Ctrl + JNext Insertion Point Ctrl + IMatch parenthesis Ctrl + ]Goto line Ctrl + GNext ToDo item Ctrl + TUppercase Ctrl + Shift + ULowercase Ctrl + UToggle comments Ctrl + /Indent TabOutdent Shift + TabToggle Whitespace Ctrl + Alt + TDelete Line Ctrl + YSelect Line Ctrl + Alt + F8Find Ctrl + FFind again F3Replace Ctrl + Alt + F3Context Help Ctrl + F1Toggle Bookmark Ctrl + F2Previous Bookmark Shift + F2Next Bookmark F2Properties Alt + EnterRecord Macro Control + Shift + RRedo Control + ASet Repeat Count Control + RToggle Overtype InsertLine Open Above Control + Shift + N

Page 494: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

494 Data Access Corporation

Sentence Cut Control + Alt + KSentence Left Control + Alt + LeftSentence Right Control + Alt + RightWindow Scroll Down Control + UpWindow Scroll Left Control + PageUpWindow Scroll Right Control + PageDownWindow Scroll Up Control + DownWord Delete-To-End Control + DeleteWord Delete-To-Start Control + BackspaceWord Left Control + LeftWord Left-Extend Control + Shift + LeftWord Right Control + RightWord Right-Extend Control + Shift + RightDocument End Control + EndDocument End-Extend Control + Shift + EndDocument Start Control + HomeDocument Start-Extend Control + Shift + HomeHome Extend Shift + HomeLine End-Extend Shift + End

Page 495: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 495

Visual DataFlex Core Information

The Visual DataFlex language is a mature language (approximately 25 years) that allowsdevelopers to create powerful character-mode; OOP (Object-Oriented Programming);Windows; or Web applications quickly and easily. DataFlex 3.x versions allow you towrite procedural code or character-based OOP code. Visual DataFlex (VDF) createsWindows and Web applications.

Some DataFlex terms are confusing to developers use to other languages

Standard Term DataFlex TermTable Data FileColumn FieldRow RecordIndex Index (K file)Database Visual DataFlex has no single database file type.

DataFlex tables each are in their own individual file.For example, Access has a .MDB file that containsmultiple tables. Embedded (DataFlex) data files eachhave a separate set of files (.DAT, .HDR, .VLD, .K*, etc).

Page 496: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

496 Data Access Corporation

The Main Utilities

• Studio

The Studio is the hub of application development. It contains everything frompowerful RAD wizards to links to all the other major utilities

• Database Builder

Database Builder enables you to create, modify, and delete the database files used ina Visual DataFlex application. It supports creation and design of Data Dictionarys(.DD files), including declaration and configuration of the data-dictionary subclassrequired for every database file. In addition, it enables you to repair indexes anddata, and to restructure files (including files from earlier revisions of DataFlex).

• Database Explorer

Database Explorer allows you to browse through the list of data files of anyenvironment or workspace and open the files to inspect their data. Many databasefeatures are incorporated in this utility such as the Database Export Wizard, whichallows you to export your data to different formats.

• Compiler

Once a program source-code file is created it must compile it into another file forthe Visual DataFlex runtime to execute. The compiler does this operation.

Page 497: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 497

File RelationshipsFile relationships connect your files together. They stop data redundancy in yourdatabase table and allow your files to work harmoniously together. The whole key tosolid code in Visual DataFlex is solid relational database tables. Your database structuremust be correct to accomplish your needs.

The Parent-Child relationship is established within the Database Builder utility. If youhave a “parent file”, OrderHea file and a “child file”, OrderDtl the OrderDtl file wouldrelate to the parent OrderHea file. The related fields in both files must be the same typeand length. In this case the related field is Order_Number.

Page 498: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

498 Data Access Corporation

The general rule to determine which file is the child and which is the parent is todetermine which file will have many records to a single record in the other file. In thisexample there can be many child OrderDtl records for each parent OrderHea record. Theexception to this logic is the one to one relationships. In these cases it make littledifference which way the relationship points. An example of a One-to-One relationshipis an employee file and a password file, you may need the password in a separate file forsecurity but there should only be one password for each employee record

File Relationships Rules:

1. N to one relationship

2. Parent related field must be uniquely indexed

3. Related fields must be the same type and length

Some Sample Relationships

Chain Relationship:

Child� Parent� Grandparent

Books� Author� Publisher

One to One Relationship:

Employee� Password

Sibling Relationship:

Employee

TimeCard Wk_Summary

Page 499: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 499

Bridge Relationship:

Orderhea Inventory Students Classes

Orderdtl St_Cl

The Orderdtl child file contains a related field for both Orderhea and Inventory and alsoneeded data about the detail line item. However, the St_Cl file contains only two fieldsone relating to the Student file and the other field relating to the Classes file. The singlepurpose of this file is to link the two parent files together to solve the many to manyrelationship that is not supported directly. To find all the students in Biology 101 yousimply find all the Class code Bio101 in the St_Cl file. To find all the classes thatstudent 1013 is registered in, you again go to the St_Cl file and find all the records withstudent ID 1013.

Page 500: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

500 Data Access Corporation

Data IntegrityWhenever data is stored, business rules are generated in order to ensure the data beingsaved is correct. The old saying “Garbage IN = Garbage OUT” results when the businessrules are not followed.

Business rules are validations preformed prior to allowing any operation to the databasetable (such as saves or deletes). They can be something as simple as making sure theState Abbreviated field is always capitalized or as complex as making sure that an orderhas sufficient inventory before a save is allowed.

The Database Builder utility creates a DataDictionary class for each database table. Thisfile has the extension of DD. A Database table called “Customer” will have aDataDictionary Class created in a file called Customer.DD that holds the business rulesfor the database. This means all business rules are centralized in one place. This makesupdates and maintaining the business rules easier.

The last four tab pages of Database Builder generate the code to create thisDataDictionary file from you.

Page 501: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 501

What Happens During a Save to Keep the Related Fields the Same?When DataDictionarys perform a save operation, an Attach command is also performed.This moves the parent-related field to the child-related field. This is the reason that theparent related field, not the child related field should be added to entry views (wizardswill replace any Child.Related_Field with the Parent.Related_Field automatically).

In our example of the order program only the OrderHea.Order_Number field is presenton screen. But everytime an OrderDtl record is saved the OrderHea.Order_Number fieldis moved into the OrderDtl.Order_Number field prior to the save.

This is why when you look at the code for the Order example you will see that a parentrecord must be found before it allows the user to enter the dbGrid to enter child records.

If a child record was created without having found a parent record first, it would result ina disconnected “orphan” child record and would display in the grid whenever the parentrecord was blank. This is NOT what is wanted!

Page 502: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

502 Data Access Corporation

File NormalizationNormalization is the elimination of data duplication between files. To create filerelationships we need to duplicate the related field in both files in order to link the filestogether, but this should be the only data duplicated. A good file structure will eliminatethe need to duplicate data among files.

When data is duplicated between files

• Maintenance must be duplicated in order to update the data.

• Data integrity is sacrificed, as the data is not updated properly.

Examples of Bad Normalization:

• Customer Addresses are maintained in several files

• Customer Name is used instead of a Customer Code field for relationships (namesare not unique and can change exceptionally for woman when they marry/divorce)

Page 503: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 503

DataFlex File Extensions

Database files:

Extensions DescriptionFilelist.CFG This file lists all database table file namesDAT Data filesHDR Header files – used to repair the header of the .DAT fileK?? Index (Key) files – making finds quicker

RPT Crystal Report files – created by the Seagate Crystal Report programTAG Field name file – used by Database Builder/Database Explorer/CrystalVLD Variable Length Data files stores the data when compression is usedFD File Definition – an ASCII file used by the compiler to convert

File.Field names into File#.Field#DEF ASCII Definition files - contains a database file definition

Common Application files:

Extensions DescriptionDD Data Dictionary files – Contains the Class with the Business RulesSRC Main Source code filesVW View code filesRV Report View code filesPKG Package files – external code files for classes etcINC Include files – external code filesEXE Compiled VDF Code

Page 504: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

504 Data Access Corporation

Maintenance of FilesDatabase Builder utility is used for most maintenance that needs to be preformed on thedatabase tables.

Maximum Records:

If you are using an embedded (DataFlex) database table, this number is very important.The embedded database uses the Max Records parameter for organizing its indexesefficiently.

You should set a value for each file that is sufficiently large to accommodate theexpected growth of records in the file. You should never allow the number of records ina file to exceed the Max Records; this can result in corruption of one or more indexes.Many developers will add into their code a feature that will check and adjust this numberwithout user intervention.

Each time you save a change to the Max Records parameter, Database Builder mustrebuild the file’s indexes, and will do so automatically.

When you set Max Records to 1, Visual DataFlex will treat the file as a system file andautomatically place a check in the System File checkbox.

Database Builder can also run a Percentage Filled Report, which will show how closeyour files are to this setting.

Figure 319

Set Max Records to 20% morethan your expected size for thedatabase table.

Page 505: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 505

Reindexing

Occasionally, index files will become corrupt and will need to be rebuilt. Corruption canoccur if the computer is turned off while writing to the hard drive. Reindexing will readthrough the main file and rebuild all the index (.K*) files.

Reindexing can beaccomplished from theMaintenance pull-downof Database Builder orprogrammable using theSort command.

Figure 320

Page 506: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

506 Data Access Corporation

OOP Core InformationMost procedural developers looking at Object Oriented Programming (OOP) Languagesfeel that they would like to dive in, but horror stories of the dark, deep waters of theobject oriented learning curve have stopped them before they even got their feet wet.

They may try struggling to learn it on their own hoping to sail through on a weekend, butthe terminology alone is enough to make them feel like they are drowning. Frustrationsets in and by the time they read through a few pages of messages, delegation,encapsulation, not to mention polymorphism, they are ready to abandon ship and jumpback into the familiar procedural boat and keep drifting along. This old reliableprocedural boat is a solid vessel, but more and more oftheir customers are demanding the new look and feel of anice cruise liner. Customers want a better interface andmouse support (yes, this boat is full of mice!). The ObjectOriented ship is not totally out of reach, the proceduraldeveloper just needs a nudge to get their feet wet.

If you have been treading procedural water – the time isnow to take that OOP plunge! I believe it must be a planand a commitment in order to learn it efficiently! Thesepages hopefully will make it easier. The goal is to fill thewaters with enough life jackets to help proceduralprogrammers feel safe about taking the plunge into thewaters that will lead them to the object oriented cruiseliner.

To change your code from procedural to Visual DataFlex or WebApp object oriented, itmust be rewritten! This sounds really nasty at first. I will not lie to you, there’s nomagical wand that can be waved and transform your procedural code into ObjectOriented code. Application Framework is now fully incorporated into the language, andthis methodology gives your application the solid building blocks needed to succeed.There’s much to learn but don’t believe those horror stories of shark infested waters asyou learn Object Oriented. The benefits far outweigh a little study time.

You may have heard that Object Oriented coding is a totally different way ofprogramming than procedural. Let’s say that this is only partially true. In fact, I’d like toconcentrate on the similarities instead of the differences. There are many concepts thatare the same in both languages. The names have just been changed, but the basicconcepts are the same! At first I find the biggest problem to face is trying to get a firmunderstanding of the obtuse words OBJECTS and CLASSES!

I strongly feel that a firm understanding of Objects and Classes is the key to success.

Page 507: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 507

Definition of Classes and Objects:Classes are the tools and Objects are the instance of using those tools.

That still sounds like Greek, so let’s relate them to something in the REAL world. Thinkof Classes as a cookie cutter and every time you use this tool is an instance of the tool (acookie)!

If you use a Star Cookie Cutter, you will create a Star Cookie. Use this tool every timeyou want your cookies to have five points. If you want heart cookies you use the heartcookie cutter (tool = class). The cookie cutter and the cookies are both called a star or aheart but there is a big difference between them, just like there is a big differencebetween Classes and Objects. It is confusing because you call each by its cutter/cookieshape or by its class/object purpose. You have DataDictionary classes andDataDictionary objects; array classes and array objects. You would use the cookie cuttertool to create the cookies to eat. In OOP you would use the Class to create the Objectsfor the application to run.

Someone has to create the tools. If you look at the FMAC file (a file that holds all theunderlining commands to make the basic language work) you could see how the EnterMacro was created. These lines of code in FMAC make the Enter Macro commandoperational, much like code that make Classes operate. Most of the classes havecorresponding package (.PKG) files that have the code to make the class/tool work. Thecode in FMAC does nothing by itSelf. You must use the Enter Macro Command in yoursource code in order for the program to allow the user to enter data. In OOP, you createobjects from your class/tools to allow the user to interact and accomplish their requiredtasks.

There are many classes/tools that come with the language. One of the things that youmust learn is the most common classes (tools) that are used. One common class (tool) isan Array class. Each time you use this Array class (tool) you create an Array Object,(cookie). This object (cookie) will have all the functionality of the class (cookie cutter).

In the DataFlex procedural language, you had three macros – Enter Macro; EnterGroupMacro and the Report Macro. These were tools very much like Classes. Using these toolsmade coding faster and easier. One of the drawbacks of the 2.3b Enter and ReportMacros were that you could only use them once per program because they used labels tonavigate, and of course you could not have two labels with the same name. DataFlexObject Oriented tools do not have this limit. Reusing code (classes) over and over is thefundamental purpose of OOP.

Page 508: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

508 Data Access Corporation

Common Classes (Tools)

Class Tool Use

Array Used to store data as a temporary memory storage area. Its sizegrows dynamically to accommodate the storage requirements

Button To create visual representations of keys or buttons that, whenpressed by users, produce a specific action (event).

DataDictionary The tool that provides database services (finds, saves, deletes andclears). Stores the Business Rules for the database table.

Some classes are product or application-type specific

Character-Based VDF (Windowsapps)

VDF (Webapps)

Class Use

Entry_View_Client DbView cWebApp a container speciallysuited as the outercontainer of a view

Entry_Form DbForm data entry tool (display &edit) of a single record

Table DbGrid data entry (display & edit)a scrollable, multi-columnlist of records

Text_Window DbEdit data entry tool for textfields

BasicReport BasicReport cWebReport Used to create reports

BusinessProcess BusinessProcess cWebBusinessProcess

To contain and execute thestatements to perform abatch process on anapplication’s databasefiles

OOP terminology is sort of like learning a foreign language. At first, every time youlearn a new word; you must convert it to your native tongue, or relate it to something youunderstand. So far you have Class = (Tool or Cookie Cutter, or Enter Macro) and Object= (an imprint from a class or Cookie, like the code using an Enter Macro).

Page 509: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 509

Let’s look at some code. The comparison is between Procedural code with DOS objectoriented classes.

Procedural Example Character-mode Object Oriented Example

// code for the enter macro is in FMAC Use EntyForm // inserts code to make Entry_Form Class

// operate. This code is kept in .PKG files

/TimeCard_Image

ID # ____

Name ______________

Rate __.__

Hours __

Pay ___.__

/*

/TimeCard_Image

ID # ____

Name ______________

Rate __.__

Hours __

Pay ___.__

/*

Enter TimeFile Empl

// Enter macro requires child file listed first

Entry Emp.ID {AutoFind}

Entry Empl.Name {CapsLock}

Entry TimeFile.Rate

Entry TimeFile.Hours

Entry TimeFile.Pay

EnterEnd

Object TimeCard is an Entry_Form TimeCard_Image

// (using clause link to Data_Set left out for this example)

Item_List

Entry_Item Empl.ID {AutoFind}

Entry_Item Empl.Name {CapsLock}

Entry _ItemTimeFile.Rate

Entry_Item TimeFile.Hours

Entry_Item TimeFile.Pay

End_Item_List

End_Object

In the above example, TimeCard is the Object and Entry_Form is the Class. Classes arethe tools and Objects are the instance of using these tools. Just knowing that the objectwas created from the Entry_Form Class you know its purpose is to allow the user to editand display single records. The object is an imprint from the tool that it was createdfrom. Just like cookies were imprints from the cookie cutter.

Page 510: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

510 Data Access Corporation

Procedures & Local VariablesProcedural code had structural code where you used GoSubs to execute sections of code.In Object Oriented, you send messages but basically they are doing the same thing.

Procedural Example Object Oriented Example//declaring global variables

Number nHours nRate nPay

// Local variables in procedures are more efficient.// Memory is release upon the end_procedure command

GoSub Calc_It

// Jump to a label called Calc_It & execute the // subroutine until a Return command is encounter.

Send Calc_IT

// Jump to a procedure called Calc_it & execute the // commands until an End_Procedure is encounter.

Calc_It: Procedure Calc_It

Move image.3 to nRate // One Based

Move image.4 to nHours

Calc (nHours * nRate ) to nPay

Move Pay to image.5

Number nHours nRate nPay

Get Field_Current_Value field Empl.Rate to nRate

Get Field_Current_Value field Empl.Hours to nHours

Calc (nHours * nRate) to nPay

Set Field_Current_Value field Tcard.Pay to nPay

Return End_Procedure

Notice the use of local variables in the OOP procedures and global variables used in theprocedural code. The local variables used in procedures are dynamic variables (meaningthey will grow as needed, so you no longer indicate the length of string variables). Localvariables are destroyed and the memory released as soon as the end_procedure commandis reached. This is much more efficient!

The Get and Set commands retrieve and set properties. Properties are special objectvariables or item variables that are used to determine the current state of the object/item.Procedural code had predefined variables. For example, the Report Macro used PageEndand PageFeed. The “Move” command could address these predefined variables directly.OOP properties (which are similar to predefined variables) use the get and set commandsto obtain or change properties.

You may have heard that Object Oriented Programming is Event Driven. That is an eventtriggers the direction flow that the program takes. Procedural programming is moresequential in its flow. At first, a programmer may feel he has lost control over the userthat now has this mouse and can easily jump anywhere! These events that drive theprogram flow can be controlled. It just may seem different, at first, as you learn all theevents that allow you to send messages (which are like gosubs to subroutines).

Page 511: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 511

If your OOP page allows database table operations to the Customer file, theCustomer_DD (DDO) is being used to perform these operations. The Server propertywill connect the entry object to the Customer DataDictionary Object. ThisDataDictionary Object will supply the database table operations for find, clear, save, anddelete operations. The procedural Enter macro has the ability to perform database tableoperations (finds/saves/deletes/clears) within the macro tool itSelf. The DataDictionaryclass also has these functions built into the class.

In OOP you will be using many tools, and it would be a waste to have each class (tool)understand how to perform the complex multi-user database table operations. Therefore,you separate these tasks out and whenever a class needs these database table operations,they are linked to the DataDictionary object that should be servicing it for finds, clears,saves, and deletes.

In OOP you link your Data Entry Object – DEO (Web Business Object -WBO in Webapps) and DataDictionary Objects (DDO) together to give the DEO/WBO access to thedatabase table. Each DEO/WBO will link (via the Main_DD property) to their mainDataDictionary Object. This is sort of like a computer operating system. If you wish yourcomputer to save a file to the floppy drive, you do not ask the computer - you ask theoperating system to ask the computer. The operating system knows how to do this anddoes it well, so you let it do all the work of finding all the fragmented parts of the fileand moving them to the floppy in drive A. Then, it updates the File allocation table sothe file will show up the next time you do a DIR A:.

DataDictionarys do all the overhead work of rereading and locking your files. They doall these database table tasks so well that you should always allow them to perform thesetypes of tasks.

Page 512: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

512 Data Access Corporation

Multiple DataDictionary Objects (DDOs)Let’s look at a VDF view using DataDictionary classes.

Use Windows … ACTIVATE_VIEW Activate_oView FOR oView Object oView is a dbView // A framework rule states that there should be a Data Dictionary Object for every File opened. Object Employee_DD is an Employee_DataDictionary End_Object Object TimeCard_DD is a TimeCard_DataDictionary Set DDO_Server to Employee_DD End_Object Object Empl_ID is an dbForm Set Server to (Employee_DataDictionary (Self)) Entry_Item Empl.ID End_Object Object Hours is an dbForm Set Server to (TimeCard_DataDictionary (Self)) Entry_Item TimeCard.Hours End_Object Object Rate is an dbForm Set Server to (TimeCard_DataDictionary (Self)) Entry_Item TimeCard.Rate End_Object End_Object

The Enter Macro had rules that had to be followed when you used related files. All fileswere listed after the Enter Command. The order that the files were listed was veryimportant for the correct saving and deleting of the data in the related files. Lower(child) files were listed first, followed by higher (parent) files.

In OOP, you connect the DEO/WBO to the main DataDictionary Object (DDO) via the

The DDO Server Clauseestablishes a two waycommunication betweenthese DDOs.

Empl_ID ObjectServer

Employee_DD

TimeCard ObjectConnected to

Employee_DD

Employee_Data_SetObject

Hours ObjectServer

TimeCard_DD

Rate ObjectServer

TimeCard_DD

Page 513: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 513

Server property, just like in the last example. Then, if there are multiple related files,you connect the DataDictionary Objects together via the DDO_Server property. You linkyour DataDictionary Objects together just like the related file structure created inDatabase table Builder (DFFile).

Hopefully, you are starting to see the power of OOP. You take classes (tools) and bymaking objects (imprints from them) you create an application that users can interactwith to have access to the database table.

Page 514: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

514 Data Access Corporation

EncapsulationAn object-oriented term that is heard often is “encapsulation”. The definition ofencapsulation is combining data and procedures into a single entity capable ofmanipulating itSelf. The easiest way to understand these terms is to relate them back toprocedural code.

Procedural Menus

Department Entry

-----------------------------------------------

Dept ____

Name: __________________

Main Menu

-----------------------------------------------

Data Entry Menu

Report Menu

System Parameters

Employee Entry

-----------------------------------------------

Employee ID _____ Dept ____

Name: __________________

Address __________________

City ____________ St__ Zip ____

Time Card Entry

-----------------------------------------------

ID ____

Name: __________________

Rate ____.__

Individual programs in their ownsource code (.SRC or .FRM) file.Each a stand-alone (encapsulated)section of code.

Data Entry Menu

-----------------------------------------------

Employee Entry

Department Entry

Time Card Entry

Page 515: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 515

Procedural code normally had a menu program that executed, via Chain wait commands,all the separate .FLX programs. An OOP application will combine all the views into asingle application (.src) and from a starting page or menu bar launch the individual views(web pages).

The different views all canbe displaying differentrecords from the same file.The DataFlex language stillonly has one record bufferfor each opened file, how isit possible that the views alldisplay/save/deletedifferent records? Eachview contains its ownDataDictionary object forthe Employee file. TheEmployee view has anEmployee_DataDictionary

Object, the Department View might also be displaying an Employee record, however thatview has it’s own Employee_DataDictionary Object. Remember these DataDictionaryObjects service the view objects for Finds/Clears/Saves/& Deletes. They are responsiblefor making sure that the correct record is in the record buffer! This is a task that the DataDictionarys do well. The user now can bring up all the views on screen at the same timeand jump between them with the mouse! The DataDictionary just sits back and keepstrack of the correct record for you! What a great tool (class).

Figure 321

Individual views eachwith their own .VW(WBO & ASP) file.

Page 516: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

516 Data Access Corporation

Message ForwardingProcedural Code came with 3 macro tools, but Object Oriented has MANY.

A small section of the Class Hierarchy Chart.

UI_Object

Menu

List

EntryList

Wide_List

Data_List

Table

The entire Hierarchy Chart is large. However only a handful of classes are used often.

One tool is built off the tool above it. Instead of rebuilding the wheel each time youcreate a new tool, you simply add the new features in the new tool. The tools get moreand more powerful as they are subclassed.

An example of how the tasks are passed from class to class, would be similar to hownetworks and operating systems pass commands along. They do basically the same thingthe classes are doing. If you are running a Novell network all commands typed at theprompt go to Novell. Novell will perform the task if it is a Novell command like NDIRor CAPTURE but if it is a DOS command, Novell just hands it to DOS to handle. If youtype DIR, Novell will (take this command) find that it does not know how to do this taskand forwards the command to DOS. Since DOS knows how to handle this command, theDIR task is performed. It would not be efficient to rewrite all the DOS commands inNovell just like it would not be effective to do this whenever you create a new class.

Since Novell is built from DOS, there is no need to make Novell understand how to do aDIR. It only has to forward it to DOS to handle. Classes operate the same way. Themessage “Bell” is sent to an object built from the Button class. It may not know how toring the computer bell but it will forward this message up to its super-class and if that

DOSNovellDIR

Command

Page 517: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 517

super-class cannot ring the bell it will forward the message up the branch until a classunderstands how to ring the bell. Just like you do not care if Novell or DOS takes care ofa command – the user will not care who handles the message “Send Bell”. Just for yourinformation the defining class for the message bell is the UI_Object Class. How do youfind out? The On-Line help will list all predefined procedures and functions (similar tosubroutines) in a chart. This chart will tell you the defining class. Looking up theprocedure under the Defining Class section will give you a full description of thepurpose and use of the message.

Now that you are aware that messages may be passed up the class hierarchy structure, itis time to take a look at building a class. It is important to note that developers will findthe DataFlex predefined classes to be sufficient for most programming needs, butoccasionally there will be a need to build a class (tool). The most common class that youwill need to build is a class built from the DataDictionary class. Database Builder makescreating DataDictionary classes very easy from four tab pages that allow you to fill in agroup of forms and checkboxes.

The Enter Macro had the database table operations built in, but in OOP they areseparated out into the DataDictionary Class. In procedural coding, there are times whenyou needed to perform certain tasks during the lock state of save and delete operations.The Enter.Save and Enter.Edit were provided to perform operations such asautomatically assigning the next available ID number from a SysFile or keeping track ofrunning totals. In Object Oriented, the Creating Procedure is only called during a newsave and the Update and Backout procedures are used to maintain running totals.

Page 518: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

518 Data Access Corporation

Event DrivenOOP is an event driven language. Events are actions that trigger messages to flow. InOOP nothing is done until a message is sent. Therefore it is very important to know howto trigger these messages.

Trigger Messages by: Description

Classes The purpose of some classes is to trigger messages. The buttonclass is sends the OnClick event when clicked. (i.e.; Menu bars;Tool-bars).

Accelerator Keys The purpose of accelerator keys is to send messages. (i.e.; F2sends the Request_Save message and Shift+F2 sends theRequest_Delete message.

On_Key The purpose of the On_Key command is to trigger a messagewhen the defined key stroke is pressed. (i.e.; On_KeyKey_Alt+Key_P send Print_It.

Send The Send command will trigger a message. There are manyvariations to the send command; Delegate; Forward; Broadcast.

Augmenting ExistingMessages

Many pre-existing messages can be augmented to perform extraprocessing or additional messages whenever they are normallytriggered.

Start_UI A special command that starts the User Interface.

Page 519: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 519

Building New Classes:New classes are built so objects built form them will contain the new class features. Thisis how the business rules are added into one location and affect all views.

The CapsLock option is added into the DataDictionary class and after recompiling it willeffect all views thatcontain this field. // Empl.DD File

// Employee_DD Class built from DataDictionary Class

Class Employee_DataDictionary is a DataDictionary

Procedure Define_Fields

Forward Send Define_Fields

Set Main_File to Empl.file_number

Set Field_Options Field Customer.State To DD_CAPSLOCK

// other business rules

End_Procedure

End_Class

//Empl.VW File – Employee Entry View

Use Empl.DD

Object Employee_DD is an Employee_DataDictionary

End_Object

//Empl_Grid.VW File – Employee Grid View

Use Empl.DD

Object Employee_DD is an Employee_DataDictionary

End_Object

Page 520: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

520 Data Access Corporation

The UIMSUser Interface Management System (UIMS) is like a shell level in DOS. At the commandline, DOS just sits and waits for the user to type a command and press return. The UIMSis similar to an operating system waiting for a command or an event to happen that willtrigger (send) a message.

Let us look at an OOP view made into an application:

Use DataDictionary Use dbGrid Use Customer.DD Object Customer_DD is a Customer_DataDictionary End_Object Object Customer_Grid is a dbGrid Set Server to (Customer_DD(Self)) Begin_Row Entry_Item Cust.ID Entry_Item Cust.Name Entry_Item Cust.Phone End_Row End_Object Start_UI (Customer_Grid(Self))

In the program nothing really happened until the last line, when the Start_UI command isreached. All the objects are simply built in memory. The Start_UI command is really twocommands in one. It starts the User Interface (UI) rolling. Remember messages are justthe gosub that will execute a procedure (subroutine). The UI starts and simply waits forthose events to trigger the sending of messages that make the program run. There aremany ways to trigger messages to be sent (e.g., keyboard entry, mouse clicks, timersfiring, entry options, setting certain properties).

At first, procedural programmers may feel like they have lost control to the user orUIMS. In procedural code the user was pushed straight through your code. The user

Customer DataDictionary

Customer_Grid

Page 521: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 521

could navigate up and down through the entry windows and with this limit, theprogrammer had complete control over the actions of the user. Now with the mouse theuser can navigate anywhere - anytime – or so it seems. The real skill of OOP comes withthe coding of these events that will trigger your messages at the correct time.

The more you code in Object Oriented, the easier it will become. One of the biggestbenefits is the increase in data integrity. This is accomplished by separating the databasetable operations from the Data Entry operations. This is a logical separation and one thathas many benefits!

Page 522: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

522 Data Access Corporation

SummaryIn this OOP overview many concepts have been quickly covered. There is still much tolearn but hopefully you will have a good general understanding of some of the basicprincipals of object-oriented programming and how it works, so the rest of your readingis easier.

Topics Covered:

• An understanding of the terms Classes and Objects

• A general idea and use of the commonly used classes.

• An understanding of forwarding messages through the class hierarchy structure

• The use of Procedures to accomplish tasks and how to trigger them by sendingmessages.

• A general understanding of the DataDictionary Class. Its importance as the server ofview Objects via the phMainDD property.

• How DataDictionary Objects are linked together with the DDO_Server propertysimilar to the file relationship structure.

• The power of creating new classes (tools) in order to stop duplication of code. Theneed to create new classes (tools). Example: creating business rule in theDataDictionary class.

• How encapsulation of each view linked together via the .SRC file.

• General understanding of the UIMS operation.

• A general connection between Procedural code to Object Oriented code.

Page 523: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Appendix C Core Information

Data Access Corporation 523

Prior DataFlex Users

Prior DataFlex Procedural UsersWe no longer rely on DFPATH or DFENV to locate our files. The workspacename.WSfile located in the workspace will now do this.

Prior DataFlex Character-Based OOP UsersModal state is now used in place of Block_Mouse_State.

There are many changes and you should read the “What’s New” section wheneverupgrading your application.

Everyone New to VDF8Refer to the “Whats New” sections in the on-line help. There are so many items thathave changed in the different versions of VDF. This great section will outline the manynew improvements made to the latest VDF version(s). The links in this section will jumpyou to full descriptions of the great features that have been added.

Page 524: Discovering Visual DataFlex 9.1

Appendix C Core Information Discovering Visual DataFlex

524 Data Access Corporation

Page 525: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Glossary

Data Access Corporation 525

Glossary

The words in this list are used in Visual DataFlex documentation with specific meaningsbeyond their meaning in general contexts, even general computer-oriented contexts.Consult this list whenever you encounter a word in the documentation that seems to beused with a special meaning.

Page 526: Discovering Visual DataFlex 9.1

Glossary Discovering Visual DataFlex

526 Data Access Corporation

Terms DefinitionsAccelerator Key A key, or combination of keys, that invokes an application-

defined procedure. The keys are referenced within a programby a predefined name preceded by the letter "k," (e.g., kcancel).Each accelerator key is mapped to an actual key on thekeyboard and the mapping can be changed through theDataFlex Configuration. See also Flex-Key.

Access Method A reference created by the compiler to address the object. Thisreference can be used to address objects in the program. Atcompile time, the compiler creates a special function, whichuses the same name as the object, which is being accessed.That function returns the object's absolute object identifier. Forexample, if Object b is nested within Object a, you would use(b(a.obj)) to reference Object b. This is the access method bywhich Object b may be referenced. See also Object; ObjectIdentifier.

Action Bars A horizontal bar that contains pull down lists giving choices forspecific actions. Like Menus

Ancestor A term denoting a parent, grandparent, great grandparent, etc.,of an object or class. See also Child Object; Class; Descendent;Object; Parent Object.

Application FrameWork

Is the methodology to construct and connect object-orientedsections together correctly.

Argument A parameter passed to a procedure, function, or a macro tocontrol the process. See also Function; Macro; Procedure.

Augment The process by which an inherited procedure or function isgiven, adds functionality in a subclass. A procedure or functionis augmented by defining a procedure or function with the samename as the inherited one and including in the new definition, aforward command that sends the message to the class fromwhich it was originally inherited. See also Override.

Page 527: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Glossary

Data Access Corporation 527

Terms DefinitionsBackout Procedure A procedure in the Data_Set class called during deletes and

edit saves that allows the programmer to code during a lockstate (such as maintaining running totals). Like the Enter.Editin DataFlex procedural code.

Broadcast The process in which a parent object sends the same messageto all of its child objects. If the message sent returns a value,only the last value is retained. For example, an object mightbroadcast the message, initialize, to all of its children aspreparation to further operations. Message delegation is turnedoff during a broadcast. See also Delegate.

Buffer, Edit An area in the computer’s memory which is used to store andmanipulate the data being entered by the user in the edit class.See also Class, Base; Edit.

Buffer, Record An area in the computer’s memory that contains a record fromeach opened database file. The place in memory where theserecords are active is called the record buffer. When a recordhas been read from disk to the record buffer, data can then beextracted, added to, and/or modified in that record. The recordcan then be written back to disk (saved). Likewise, in order todelete a record, the record must first be active. The recordbuffer is where DataFlex does its work on a given record. Seealso File, Database; Record.

Buffer, Screen An area in memory where the active image is located. There areimage-name-line options, resident and resource, which place animage in memory for the duration of the program. See alsoCurrent Image; Current Window; Image; Window.

Child File A naming convention database file which is relating to anotherfile and there is a valid relationship established. This databasefile extracts the related fields from the related to database file(Parent) and allows for a seamless data structure within aprogram. See also Parent File.

Page 528: Discovering Visual DataFlex 9.1

Glossary Discovering Visual DataFlex

528 Data Access Corporation

Terms DefinitionsChild Object An object-creation block which is nested inside an object-

creation block. Parentage provides a route for the child objectto inherit properties, including messages and accelerator keys.See also Descendent; Object; Parent Object.

Class A group of properties, children and messages that definespecific behaviors to objects. Classes are designed bybehavioral description, or, a class may be constructed as theintersection of the properties of a set of similar objects. A classmust be based on another class, called its superclass. See alsoClass, Base; Superclass. We can also think of them as “Tools”that our objects are built from. Like the Enter or Report macroin DataFlex procedural code.

Class, Base A set of classes supplied with Visual DataFlex defined `below'the level of DataFlex itself (as distinguished from classescreated with the class command). The base classes, also called"data structures" are Message, Menu, DFList, Edit, Scrollb(Scroll Bar), and Array. See also Class; Superclass.

Class Package A .PKG file that contains the source code for a class definition.This code is included in the program at compile time throughthe use command. Examples: Windows.PKG, DfAllEnt.PKG

Clipboard An abstract term denoting an area in memory that stores data. Itis designed to be used as the source and destination for cut andpaste operations. The clipboard is automatically created by thesystem, and is available to the programmer at any time a cutsource or destination is needed. The clipboard is retainedacross chain and chain wait operations, so it can be used totransfer information between programs or modules of anapplication. The clipboard can receive all of the messages ofthe edit class objects. See also Edit; Object.

Page 529: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Glossary

Data Access Corporation 529

Terms DefinitionsCommand A word or series of words in program source code which

execute a predefined procedure (i.e., goto X1, sendsexecution to Label x1) or string abc (creates a variablenamed abc with a length of 80 characters). DataFlexcommands are macros, which are defined in the fileFLEX.CFL. FLEX.CFL is what the compiler reads as itprocesses your program source code. Commands can also bedefined with compiler directives in programs and packages. Seealso Macro.

Comparison Mode The method of comparing values using any of the followinglogical functions: matches, contains, min, max, ior, iand, <>, >,<, =, <=, and >= in expressions, and ne, eq, lt, gt, ge, le, match,and in commands. See also Function.

Creating Procedure A procedure in the DataDictionary class called only during newsaves that that allows the programmer to code during a lockstate (such as assigning next available ID numbers). Like theEnter.Save in DataFlex procedural code.

Current Focus An active object currently being used. An object becomes thecurrent focus in the focus list when 1) a message is sent or acommand is executed to activate an object or group of objects,2) a procedure or function uses the procedure_return orfunction_return command to return a non-zero value to astart_ui or ui_accept command, or 3) the user clicks the mousecursor on an object which is already activated, but not thecurrent focus. See also Focus List.

Current Image The image being acted upon. Images are numberedconsecutively (top to bottom) within a program when compiled.The image being acted upon is internally maintained by thecurrent_image system variable. See also Buffer Screen, CurrentWindow, Image, Window.

Current Message A predefined integer that contains the number of the messagethat invoked the currently executing procedure.current_message is useful when the message number of aprocedure must be passed to another procedure.

Page 530: Discovering Visual DataFlex 9.1

Glossary Discovering Visual DataFlex

530 Data Access Corporation

Terms DefinitionsCurrent_Object A predefined integer that always contains the absolute object

identifier for the object owning the procedure currentlyexecuting. See also Focus, Focus List, Object, ObjectIdentifier.

Current Window The window being acted upon. Windows are numberedconsecutively (left to right, top to bottom) within a program,regardless of the image they belong to when compiled. Thewindow being acted upon is internally maintained by thecurrent_window system variable. See also Current Image,Image, Window.

Cursor, Mouse A visual cue that shows users the current position of the mouseinput focus (current position). See also Cursor Text, CursorSelection.

Cursor, Selection A visual cue whereby users indicate with the keyboard thechoice they want to interact with. It is represented byhighlighting the choice with an inverse bar. For example, if youwere making a selection from a scrolling list, the selectioncursor would be located on the choice in the list, which ishighlighted. See also Cursor Text.

Cursor, Text A visual cue that shows users the current position of thekeyboard input focus (current location). See also CursorMouse, Cursor Selection.

.DAT files The .DAT files are the data files where DataFlex stores the rawdata entered, unless compression is used in which case the datais stored in the .VLD file and the .DAT is used as a pointer tolocate the correct record in the .VLD file

Page 531: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Glossary

Data Access Corporation 531

Terms DefinitionsDate A field, variable or window used for evaluating and storing

dates. There are three formats supported; mm/dd/yyyy (USA),dd/mm/yyyy (European) and yyyy.mm.dd (Military), where mmindicates two digits representing the month, dd represents twodigits representing the day, and yyyy represents four digitsrepresenting the year. Two-digit entry and recording of years isallowed optionally. The format is set as a system option in theDataFlex Configuration. Dates are stored in Julian form asnumbers, allowing for operations requiring calculations withouttype conversion. The display is a de-coded representation of thenumeric format storage. There is a date command, whichdefines a variable of Type Date. See also Variable, Window.

.DEF files The .DEF files have an entire file structure of a databasedescribed in an ASCII format. These ACSII files can be createdfrom DFFile or DFMaint and can be used in DFFile to create aduplicate file structure.

Delegate The process by which a message is sent to the parent object ofthe current object. Any message that cannot be understood bythe current object or the class of the current object isautomatically delegated (sent to the parent of that object orclass). This delegation continues until the message reaches theDesktop; if the Desktop cannot understand the message, anerror is generated. There is also a delegate command inDataFlex that causes messages to be sent directly to the parent.

DEO Data-Entry Objects are objects that allow data-entry.

Descendent A term denoting a child, grandchild, great grandchild, etc., ofan object or class. See also Ancestor; Object; Class; Object;Parent Object.

Desktop An "invisible" object which is the ultimate ancestor of allobjects within a program. The desktop is the background uponwhich all other objects are displayed. Likewise, it is the finalreceiver of messages that are delegated by global objects. Therecan only be one desktop within a program.

Differentiation Deviations of objects from their superclass

Page 532: Discovering Visual DataFlex 9.1

Glossary Discovering Visual DataFlex

532 Data Access Corporation

Terms Definitions

DSO Data Set Objects are objects that are built from the Data_Setclass or a subclass built from this important class. Data SetsObjects are used as the servers to the DEOs. They handle thedatabase operation such as finds, clears, saves, and deletes.

Edit See Class, Base.

Encapsulation A section of code that can operate alone This does not mean itneeds no external connections. An object is an encapsulatedcode segment; it is a black box whose makeup you need notknow exactly, just the interfaces that allow you to interact withit (i.e. what properties and messages can be sent to it). Theobject may have external dependencies, such as a DEO beingconnected to a DataDictionay Object.

Entry Item Options Options that are connected to an item Windows that willperform a desired action when the user enters or leaves awindow. Example: {CapsLock} will force the contents of thewindow to only be capital letters: Field_Entry_msg propertywill send the corresponding message just prior to entering thewindow.

Event-DrivenInterface

The ability for a user to process requests for action at almostany time. When users navigate with the arrow keys, input,select items with the mouse, or press accelerator keys, theprogram is continually asked to respond to events. These eventsmay be directed at any active object, or cause the activation ofobjects.

Events that determine the flow of the program. Like a KeyProcused in DataFlex procedural code. See also User Interface.

Expression A set of commands encompassed by "(" and ")" which areexecuted jointly to process data. All expressions return a value.Expressions can be nested. For example(length(trim(temp_string))), in this expression thevariable temp_string is first trimmed then the length of it iscalculated. See also Command.

Page 533: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Glossary

Data Access Corporation 533

Terms DefinitionsField A discrete piece of data that is of a defined type and size which

is stored in a record. There are usually many fields in a record.Each field is given a name that is unique to that database file,and common to every record. Database fields are sometimesreferred to as the elements in the file. You can have up to 255fields per record. See also File, Database; Record.

File, Database An area on disk that holds structured data, which makes up aparticular information system. A database consists of records,which contain fields (file elements). Database file definitionscontain the name of the file, the numbers, lengths, and types ofthe fields, which fields make up the indexes, etc. Database filesare analogous to a file cabinet drawer (database file) containingfolders of employees (records), which contain the employeesemployment form (the data in the employees employment formare the fields). See also Field; File System; Record.

File, Index A file (organized listing) used to expedite the finding of recordsfor a database file. The file structure is B+ Multi-level ISAM.There are two types of index files; online (maintainedautomatically by the programs) and batch (must be reindexedprior to its use). Index files determine if the fields of a databasefile can be duplicated (the record number is part of the index)or not. An index file is created by the DataFlex DatabaseBuilder or the DataFlex Index Tool. See also Field; File,Database; Record; Reindex.

Filelist.CFG Filelist.CFG contains a list of all the filenames (Rootname,DataFlex name, User name) for each file that is accessible.

The numbered list of database files in a system, kept in a filedefault-named Filelist.CFG. The compiler and the runtime usesFilelist.CFG to find the physical disk fileset containing thedesired data.

Page 534: Discovering Visual DataFlex 9.1

Glossary Discovering Visual DataFlex

534 Data Access Corporation

Terms DefinitionsFile, Sequential Data in sequential files can only be accessed sequentially,

rather than randomly as in database files. The read, readln andread_block commands are used to access the data in sequentialfiles. One of the most common types of sequential files isASCII text files.

File, System A database file with unique limitations. The file can not containmore than one record, be indexed, or have a relationshipestablished with another database file. The buffer of a systemfile is automatically loaded with the data contained in its recordupon open. The purpose of this type of database file is to keepsystem (global) information in it (i.e., your company name,address, city, state and zipcode). See also Child File; File,Database; File, Index; Parent File.

Flex-Key Any of 13 standard DataFlex functions activated by a singlekeypress or shift-key combination. The functions pertain todatabase operations (finding, deleting, saving) and text editing(backspace, arrows), and have standard names in DataFlex tomake the function independent of the particular physical keysto which they are mapped. The mapping is configurable at eachsite, and for each machine using a multi-user license. See alsoAccelerator Key.

Focus See Current Focus.

Focus List A list of objects that are currently activated. This list ismodified by the activation (activate) and deactivation(deactivate) of objects. This list is set up so that each object inthe list knows 1) what object had the focus prior to its ownactivation (prior_focus), and 2) what object took the focus afterit was activated (next_focus). In programmer terms, the focuslist is a doubly-linked list. How this list is maintained is criticalto the design of an application - the order of activation andparentage of objects must follow a particular structure for aprogram to function properly.

Focus Object The object that currently is capable of user interaction.

Page 535: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Glossary

Data Access Corporation 535

Terms DefinitionsFocus Tree UIMS applications organize objects in a manner allowing

logical navigation paths between objects. As objects activateand deactivate, this tree is updated to reflect the object’sposition in relation to other active objects. Four propertiesindicate the object’s position: Prior_Focus, Next_Focus,Prior_Level, and Next_Level.

Forward The process of sending a message to the ancestor class of anobject or class. If no ancestor of an object understands amessage, then it is delegated to the parent of the object towhich it was sent. The forward command causes messages tobe sent to the ancestor class. See also Delegate.

Forward Reference To reference an object not yet created. When it is necessary toreference an object not yet created, use the Register_Objectcommand, so it creates an access method for that object. Seealso Access Method; Object.

Function A block of code which incorporates a set of commands thatjointly define messages sent to an object. The message isdefined using the get command. A function is defined by thefunction and End_Function commands. Functions return avalue of a particular type using the function_return command.Functions can not be nested. Functions are like subroutines inprocedural code that always return a value. See also Command;Delegate; Message; Object; Procedure.

Global Something is global when it is not contained within the boundsof a class, object, function or procedure. For example, avariable not specifically declared within a procedure is global.A procedure, function, or object is global when it is not nestedwithin any other object. Global code and data structures cangenerally be referenced by any part of the program.

Global, Object An object whose parent is the desktop. These objects aredescribed as `children of the desktop' or global objects, andmay be addressed without access methods. See also AccessMethod; Child Object; Parent Object.

Page 536: Discovering Visual DataFlex 9.1

Glossary Discovering Visual DataFlex

536 Data Access Corporation

Terms DefinitionsHandler A handler is another term for a message-handling procedure.

The name comes from the idea that the handler "handles" orresponds to a message it receives. See also Message;Procedure.

Image An area in memory that holds static and data-output areas(Windows). In source code, an image (also referred to as a"page") is defined by a slash (/) in the first (0) column andfollowed by a name (page name) which must contain a letter inthe first character. An image continues until the start of anotherimage ("/pagename") or the end of the image section (indicatedby "/*" at the start of the first line after the last image). Eachimage can be manipulated individually by the program. Imagescan be used for output to a device (printer, console or file).Each image is identified by a page name. See also Window.

Image, Dynamic The ability for an object to change the image (visual property)at runtime. Certain objects can change their visual properties atruntime. For example, the edit object may change its height andwidth merely by changing the value of its size property. Thescrollbar object adjusts its length based on the length of itsparent. Images that can be changed at runtime are dynamicimages.

Indicator A special type of argument (often referred to as "flags") whichconditionally controls command line execution. Boolean innature, it can only be set to true or false. It is created with theindicator command and defaults to a false status until someother event in the program resets it to true (i.e., indicatorselect). Once defined, an indicator is addressed by enclosingits name in brackets ("[" and "]") to identify it to the commandprocessor (i.e., [not select] return).

Inheritance The process of assuming properties and message handlers froman object's class. Inheritance saves the effort and potential errorof having to define the properties and messages of every objectexplicitly. See also Subclass; Superclass.

Page 537: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Glossary

Data Access Corporation 537

Terms DefinitionsInstance The coming to existence of an object (i.e., an object is an

instance of a class). The realization of a class definition. In aclass, the construct_object is the operation, which is executedon a new instance of the class to configure the instance toconform to the class's definition. See also Class; Object.

Integer One of three types of numeric representations that can be usedas the subject of a command's execution or expressionevaluation. A field, variable or window used for storing numbertypes. Only whole numbers can be stored in this type, rangingfrom 0 to ±2,147,483,647. There is an integer command, whichdefines a variable type integer. See also Variable; Window.

Invalid Message A message not understood by the receiving object, its ancestorsor the desktop. When the message reaches the desktop and itcan not understand it, an error is generated. See also Message.

Item A storage area for data associated with an object, displayed foruser interaction. When an object, which contains items, isdisplayed for interaction with the user, the data for the itemswill be displayed in the windows of the object's image. Thedata for each item is initialized when the item is created,according to the command used to create the item. All itemshave a value property associated with them. The data stored inthe value property of an item is a string and is displayed whenthe user is interacting with the object. Items may containdifferent types of data and maintain various states, dependingon the class of the object in which the item is created. There arefive types of item lists, which can be created by DataFlex;Static, Dynamic, Entry, Window and Array. See also Item List,Dynamic; Item List, Static; Object.

Page 538: Discovering Visual DataFlex 9.1

Glossary Discovering Visual DataFlex

538 Data Access Corporation

Terms DefinitionsItem List, Dynamic A list where not all of the items in an object can be seen in the

windows at once. Consequently these objects alsoautomatically create a scroll bar to indicate when there aremore items above or below the items currently displayed. Theclasses, which support dynamic item lists, are DFList,Checklist, Entrylist, and Formlist. The add_item andinsert_item commands are used to create items in objects ofthese classes, while the delete_item message can be used toremove items from the list. The syntax for add_item andinsert_item allow the item's message and value to be specified,but the item selection message is always sent to the object inwhich the items are created. See also Item; Item List, Static;Object.

Item List, Static A list where all the items of an object can be seen in thewindows at once. The classes that use static item lists areMenu, MenuBar, Button, Checkbox, Entry, and Form. Items inobjects based on one of these classes must be created within anitem_list-end_item_list structure using the on_item command.See also Item; Item List, Dynamic; Object.

Label A program location identifier used by control commands (i.e.,goto, gosub, return) to jump over commands and group ofcommands. It is defined as any continuous string of charactersat the beginning of a line followed immediately by a colon (:).Labels must begin with a letter, which may be followed by upto 79 numbers or letters (no spaces or punctuation).

Local Variable A variable which cannot be referenced outside the procedure orfunction which defined it. They are defined by invoking thelocal command preceding the variable type. Multipleprocedures may define local variables with the same name buteach will have its own value. A local variable may not have thesame name as a global variable. Local variables release theirmemory area upon the end_procedure line. See also Global;Variable.

Page 539: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Glossary

Data Access Corporation 539

Terms DefinitionsMacro A set of code (which the compiler understands) that accepts

arguments and textually substitutes the values of the argumentsinto the command model. The resultant commands are thencompiled and included with the rest of the code. Macros can bedefined directly within one or more programs, or they can bedefined in packages. Macros are expanded every time thecompiler finds a call to it. See also Command; Subroutine.

Menu There is a menu object class, and a user-interface elementcalled menu. The class is frequently user to create the elementin programs. See Menu bar Pulldown; Class, Base.

Menu bar Pulldown An extension of the menu bar that displays a list of choicesavailable for a selected choice in the menu bar. After a userselects a choice in the menu bar, the pulldown appears. Anotherterm is Menu.

Message A request for an object to perform one of its operations. It isnot a behavior, it is a name (and the arguments) of a behavior.They are the only interface to an object. Messages are sent andreceived by the send, get, and set commands. These is also amessage class. Messages are like a gosub in procedural code.See Class, Base.

Mode, Property A type of property which has a finite number of values it cancontain. The number of properties is usually three or more;properties with only two possible values are generallyconsidered to be states, not modes. An example of a mode issearch_mode which may be set to first_character, incremental,capital, and no_search. See also State, Property.

Model Navigation: Users are required to finish one task before moving to the next

Number One of three types of numeric representations that can be usedas the subject of a command's execution or expressionevaluation. A field, variable or window used for storing numbertypes. Only fixed point numbers can be stored in this type,ranging from .00000001 to ±99,999,999,999,999.99999999.There is a number command which defines a variable of typeNumeric. See also Variable; Window.

Page 540: Discovering Visual DataFlex 9.1

Glossary Discovering Visual DataFlex

540 Data Access Corporation

Terms DefinitionsObject An object is the realization of a class (sometimes referred to as

the object's type). An object can be defined in terms of theproperties and messages that it understands. The commandsbetween object and End_Object commands are executed by theruntime (not the compiler) during the creation of the object. Anobject relationship to a class is similar to the variable'srelationship to its type. See also Access Method; GlobalObject; Object Identifier. Objects are the instance of using aclass. Like: the Enter Macro in procedural code

Object Identifier An integer unique to each object assigned at runtime when theobject command is executed. This integer is called the absoluteobject identifier. If an object is the child of the desktop thecompiler issues a global object identifier. See also AccessMethod; Object.

Object-OrientedProgramming

A style of programming which uses objects as the unit ofsoftware division and messages as the way to connect objects.Data is encapsulated within an object, making it part of theprocess and is not treated globally.

Operation, Package The messages that are provided for the object class defined bythe package. Of these, the important messages are listed underthe package category of Usage. See also Usage, Package.

Object Package A .PKG file that contains a predefined structure of objects thatmay be used in programs. Example: Confirm.PKG

On_Key Commands that will allow you to define program action. Like aKeyProc in DataFlex procedural code.

Overloading The practice of using message arguments in a class or objectthat have a slightly different purpose in the class from whichthey are inherited. Overloading is apparent to the programmerwhen it is used together with (unchanging) keywords, such asitem, where the actual argument is something slightly different,such as a line number. See also Encapsulation; Polymorphism.

Page 541: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Glossary

Data Access Corporation 541

Terms DefinitionsOverride The process of redefining an inherited property or message.

Creating a procedure, function, or property with the same nameas the one inherited causes the new definition to be used inplace of the old, thus overriding the inherited property. See alsoAugment.

Package A body of source code frequently composed of several classes,objects and screen definitions (images). They are a finishedpiece of code including the user interface, ready forimplementation into your program. Packages are plain ASCIIfiles, but must use the extension .PKG in their filenames. Anexample is the List package which provides users with a classthat defines a pop-up look up list.

Panel A portion of the screen, usually rectangular, containing datarelating to a particular function among those displayed on thescreen. Panels often contain several lines and several windows,and may pop up and disappear with user interaction. Panelsrepresenting sub-functions outside which the mouse is disabled(modal dialogs) are surrounded with a double line, whileothers, outside which mouse action is allowed, are surroundedwith a single line. See also Image; Window.

Parameter A parameter is a value, or one of several values included in aprocedure or function call. These values are "passed" to theprocedure or function to allow it to have some desired effect.For example, a procedure designed to draw a box on the screencould be passed the height and width of the box as parameters.

Parent File A naming convention denoting a database file which is beingrelated to and there is a valid relationship established. Thisdatabase file requires the field upon which the relation is basedto be uniquely identifiable (main index for that field must notcontain record number). Once a valid relationship is establishedboth the Parent and Child database files will feel like one largedatabase. The benefits for relating database files are efficientutilization of disk space (reduce data redundancy), improvedefficiency in changing data, greater consistency and an easierview of the system conceptually. See also Child File.

Page 542: Discovering Visual DataFlex 9.1

Glossary Discovering Visual DataFlex

542 Data Access Corporation

Terms DefinitionsParent Object An object-creation block with nested object-creation blocks in

it. Parentage provides a route for inheritance of properties anddelegation of messages. See also Ancestor; Child Object.

Polymorphism The characteristic of objects and message definitions thatpermits the use of object and variable names that match in morethan one place without conflict between the same-namedobjects and/or messages. In object and message names, thisarises from the fact that objects and their messages can beaddress from outside the object only through their fullparentage. In the names of variables used in messages, it arisesfrom the fact that message arguments are automatically createdas local variables, and local variables are normally used whendeclared inside message definitions. See also Access Method;Encapsulation; Local Variable; Overloading.

Pop-Up Window A movable window, fixed in size, in which users provideinformation that is required by an application so it can continuea user request. See also Menu bar Pulldown.

ProceduralProgramming

A programming style which places emphasis on algorithmicdescription, or how a procedure works. Procedural programsare built out of procedures and global data used by theprocedures. Data, when considered at all, is secondary, global,and often considered unrelated to procedures. See also Object-Oriented Programming.

Procedure A block of code inside an object which incorporates a set ofcommands that jointly define messages sent to the object. Themessage is defined using the set and send commands. It isdefined by the procedure and end_procedure commands.Procedures can receive and/or send messages. Procedures cannot be nested. They are like a subroutine in procedural code.See also Command; Delegate; Function; Message; Object.

Page 543: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Glossary

Data Access Corporation 543

Terms DefinitionsProperty The characteristics determining the uniqueness of an object.

The characteristics are determined by the class and set by theobject itSelf. location is an example of a property. Theinformation in a property may not necessarily have a directeffect on the appearance of an object. A property is simply adata storage area associated with a particular object. They arelike predefined variables in DataFlex procedural code.

PullDown See Menu bar Pulldown.

Real One of three types of numeric representations that can be usedas the subject of a command's execution or expressionevaluation. A variable or window used for storing numbertypes. Only floating point numbers can be stored in this type, inthe range ±10±306. There is a real command which defines avariable of Type Real. See also Variable; Window.

Record An area in a database file composed of fields (pieces ofinformation) relating to a particular thing. Records areautomatically assigned a unique record number when it iscreated. You can have up to 16.6 million records in a databasefile and 255 fields within a record. See also Field; File,Database.

Refresh Screen The process of redrawing all objects on the screen. This is doneso that the screen shows the current state of the application orapplications.

Reindex The process of updating an index file. This process is generatedby using the DataFlex Index Tool. Its use is to update batchindex files and online index files which have become corrupt(due to programming error or hardware failure). See also File,Index.

Page 544: Discovering Visual DataFlex 9.1

Glossary Discovering Visual DataFlex

544 Data Access Corporation

Terms DefinitionsRelative Identifier A way to access objects which are created as immediate

children of that class. The syntax is, the class name, followedby a period, the object name, and `.OBJ'. The identifier isrelative in that it is only valid in relation to the class beingdefined, and cannot be used outside the class definitionstructure. A relative identifier is quicker and easier to usewithin a class definition, and is the preferred method toreference objects in class definitions. See also Class; Object.

Rotate The shifting of the current focus from one object to another inthe Focus List. See also Focus List; Object.

Scope A set of objects that are meant to be accessed as a single unit.When a parent object has its scope_state set to true, all of itschildren are within the scope. Objects which have thescope_state set to true are accessed by the msg_entering_scopeand msg_exiting_scope messages. Scopes are used to isolateparts of the application which are independent of each other.See also Message; Object; Property.

State, Object The class, all of the values of all the properties of an object andits children. If any of these change then the object has changedstate.

State, Property A property which may have one of two values. Exampleswould be on/off, true/false, right/left. A property which hassome number of finite values greater than two is generallyreferred to as a mode. See also Mode, Property.

String A command used to create a variable of type ASCII,representing a string of characters which will have a consistentmeaning (but with contents that vary). The variable created willdefault to 80 characters in length, if the length is not specifiedin the command line (i.e., string varname 40; this willcreate a variable of type ASCII called varname with a length of40 characters). See also Variable.

Subclass A naming convention denoting a descendent class; a classwhich inherits from another class. See also Inheritance;Superclass.

Page 545: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Glossary

Data Access Corporation 545

Terms DefinitionsSubimage See Image, Shared.

Subroutine A block of code created after the end of the program (abort orsystem command). A subroutine is defined with a label andnormally ends with a return command. A subroutine is accessedby a gosub control command with the label identifying thesubroutine. Subroutines are read by the compiler once (savescompile lines). They are created to stop redundant coding(same block of code is used in several places). See also Label.

Superclass A class used to base a class-creation block on. An ancestor orparent of a class which provides properties and messages for itsdescendent to inherit. See also Class; Class, Base; Inheritance;Subclass.

Support Command,Package

Many packages create commands exclusively for use withobjects created from the class defined in the package. Thesecommands are discussed in the "Support Commands" section ofthe documentation of each package.

Text See File Sequential.

UIMS User Interface Management System (UIMS) is a programmingenvironment in which DataFlex programmers can create andmaintain attractive, intuitive, and powerful user interfaces forapplications.

Update Procedure A procedure in the Data_Set class called during new & editsaves that allows the programmer to code during a lock state(such as maintaining running totals). Like Enter.Save

Usage, Package The primary documentation of how to use a class defined by apackage. This section documents the basic use and syntax ofthe package as well all the messages and attributes which weexpect you to use under "normal" circumstances.

Use Command Includes a file into the code if it has not already been included.Like #INCLUDE command.

Page 546: Discovering Visual DataFlex 9.1

Glossary Discovering Visual DataFlex

546 Data Access Corporation

Terms DefinitionsUser Interface The method by which the program communicates with the user.

Examples are popupMenus, pop-up screens, error and promptmessages, scrolling windows, accelerator keys, etc. See alsoEvent-Driven Interface.

Validate Validation refers to the process of determining whether somespecified data meets a set of criteria. For example, before wesave a new record, we might wish to validate it by checkingthat all the fields had been filled in with acceptable entries.

Value In reference to the items of an object, value generally refers tothe data which that item holds. For example, the value of aparticular item of a list would be the text displayed in that item.

Variable Data values that can be changed in the course of a program'sexecution. They are stored in memory, and are of a fixedlength. Variable names may be up to 80 characters in length,must begin with a letter, and may not contain a space. The datatypes stored in variables are Date, Numeric, Real and String.Once a variable is designated a data type it can containinformation consistent with its type. If data is not of the sametype it will convert it to the proper type when it is moved (seemove command in the DataFlex Command Reference). Seealso Date; Number; Real; String.

Virtual A method of reading data into the buffer from disk. Virtualobjects only read the data necessary for interaction, as opposedto batch objects which read all of the data at once. This methodof reading data is useful when handling large amounts of data.See also Object.

View A section of code (usually encapsulated in anEntry_View_Client Object and activated by way of selectionfrom a pulldown menu). That handles one aspect of a largeapplication. E.g., The data-entry section allowing customerentry. These independent views are coded and tested standalone and then combined with other views to create anapplication.

Page 547: Discovering Visual DataFlex 9.1

Discovering Visual DataFlex Glossary

Data Access Corporation 547

Terms DefinitionsWindow An area of an image designated for data output. A window is

formatted to accept one of three data types (ASCII, Numeric, orDate). Data is validated based on the format given to thewindow. They are addressed by reference to the name of theimage of which they are a component, and their sequentialposition in that image (i.e., move body.2 to body.6,copies the contents of the second window in the image calledbody to the sixth window of the image called body). Thesequence is established by numbering the windows on each linefrom left to right, moving from the top to the bottom lines ofthe image. See also Current Image; Current Window; Image.

Window 1) The DataFlex language has always used this to refer to anarea of the screen with visible boundaries through whichinformation is displayed. A window can be smaller than orequal in size to the screen. 2) A choice in the menu bar ofmultiple-document interface applications. See also Image.

Zero-Based A system of numbering which uses zero as the first number(starts with 0). For example, the numbering of all items inobjects is zero-based. This means that the first item in an objectis always Item 0, not Item 1.

Page 548: Discovering Visual DataFlex 9.1

Glossary Discovering Visual DataFlex

548 Data Access Corporation

Page 549: Discovering Visual DataFlex 9.1

EvaluationVisual DataFlex Class & Manual

Students completing a class, please fill out both parts A and B. Students using themanual as a Self taught course, please answer only part B. When complete, simply pullthis page out, fold on dotted line, tape where indicated, stamp, and drop in the mail.

Part A:

Part B:

Additional Comments:____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

Training Manual errors:

Page Number Discrepancy

___________ _______________________________________________

___________ _______________________________________________

___________ _______________________________________________

___________ _______________________________________________

Date: ________________________

Location: ________________________

Instructor: ________________________

Would you recommend the class to a friend? ____

Please rate the following on a scale from 1 to 10 (10 being the best)

• Class overall? ____

• Instructor? ____

• Training manual? ____

• Handouts and other training media? ____

Page 550: Discovering Visual DataFlex 9.1

Thank you for your comments.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Data Access Worldwide

Training Dept.

14000 S.W. 119 Avenue

Miami, FL USA 33186-6017

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

tape here