You are on page 1of 279

Fast Track to PowerBuilder, Part 1

Fast Track to PowerBuilder, Part 1

Lab WorkBook

Lab WorkBook

Version 1.0
Part # DEV134-90-1200-10

Version 1.0
Part # DEV134-90-1200-10

Notice

Notice

Copyright 2010 Sybase, Inc. All rights reserved.

Copyright 2010 Sybase, Inc. All rights reserved.

No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic,
mechanical, manual, optical or otherwise, without prior written permission from Sybase, Inc.

No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic,
mechanical, manual, optical or otherwise, without prior written permission from Sybase, Inc.

indicates registration in the United States of America.

indicates registration in the United States of America.

Sybase Trademarks

Sybase Trademarks

Sybase, SYBASE (logo), ADA Workbench, Adaptable Windowing Environment, Adaptive Component Architecture, Adaptive
Server, Adaptive Server Anywhere, Adaptive Server Enterprise, Adaptive Warehouse, AnswerBase, Application Manager,
AppModeler, APT Workbench, APT-Build, APT-Edit, APT-Execute, APT-FORMS, APT-Translator, APT-Library, ASEP,
Backup Server, BayCam, Bit-Wise, Certified PowerBuilder Professional, Certified SYBASE Professional, Certified SYBASE
Professional Logo, ClearConnect, Client-Library, Client Services, CodeBank, Column Design, ComponentPack, Connection
Manager, CSP, Data Pipeline, Data Workbench, DataArchitect, Database Analyzer, DataExpress, DataServer, DataWindow, DBLibrary, dbQueue, Developers Workbench, DirectConnect, Distribution Agent, Distribution Director, Dynamo, Electronic Case
Management, Embedded SQL, EMS, Enterprise Client/Server, Enterprise Connect, Enterprise Manager, Enterprise SQL Server
Manager, Enterprise Work Architecture, Enterprise Work Designer, Enterprise Work Modeler, EWA, First Impression, Formula
One, Gateway Manager, GeoPoint, IDN, ImpactNow, InfoMaker, InformationConnect, InstaHelp, Internet Developers Network,
InternetBuilder, iScript, Jaguar CTS, jConnect for JDBC, KnowledgeBase, Logical Memory Manager, MainframeConnect,
Maintenance Express, MAP, MDI Access Server, MDI Database Gateway, media.splash, MetaWorks, MethodSet, Net-Gateway,
Net-Library, NetImpact, O DEVICE, OASiS, OASiS logo, ObjectConnect, ObjectCycle, OmniConnect, OmniSQL Access
Module, OmniSQL Toolkit, Open Client, Open ClientConnect, Open Client/Server, Open Client/Server Interfaces, Open
Gateway, Open Server, Open ServerConnect, Open Solutions, Optima++, Partnerships that Work, PB-Gen, PC APT Execute, PC
DB-Net, PC Net Library, Power ++, Power J, Power Through Knowledge, power.stop, PowerAMC, PowerBuilder, PowerBuilder
Foundation Class Library, PowerBuilt, PowerBuilt with PowerBuilder, PowerDesigner, PowerScript, PowerSite, PowerSocket,
Powersoft, PowerStudio, PowerTips, Powersoft Portfolio, Powersoft Professional, PowerWare Desktop, PowerWare Enterprise,
ProcessAnalyst, QuickStart DataMart, QuickStart MediaMart, QuickStart ReportSmart, Report Workbench, Report-Execute,
Replication Agent, Replication Driver, Replication Server, Replication Server Manager, Replication Toolkit, Resource Manager,
RW-DisplayLib, RW-Library, S Designor, S-Designor, SAFE, SAFE/PRO, SDF, Secure SQL Server, Secure SQL Toolset,
Security Guardian, SKILS, smart.partners, smart.parts, smart.script, SQL Advantage, SQL Code Checker, SQL Debug, SQL
Edit/TPU, SQL Edit, SQL Modeler, SQL Remote, SQL Server, SQL Server Manager, SQL Server Monitor, SQL SMART, SQL
Toolset, SQL Server/CFT, SQL Server/DBM, SQL Server SNMP SubAgent, SQL Solutions, SQL Station, STEP, SupportPlus,
Sybase Central, Sybase Client/Server Interfaces, Sybase Development Framework, Sybase Gateways, Sybase IQ, Sybase MPP,
Sybase SQL Desktop, Sybase SQL Lifecycle, Sybase SQL Workgroup, Sybase Synergy Program, Sybase Virtual Server
Architecture, Sybase User Workbench, SybaseWare, SyBooks, System 10, System 11, System XI (logo), SystemTools, Tabular
Data Stream, The Enterprise Client/Server Company, The Extensible Software Platform, The Future Is Wide Open, The Learning
Connection, The Model For Client/Server Solutions, The Online Information Center, Transact-SQL, Translation Toolkit, Turning
Imagination Into Reality, UNIBOM, Unilib, Uninull, Unisep, Unistring, Viewer, Visual Components, VisualSpeller,
VisualWriter, VQL, WarehouseArchitect, Warehouse WORKS, Watcom, Watcom SQL, Watcom SQL Server, Web.PB,
Web.SQL, WebSights, WebViewer, WorkGroup SQL Server, XA-Library and XA-Server are trademarks of Sybase, Inc. or its
subsidiaries.

Sybase, SYBASE (logo), ADA Workbench, Adaptable Windowing Environment, Adaptive Component Architecture, Adaptive
Server, Adaptive Server Anywhere, Adaptive Server Enterprise, Adaptive Warehouse, AnswerBase, Application Manager,
AppModeler, APT Workbench, APT-Build, APT-Edit, APT-Execute, APT-FORMS, APT-Translator, APT-Library, ASEP,
Backup Server, BayCam, Bit-Wise, Certified PowerBuilder Professional, Certified SYBASE Professional, Certified SYBASE
Professional Logo, ClearConnect, Client-Library, Client Services, CodeBank, Column Design, ComponentPack, Connection
Manager, CSP, Data Pipeline, Data Workbench, DataArchitect, Database Analyzer, DataExpress, DataServer, DataWindow, DBLibrary, dbQueue, Developers Workbench, DirectConnect, Distribution Agent, Distribution Director, Dynamo, Electronic Case
Management, Embedded SQL, EMS, Enterprise Client/Server, Enterprise Connect, Enterprise Manager, Enterprise SQL Server
Manager, Enterprise Work Architecture, Enterprise Work Designer, Enterprise Work Modeler, EWA, First Impression, Formula
One, Gateway Manager, GeoPoint, IDN, ImpactNow, InfoMaker, InformationConnect, InstaHelp, Internet Developers Network,
InternetBuilder, iScript, Jaguar CTS, jConnect for JDBC, KnowledgeBase, Logical Memory Manager, MainframeConnect,
Maintenance Express, MAP, MDI Access Server, MDI Database Gateway, media.splash, MetaWorks, MethodSet, Net-Gateway,
Net-Library, NetImpact, O DEVICE, OASiS, OASiS logo, ObjectConnect, ObjectCycle, OmniConnect, OmniSQL Access
Module, OmniSQL Toolkit, Open Client, Open ClientConnect, Open Client/Server, Open Client/Server Interfaces, Open
Gateway, Open Server, Open ServerConnect, Open Solutions, Optima++, Partnerships that Work, PB-Gen, PC APT Execute, PC
DB-Net, PC Net Library, Power ++, Power J, Power Through Knowledge, power.stop, PowerAMC, PowerBuilder, PowerBuilder
Foundation Class Library, PowerBuilt, PowerBuilt with PowerBuilder, PowerDesigner, PowerScript, PowerSite, PowerSocket,
Powersoft, PowerStudio, PowerTips, Powersoft Portfolio, Powersoft Professional, PowerWare Desktop, PowerWare Enterprise,
ProcessAnalyst, QuickStart DataMart, QuickStart MediaMart, QuickStart ReportSmart, Report Workbench, Report-Execute,
Replication Agent, Replication Driver, Replication Server, Replication Server Manager, Replication Toolkit, Resource Manager,
RW-DisplayLib, RW-Library, S Designor, S-Designor, SAFE, SAFE/PRO, SDF, Secure SQL Server, Secure SQL Toolset,
Security Guardian, SKILS, smart.partners, smart.parts, smart.script, SQL Advantage, SQL Code Checker, SQL Debug, SQL
Edit/TPU, SQL Edit, SQL Modeler, SQL Remote, SQL Server, SQL Server Manager, SQL Server Monitor, SQL SMART, SQL
Toolset, SQL Server/CFT, SQL Server/DBM, SQL Server SNMP SubAgent, SQL Solutions, SQL Station, STEP, SupportPlus,
Sybase Central, Sybase Client/Server Interfaces, Sybase Development Framework, Sybase Gateways, Sybase IQ, Sybase MPP,
Sybase SQL Desktop, Sybase SQL Lifecycle, Sybase SQL Workgroup, Sybase Synergy Program, Sybase Virtual Server
Architecture, Sybase User Workbench, SybaseWare, SyBooks, System 10, System 11, System XI (logo), SystemTools, Tabular
Data Stream, The Enterprise Client/Server Company, The Extensible Software Platform, The Future Is Wide Open, The Learning
Connection, The Model For Client/Server Solutions, The Online Information Center, Transact-SQL, Translation Toolkit, Turning
Imagination Into Reality, UNIBOM, Unilib, Uninull, Unisep, Unistring, Viewer, Visual Components, VisualSpeller,
VisualWriter, VQL, WarehouseArchitect, Warehouse WORKS, Watcom, Watcom SQL, Watcom SQL Server, Web.PB,
Web.SQL, WebSights, WebViewer, WorkGroup SQL Server, XA-Library and XA-Server are trademarks of Sybase, Inc. or its
subsidiaries.

All other company and product names used herein may be the trademarks or registered trademarks of their
respective companies.

All other company and product names used herein may be the trademarks or registered trademarks of their
respective companies.

Restricted Rights Legend

Restricted Rights Legend

Use, duplication or disclosure by the Government is subject to restrictions set forth in subparagraph (c)(1)(ii) of
DFARS 52.227-7013 for the DOD and as set forth in FAR 52.227-19(a)(d) for civilian agencies.

Use, duplication or disclosure by the Government is subject to restrictions set forth in subparagraph (c)(1)(ii) of
DFARS 52.227-7013 for the DOD and as set forth in FAR 52.227-19(a)(d) for civilian agencies.

Sybase, Inc., One Sybase Drive, Dublin, CA 94568

Sybase, Inc., One Sybase Drive, Dublin, CA 94568

Fast Track to PowerBuilder, Part I


Lab Workbook

Module 1: Course Introduction and Overview

Fast Track to PowerBuilder, Part I


Lab Workbook

Module 1: Course Introduction and Overview

Lab 1-1: Installing Student Files ..................................................................................................Lab 1-1


Detailed Instructions ....................................................................................................................Lab 1-2

Module 2: Understanding and Navigating the PowerBuilder IDE

Lab 1-1: Installing Student Files ..................................................................................................Lab 1-1


Detailed Instructions ....................................................................................................................Lab 1-2

Module 2: Understanding and Navigating the PowerBuilder IDE

Lab 2-1: Customizing & Configuring the IDE.............................................................................Lab 2-1


Detailed Instructions ....................................................................................................................Lab 2-2
Lab 2-2: Experimenting with Workspaces and Targets ...............................................................Lab 2-12
Detailed Instructions ....................................................................................................................Lab 2-13
Lab 2-3: Experimenting with PBLs .............................................................................................Lab 2-17
Detailed Instructions ....................................................................................................................Lab 2-18
Lab 2-4: Creating the SybHealth Application ..............................................................................Lab 2-23
Detailed Instructions ....................................................................................................................Lab 2-24
Lab 2-5: Using Utility Tools ........................................................................................................Lab 2-28
Detailed Instructions ....................................................................................................................Lab 2-29
Lab 2-6: Painter Configuration ....................................................................................................Lab 2-41
Lab 2-7: Opening & Searching ....................................................................................................Lab 2-45
Detailed Instructions ....................................................................................................................Lab 2-46
Lab 2-8: Examine NewsGroups, ISUG, Codexchange ................................................................Lab 2-48

Module 3: Coding Fundamentals

Lab 2-1: Customizing & Configuring the IDE.............................................................................Lab 2-1


Detailed Instructions ....................................................................................................................Lab 2-2
Lab 2-2: Experimenting with Workspaces and Targets ...............................................................Lab 2-12
Detailed Instructions ....................................................................................................................Lab 2-13
Lab 2-3: Experimenting with PBLs .............................................................................................Lab 2-17
Detailed Instructions ....................................................................................................................Lab 2-18
Lab 2-4: Creating the SybHealth Application ..............................................................................Lab 2-23
Detailed Instructions ....................................................................................................................Lab 2-24
Lab 2-5: Using Utility Tools ........................................................................................................Lab 2-28
Detailed Instructions ....................................................................................................................Lab 2-29
Lab 2-6: Painter Configuration ....................................................................................................Lab 2-41
Lab 2-7: Opening & Searching ....................................................................................................Lab 2-45
Detailed Instructions ....................................................................................................................Lab 2-46
Lab 2-8: Examine NewsGroups, ISUG, Codexchange ................................................................Lab 2-48

Module 3: Coding Fundamentals

Lab 3-1: Basic Coding Techniques ..............................................................................................Lab 3-1


Detailed Instructions ....................................................................................................................Lab 3-2

Module 4: Adding Funcationality to Classes

Lab 3-1: Basic Coding Techniques ..............................................................................................Lab 3-1


Detailed Instructions ....................................................................................................................Lab 3-2

Module 4: Adding Funcationality to Classes

Lab 4-1: More Advanced Coding Techniques ............................................................................Lab 4-1


Detailed Instructions ....................................................................................................................Lab 4-2

Module 5: User Interfaces in PowerBuilder

Lab 4-1: More Advanced Coding Techniques ............................................................................Lab 4-1


Detailed Instructions ....................................................................................................................Lab 4-2

Module 5: User Interfaces in PowerBuilder

Lab 5-1: Exploring and Creating Framework Objects .................................................................Lab 5-1


Detailed Instructions ....................................................................................................................Lab 5-2
Lab 5-2: Building SybHealth Windows ......................................................................................Lab 5-10
Detailed Instructions ....................................................................................................................Lab 5-11
2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

TOC - 1

Lab 5-1: Exploring and Creating Framework Objects .................................................................Lab 5-1


Detailed Instructions ....................................................................................................................Lab 5-2
Lab 5-2: Building SybHealth Windows ......................................................................................Lab 5-10
Detailed Instructions ....................................................................................................................Lab 5-11
2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

TOC - 1

Lab Workbook

Lab Workbook

Module 6: Working with Menus

Module 6: Working with Menus

Lab 6-1: Creating a Menu Hierarchy ..........................................................................................Lab 6-1


Detailed Instructions ....................................................................................................................Lab 6-2
Lab 6-2: Coding Basic Menu Items ............................................................................................Lab 6-12
Detailed Instructions ....................................................................................................................Lab 6-13

Module 7: Working with MDI Applications

Lab 6-1: Creating a Menu Hierarchy ..........................................................................................Lab 6-1


Detailed Instructions ....................................................................................................................Lab 6-2
Lab 6-2: Coding Basic Menu Items ............................................................................................Lab 6-12
Detailed Instructions ....................................................................................................................Lab 6-13

Module 7: Working with MDI Applications

Lab 7-1: Building Application Windows .....................................................................................Lab 7-1


Detailed Instructions ....................................................................................................................Lab 7-2
Lab 7-2: Opening Sheets and Resizing Code ..............................................................................Lab 7-7
Detailed Instructions ....................................................................................................................Lab 7-8

Module 8: Using the Database Painter & Working with Extended


Attributes

Lab 7-1: Building Application Windows .....................................................................................Lab 7-1


Detailed Instructions ....................................................................................................................Lab 7-2
Lab 7-2: Opening Sheets and Resizing Code ..............................................................................Lab 7-7
Detailed Instructions ....................................................................................................................Lab 7-8

Module 8: Using the Database Painter & Working with Extended


Attributes

Lab 8-1: Using the Database Painter ...........................................................................................Lab 8-1


Detailed Instructions ....................................................................................................................Lab 8-2

Module 9: DataWindow Technology - Overview & DataWindow


Objects

Lab 8-1: Using the Database Painter ...........................................................................................Lab 8-1


Detailed Instructions ....................................................................................................................Lab 8-2

Module 9: DataWindow Technology - Overview & DataWindow


Objects

Lab 9-1: Building Basic DataWindows .......................................................................................Lab 9-1


Detailed Instructions ....................................................................................................................Lab 9-2
Lab 9-2: Building DataWindows Requiring Input ......................................................................Lab 9-6
Detailed Instructions ....................................................................................................................Lab 9-7
Lab 9-3: Building Report DataWindows ....................................................................................Lab 9-18
Detailed Instructions ....................................................................................................................Lab 9-19

Module 10: Using DataWindow Controls

Lab 9-1: Building Basic DataWindows .......................................................................................Lab 9-1


Detailed Instructions ....................................................................................................................Lab 9-2
Lab 9-2: Building DataWindows Requiring Input ......................................................................Lab 9-6
Detailed Instructions ....................................................................................................................Lab 9-7
Lab 9-3: Building Report DataWindows ....................................................................................Lab 9-18
Detailed Instructions ....................................................................................................................Lab 9-19

Module 10: Using DataWindow Controls

Lab 10-1: Coding a Basic Database Connection .........................................................................Lab 10-1


Detailed Instructions ....................................................................................................................Lab 10-2
Lab 10-2: Completing Application Sheets ..................................................................................Lab 10-6
Detailed Instructions ....................................................................................................................Lab 10-7
Lab 10-3: Enabling Basic DataWindow Functionality ...............................................................Lab 10-13
Detailed Instructions ....................................................................................................................Lab 10-14

Module 11: Inserting and Deleting Data

Lab 10-1: Coding a Basic Database Connection .........................................................................Lab 10-1


Detailed Instructions ....................................................................................................................Lab 10-2
Lab 10-2: Completing Application Sheets ..................................................................................Lab 10-6
Detailed Instructions ....................................................................................................................Lab 10-7
Lab 10-3: Enabling Basic DataWindow Functionality ...............................................................Lab 10-13
Detailed Instructions ....................................................................................................................Lab 10-14

Module 11: Inserting and Deleting Data

Lab 11-1: Adding Insert/Delete Functionality to SybHealth ......................................................Lab 11-1


Detailed Instructions ....................................................................................................................Lab 11-2

Module 12: Saving Data to the Database (Basics)

Lab 11-1: Adding Insert/Delete Functionality to SybHealth ......................................................Lab 11-1


Detailed Instructions ....................................................................................................................Lab 11-2

Module 12: Saving Data to the Database (Basics)

Lab 12-1: Saving Data to the Database .......................................................................................Lab 12-1


TOC - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 12-1: Saving Data to the Database .......................................................................................Lab 12-1


TOC - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I

Module 13: NVOs: Non-Visual (User) Objects

Fast Track to PowerBuilder, Part I

Module 13: NVOs: Non-Visual (User) Objects

Lab 13-1: Creating and Using Standard Class User Objects ......................................................Lab 13-1
Detailed Instructions ....................................................................................................................Lab 13-2
Lab 13-2: Creating and Using Custom Class User Objects ........................................................Lab 13-14

Module 14: Object Communication: Message Object

Lab 13-1: Creating and Using Standard Class User Objects ......................................................Lab 13-1
Detailed Instructions ....................................................................................................................Lab 13-2
Lab 13-2: Creating and Using Custom Class User Objects ........................................................Lab 13-14

Module 14: Object Communication: Message Object

Lab 14-1: Communication Between Windows ...........................................................................Lab 14-1


Detailed Instructions ....................................................................................................................Lab 14-2

Module 15: Intermediate DataWindow Topics

Lab 14-1: Communication Between Windows ...........................................................................Lab 14-1


Detailed Instructions ....................................................................................................................Lab 14-2

Module 15: Intermediate DataWindow Topics

Lab 15-1: Implementing a Master-Detail Interface .....................................................................Lab 15-1


Lab 15-2: Implementing Client-Side Sort and Filter Capabilities...............................................Lab 15-5
Detailed Instructions ....................................................................................................................Lab 15-6
Lab 15-3: Implementing Data Validation ...................................................................................Lab 15-12
Detailed Instructions ....................................................................................................................Lab 15-13
Lab 15-4: Completing Update Functionality ..............................................................................Lab 15-16
Detailed Instructions ....................................................................................................................Lab 15-17

Module 16: Deploying PowerBuilder Applications

Lab 15-1: Implementing a Master-Detail Interface .....................................................................Lab 15-1


Lab 15-2: Implementing Client-Side Sort and Filter Capabilities...............................................Lab 15-5
Detailed Instructions ....................................................................................................................Lab 15-6
Lab 15-3: Implementing Data Validation ...................................................................................Lab 15-12
Detailed Instructions ....................................................................................................................Lab 15-13
Lab 15-4: Completing Update Functionality ..............................................................................Lab 15-16
Detailed Instructions ....................................................................................................................Lab 15-17

Module 16: Deploying PowerBuilder Applications

Lab 16-1: Delivering the SybHealth Application .......................................................................Lab 16-1


Detailed Instructions ....................................................................................................................Lab 16-2

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

TOC-3

Lab 16-1: Delivering the SybHealth Application .......................................................................Lab 16-1


Detailed Instructions ....................................................................................................................Lab 16-2

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

TOC-3

Lab Workbook

TOC - 4

Lab Workbook

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

TOC - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 1: Course Introduction and Overview

Module 1: Course Introduction and Overview

Module 1: Course Introduction and Overview

Module 1: Course Introduction and Overview

Lab 1-1: Installing Student Files

Lab 1-1: Installing Student Files

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Install the files from the accompanying CD-ROM, which are necessary to complete the
labs for this course.

Install the files from the accompanying CD-ROM, which are necessary to complete the
labs for this course.

Familiarize yourself with the final solution so that you will better understand the
application you will be building.

Familiarize yourself with the final solution so that you will better understand the
application you will be building.

Description:

In this lab, you will install the files from the CD-ROM that accompanied your Student
Guide. You will become familiar with the directory structure created from the install,
learning where you will store application components that you create as well as understand
the purpose of the other lab folders. After installing the student files, you will run the final
solution (executables) so that you have an idea of what you will be building over the next
five days.

Description:

In this lab, you will install the files from the CD-ROM that accompanied your Student
Guide. You will become familiar with the directory structure created from the install,
learning where you will store application components that you create as well as understand
the purpose of the other lab folders. After installing the student files, you will run the final
solution (executables) so that you have an idea of what you will be building over the next
five days.

Task Outline:

Task 1: Installing Student Files

Task Outline:

Task 1: Installing Student Files

Task 2: Running the Final Solution

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Running the Final Solution

Lab 1 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 1 - 1

Lab Workbook: Lab 1

Lab Workbook: Lab 1

Detailed Instructions

Detailed Instructions

Task 1: Installing Student Files

Task 1: Installing Student Files

Lab 1 - 2

1.

Insert the provided CD-ROM into your machine and open Windows Explorer.

1.

Insert the provided CD-ROM into your machine and open Windows Explorer.

2.

In Windows Explorer, navigate to your CD drive. You will see a file in the root
directory on the CD named Setup.exe. Double-click this file.

2.

In Windows Explorer, navigate to your CD drive. You will see a file in the root
directory on the CD named Setup.exe. Double-click this file.

3.

Setup.exe is a WinZip self-extracting executable. When the WinZip Self-Extractor


dialog appears, make sure you Unzip to folder: C:\. The WinZip file has folder
names associated with its contents so that you are not extracting to your root
directory.

3.

Setup.exe is a WinZip self-extracting executable. When the WinZip Self-Extractor


dialog appears, make sure you Unzip to folder: C:\. The WinZip file has folder
names associated with its contents so that you are not extracting to your root
directory.

4.

Click the Unzip button.

4.

Click the Unzip button.

5.

When unzipping is complete, close the WinZip dialog.

5.

When unzipping is complete, close the WinZip dialog.

6.

Remove your CD-ROM from the machine.

6.

Remove your CD-ROM from the machine.

7.

Go back to Windows Explorer.

7.

Go back to Windows Explorer.

8.

Under the C:\ drive you will see a folder named Sybase Courses. Under that is folder
named DEV134 (the course code for FastTrack to PowerBuilder, Part I). Below
DEV134 are a series of folders. Review the contents of those folders:

8.

Under the C:\ drive you will see a folder named Sybase Courses. Under that is folder
named DEV134 (the course code for FastTrack to PowerBuilder, Part I). Below
DEV134 are a series of folders. Review the contents of those folders:

9.

The course uses Sybases SQL Anywhere database (Version 11). The Database
folder contains a SQL Anywhere database named SybHealth.db. There is also a file
named SybHealthDDL.sql if you need to create the database / tables on an older
version of SQL Anywhere. A Developers edition of SQL Anywhere 11 can be
installed from your original PowerBuilder installation CD if you do not already have
it on your machine.

9.

The course uses Sybases SQL Anywhere database (Version 11). The Database
folder contains a SQL Anywhere database named SybHealth.db. There is also a file
named SybHealthDDL.sql if you need to create the database / tables on an older
version of SQL Anywhere. A Developers edition of SQL Anywhere 11 can be
installed from your original PowerBuilder installation CD if you do not already have
it on your machine.

10. The Demo Applications will be discussed during the class and will be good for you to
review afterwards.

10. The Demo Applications will be discussed during the class and will be good for you to
review afterwards.

11. There are coded solutions for every lab. If you are doing labs and reach an impasse,
use the solutions as your guide. Module 2 will teach you how to add one of the
solutions (a Target) to your PowerBuilder Workspace.

11. There are coded solutions for every lab. If you are doing labs and reach an impasse,
use the solutions as your guide. Module 2 will teach you how to add one of the
solutions (a Target) to your PowerBuilder Workspace.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 1 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 1: Course Introduction and Overview

2010 Sybase, Inc.

Module 1: Course Introduction and Overview

12. The class and labs will be performed on PowerBuilder 12 Classic. The objects and
code you write and store into PowerBuilder 12 libraries is not backward compatible to
older versions of PowerBuilder. However, final coded solutions for PowerBuilder 9
are available in the Solutions folder. If you are using PowerBuilder 10 through 11.5
at your worksite, you can easily migrate the PowerBuilder 9 solution to your version.

12. The class and labs will be performed on PowerBuilder 12 Classic. The objects and
code you write and store into PowerBuilder 12 libraries is not backward compatible to
older versions of PowerBuilder. However, final coded solutions for PowerBuilder 9
are available in the Solutions folder. If you are using PowerBuilder 10 through 11.5
at your worksite, you can easily migrate the PowerBuilder 9 solution to your version.

13. The Student folder is where anything you create or save is to be placed. This is your
working directory.

13. The Student folder is where anything you create or save is to be placed. This is your
working directory.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 1 - 3

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 1 - 3

Lab Workbook: Lab 1

Lab Workbook: Lab 1

Task 2: Running the Final Solution

Lab 1 - 4

Task 2: Running the Final Solution

1.

To run the solution executables, an ODBC DSN must be created. Go to


StartControl PanelAdministrative ToolsData Sources (ODBC) which will
launch the ODBC Data Source Administrator.

1.

To run the solution executables, an ODBC DSN must be created. Go to


StartControl PanelAdministrative ToolsData Sources (ODBC) which will
launch the ODBC Data Source Administrator.

2.

Click on the System DSN tab.

2.

Click on the System DSN tab.

3.

Click the Add button.

3.

Click the Add button.

4.

Scroll down and select SQL Anywhere 11 on the Create New Data Source dialog.

4.

Scroll down and select SQL Anywhere 11 on the Create New Data Source dialog.

5.

Click Finish.

5.

Click Finish.

6.

On the ODBC Configuration dialog, the ODBC tab, enter SybHealth as the Data
source name.

6.

On the ODBC Configuration dialog, the ODBC tab, enter SybHealth as the Data
source name.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 1 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 1: Course Introduction and Overview

2010 Sybase, Inc.

Module 1: Course Introduction and Overview

7.

On the Login tab, enter sybinsure for both the User ID and Password:

7.

On the Login tab, enter sybinsure for both the User ID and Password:

8.

On the Database tab, click the Browse button, navigating to and selecting the
sybhealth.db in the C:\Sybase Courses\DEV134\Database folder:

8.

On the Database tab, click the Browse button, navigating to and selecting the
sybhealth.db in the C:\Sybase Courses\DEV134\Database folder:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 1 - 5

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 1 - 5

Lab Workbook: Lab 1


9.

Lab Workbook: Lab 1

Return to the ODBC tab and click the Test Connection button. You should receive a
Connection Successful message:

9.

10. Click OK to close the Note dialog, OK again to close the ODBC Configuration
dialog, and OK one more time to close the ODBC Data Source Administrator dialog.

10. Click OK to close the Note dialog, OK again to close the ODBC Configuration
dialog, and OK one more time to close the ODBC Data Source Administrator dialog.

11. In Windows Explorer, navigate to the following directory:

11. In Windows Explorer, navigate to the following directory:

C:\Sybase Courses\DEV134\Solutions\For Deployment - PB 12

Lab 1 - 6

Return to the ODBC tab and click the Test Connection button. You should receive a
Connection Successful message:

C:\Sybase Courses\DEV134\Solutions\For Deployment - PB 12

12. Locate and double-click on sybhealth.exe.

12. Locate and double-click on sybhealth.exe.

13. A login window will appear on top of the MDI frame window. For your convenience,
the User Name and Password (both are sybinsure) have been hard-coded.

13. A login window will appear on top of the MDI frame window. For your convenience,
the User Name and Password (both are sybinsure) have been hard-coded.

14. Click on the Change Database picture button on the login window to observe what
happens. Do not change the database name. It should already contain SybHealth, as
that value is read from an INI file.

14. Click on the Change Database picture button on the login window to observe what
happens. Do not change the database name. It should already contain SybHealth, as
that value is read from an INI file.

15. Click OK to log in.

15. Click OK to log in.

16. After logging in, the MDI Frame window will appear on top of which is a menu.
Click FileNewClaims. Enter a claim for a patient of your choosing. All fields
are required. Click the red X in the upper right of the window to close and save your
changes.

16. After logging in, the MDI Frame window will appear on top of which is a menu.
Click FileNewClaims. Enter a claim for a patient of your choosing. All fields
are required. Click the red X in the upper right of the window to close and save your
changes.

17. Briefly review the other FileNew options.

17. Briefly review the other FileNew options.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 1 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 1: Course Introduction and Overview

2010 Sybase, Inc.

Module 1: Course Introduction and Overview

18. On the main menu, click FileOpenDoctors (or you can click the first icon on the
toolbar). Experiment. Not all of the icons on the 2nd toolbar are active for the
application. The Print icon is active, however there is no printer available in the
classroom. Attempt to delete Doctor # 1047 (Coleman Bertrand). Are you
successful? Why or why not? Click the Export icon and save your doctor list as an
Excel8 spreadsheet. Be sure to save everything in your Student folder. Close the
Doctor Directory window.

18. On the main menu, click FileOpenDoctors (or you can click the first icon on the
toolbar). Experiment. Not all of the icons on the 2nd toolbar are active for the
application. The Print icon is active, however there is no printer available in the
classroom. Attempt to delete Doctor # 1047 (Coleman Bertrand). Are you
successful? Why or why not? Click the Export icon and save your doctor list as an
Excel8 spreadsheet. Be sure to save everything in your Student folder. Close the
Doctor Directory window.

19. Click FileOpenClaims Search. Click on the ellipse button to the right of the
Patient ID field. Double-click any patient that appears on the Patient Search dialog.
The Patient Search dialog closes and pastes the patient ID in the search window for
you. You can then click the Search button. As you see claims, note that you can drag
and re-order columns in the grid display. You can also double-click on a claim which
will display a modal dialog window showing the details of that claim. Edit a claim
and close the modal window, saving changes. You will notice that the claim search
grid does not update, but if you click the Search button a second time you will see the
results of your change. An automatic refresh is a feature you can add when you
perform the labs to create this window. When finished, close the Claims Search
window.

19. Click FileOpenClaims Search. Click on the ellipse button to the right of the
Patient ID field. Double-click any patient that appears on the Patient Search dialog.
The Patient Search dialog closes and pastes the patient ID in the search window for
you. You can then click the Search button. As you see claims, note that you can drag
and re-order columns in the grid display. You can also double-click on a claim which
will display a modal dialog window showing the details of that claim. Edit a claim
and close the modal window, saving changes. You will notice that the claim search
grid does not update, but if you click the Search button a second time you will see the
results of your change. An automatic refresh is a feature you can add when you
perform the labs to create this window. When finished, close the Claims Search
window.

20. Next click FileOpenPatient Details. This is a master-detail window. Select any
patient in the top (tabular) display, and you will see the bottom (free-form) display
update showing the details of the patient chosen. In the top (tabular) display, you may
click on a column header like First Name. You should see that the data is now sorted
by first name. Click the same header again and the sort changes to a descending sort.
For the Patient Details window, the Sort and Filter icons (2nd toolbar) are active.
Click the Sort icon. Drag first_name away from the Columns listbox, and then drag
state_code from Source Data to Columns. Click OK and note the new sort order.
Click the Filter icon on the toolbar. In the Filter dialog, type the expression:
state_code = TX and click OK. The display should filter out every patient but those
located in Texas. Click the Filter icon again. Clear the expression and click OK. All
patients are returned to the display. Leave the Patient Details window open.

20. Next click FileOpenPatient Details. This is a master-detail window. Select any
patient in the top (tabular) display, and you will see the bottom (free-form) display
update showing the details of the patient chosen. In the top (tabular) display, you may
click on a column header like First Name. You should see that the data is now sorted
by first name. Click the same header again and the sort changes to a descending sort.
For the Patient Details window, the Sort and Filter icons (2nd toolbar) are active.
Click the Sort icon. Drag first_name away from the Columns listbox, and then drag
state_code from Source Data to Columns. Click OK and note the new sort order.
Click the Filter icon on the toolbar. In the Filter dialog, type the expression:
state_code = TX and click OK. The display should filter out every patient but those
located in Texas. Click the Filter icon again. Clear the expression and click OK. All
patients are returned to the display. Leave the Patient Details window open.

21. Click FileOpenDoctor List. You can have as many sheet windows opened within
the MDI frame as you want. You now have multiple sheets open though you can see
only one. On the keyboard press CtrlTab to cycle through the two sheets (Doctor
List and Patient Details). Using the menu, click WindowTile Horizontal. You
should now see the two windows split equally on the screen. Again on the menu,
click WindowLayer. You are back in full-screen mode. Also note that the Window
menu item contains a list of open sheets that you can use to navigate between the two
opened windows.

21. Click FileOpenDoctor List. You can have as many sheet windows opened within
the MDI frame as you want. You now have multiple sheets open though you can see
only one. On the keyboard press CtrlTab to cycle through the two sheets (Doctor
List and Patient Details). Using the menu, click WindowTile Horizontal. You
should now see the two windows split equally on the screen. Again on the menu,
click WindowLayer. You are back in full-screen mode. Also note that the Window
menu item contains a list of open sheets that you can use to navigate between the two
opened windows.

22. With one of the sheets open, go to the menu and click ToolsClaim Calculator. Test
this window by using multiple scenarios. Also, notice the Title Bar of this Claim
Calculator window. It is displaying the name of the user that is logged into the
Windows operating system. This is done by coding external function calls, a feature
you will be taught in the course. Close the Claim Calculator window.

22. With one of the sheets open, go to the menu and click ToolsClaim Calculator. Test
this window by using multiple scenarios. Also, notice the Title Bar of this Claim
Calculator window. It is displaying the name of the user that is logged into the
Windows operating system. This is done by coding external function calls, a feature
you will be taught in the course. Close the Claim Calculator window.

23. While you still have a sheet open experiment with the menu item ToolsToolbars
and the window that appears following that command. When satisfied, close the
Toolbars window.

23. While you still have a sheet open experiment with the menu item ToolsToolbars
and the window that appears following that command. When satisfied, close the
Toolbars window.

24. Click WindowClose All. This closes all of the opened sheet windows but leaves
the MDI Frame window open.

24. Click WindowClose All. This closes all of the opened sheet windows but leaves
the MDI Frame window open.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 1 - 7

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 1 - 7

Lab Workbook: Lab 1

Lab 1 - 8

Lab Workbook: Lab 1

25. Click HelpSybHealth Help. While this displays the PowerBuilder help file that is
included with the executables, you will be shown how to write code to display any
Windows help file.

25. Click HelpSybHealth Help. While this displays the PowerBuilder help file that is
included with the executables, you will be shown how to write code to display any
Windows help file.

26. Click HelpAbout. Notice the About window has no means to close it. Wait about
10 seconds and you will see this window closes itself. You will be coding a timer
event with instructions to automatically close this window.

26. Click HelpAbout. Notice the About window has no means to close it. Wait about
10 seconds and you will see this window closes itself. You will be coding a timer
event with instructions to automatically close this window.

27. As you are exploring the SybHealth application, you may notice some menu items or
toolbar icons that are not active. This is by design. Much more functionality will be
added to this same application in the FastTrack to PowerBuilder, Part II course.

27. As you are exploring the SybHealth application, you may notice some menu items or
toolbar icons that are not active. This is by design. Much more functionality will be
added to this same application in the FastTrack to PowerBuilder, Part II course.

28. Click on the Exit icon on the toolbar to stop the SybHealth application. This is what
you will build during the next five days.

28. Click on the Exit icon on the toolbar to stop the SybHealth application. This is what
you will build during the next five days.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 1 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

Module 2: Understanding and Navigating the PowerBuilder IDE

Module 2: Understanding and Navigating the PowerBuilder


IDE

Module 2: Understanding and Navigating the PowerBuilder


IDE

Lab 2-1: Customizing and Configuring the IDE

Lab 2-1: Customizing and Configuring the IDE

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Customize PowerBuilder Toolbars

Customize PowerBuilder Toolbars

Configure Shortcut Keys

Configure Shortcut Keys

Configure System Options

Configure System Options

Description:

In this lab, you will be shown how to configure and customize the PowerBuilder IDE.
You will be adding some custom icons on the PowerBar. You will assign some custom
shortcut keys to quickly enable/disable typical PowerBuilder features. And you will
review some of the System Options and their use.

Description:

In this lab, you will be shown how to configure and customize the PowerBuilder IDE.
You will be adding some custom icons on the PowerBar. You will assign some custom
shortcut keys to quickly enable/disable typical PowerBuilder features. And you will
review some of the System Options and their use.

Task Outline:

Task 1: Customizing PowerBuilder Toolbars

Task Outline:

Task 1: Customizing PowerBuilder Toolbars

2010 Sybase, Inc.

Task 2: Configuring Shortcut Keys

Task 2: Configuring Shortcut Keys

Task 3: Configuring System Options

Task 3: Configuring System Options

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 1

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Detailed Instructions

Detailed Instructions

Task 1: Customizing PowerBuilder Toolbars

Task 1: Customizing PowerBuilder Toolbars

Lab 2 - 2

1.

Start PowerBuilder by using the Windows StartAll


ProgramsSybasePowerBuilder 12.0PowerBuilder Classic 12.0.

1.

Start PowerBuilder by using the Windows StartAll


ProgramsSybasePowerBuilder 12.0PowerBuilder Classic 12.0.

2.

Right-click to the right of the Exit icon on the PowerBar (1st row of toolbar icons is
called the PowerBar) and select the Customize option on the context menu. The
Customize dialog appears.

2.

Right-click to the right of the Exit icon on the PowerBar (1st row of toolbar icons is
called the PowerBar) and select the Customize option on the context menu. The
Customize dialog appears.

3.

The selected palette is the PowerBar. Click an icon in the Selected Palette list view
and you will see the name of that icon display at the bottom of the Customize dialog.

3.

The selected palette is the PowerBar. Click an icon in the Selected Palette list view
and you will see the name of that icon display at the bottom of the Customize dialog.

4.

Drag the icon to Fully build the current target (this icon is only available on
PowerBuilder 11 and greater) down to the Current toolbar view and drop it before the
Go to next error message icon. You may click on the icons in the Current toolbar
view to determine their names.

4.

Drag the icon to Fully build the current target (this icon is only available on
PowerBuilder 11 and greater) down to the Current toolbar view and drop it before the
Go to next error message icon. You may click on the icons in the Current toolbar
view to determine their names.

5.

Click OK to close the Customize dialog. Your PowerBar should look as follows:

5.

Click OK to close the Customize dialog. Your PowerBar should look as follows:

6.

Again, customize the PowerBar.

6.

Again, customize the PowerBar.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

7.

Drag the Fully build icon off of the Current toolbar view. This will remove the
icon from the PowerBar. Where you drag the icon is immaterial. Note: there is a
Reset button on the Customize dialog. Reset would remove all of the PowerBar
customizations. Do not close the Customize dialog.

7.

Drag the Fully build icon off of the Current toolbar view. This will remove the
icon from the PowerBar. Where you drag the icon is immaterial. Note: there is a
Reset button on the Customize dialog. Reset would remove all of the PowerBar
customizations. Do not close the Customize dialog.

8.

Next, in the Select Palette group box, change the radio button from PowerBar to
Custom. This will display a list of custom icons you may add to the PowerBar.

8.

Next, in the Select Palette group box, change the radio button from PowerBar to
Custom. This will display a list of custom icons you may add to the PowerBar.

9.

Click on the icons on the first row of custom icons. Notice how their name shows as
Unassigned custom icon (at the bottom of the Customize dialog).

9.

Click on the icons on the first row of custom icons. Notice how their name shows as
Unassigned custom icon (at the bottom of the Customize dialog).

10. On the first row of custom icons, click the last icon.

10. On the first row of custom icons, click the last icon.

11. Drag that icon down to the Current toolbar, to the left of the To-Do list icon.

11. Drag that icon down to the Current toolbar, to the left of the To-Do list icon.

12. The Toolbar Item Command dialog appears. Specify the following:

12. The Toolbar Item Command dialog appears. Specify the following:

Command line: hh.exe C:\Documents and Settings\All


Users\Documents\Sybase\PowerBuilder 12.0\Help\pbman120.chm
Item Text: HTML Books
Item Microhelp: PowerBuilder 12 HTML Books

Command line: hh.exe C:\Documents and Settings\All


Users\Documents\Sybase\PowerBuilder 12.0\Help\pbman120.chm
Item Text: HTML Books
Item Microhelp: PowerBuilder 12 HTML Books

(The command line may need to be adjusted for older versions of PowerBuilder.)

(The command line may need to be adjusted for older versions of PowerBuilder.)

13. Click OK to close the Customize dialog.

13. Click OK to close the Customize dialog.

14. Your toolbar should look as follows:

14. Your toolbar should look as follows:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 3

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 3

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

15. Test your work. When you click on the HTML Books icon, you should see the
following:

15. Test your work. When you click on the HTML Books icon, you should see the
following:

16. Close the HTML (Books) Help.

16. Close the HTML (Books) Help.

Task 2: Configuring Shortcut Keys

Lab 2 - 4

Task 2: Configuring Shortcut Keys

1.

PowerBuilder provides some default Shortcut keys for the commonly used features of
the IDE. In this task, you will add some custom Shortcut keys.

1.

PowerBuilder provides some default Shortcut keys for the commonly used features of
the IDE. In this task, you will add some custom Shortcut keys.

2.

Make sure that you have no painters open, only PowerBuilder itself.

2.

Make sure that you have no painters open, only PowerBuilder itself.

3.

Selecting ToolsKeyboard Shortcuts from the PowerBuilder menu.

3.

Selecting ToolsKeyboard Shortcuts from the PowerBuilder menu.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE


4.

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

The Keyboard Shortcuts dialog appears. It should look as follows:

Fast Track to PowerBuilder, Part I Version 1.0

4.

Lab 2 - 5

2010 Sybase, Inc.

The Keyboard Shortcuts dialog appears. It should look as follows:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 5

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Lab 2 - 6

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

5.

The Keyboard Shortcuts dialog is context sensitive. The above dialog will look
different later as Painters are opened. The following is an example of what Keyboard
Shortcuts dialog looks like when the Window painter is open:

5.

The Keyboard Shortcuts dialog is context sensitive. The above dialog will look
different later as Painters are opened. The following is an example of what Keyboard
Shortcuts dialog looks like when the Window painter is open:

6.

With the Keyboard Shortcuts dialog open, expand the Tools node.

6.

With the Keyboard Shortcuts dialog open, expand the Tools node.

7.

Note that Library Painter has a default shortcut of Shift + F10.

7.

Note that Library Painter has a default shortcut of Shift + F10.

8.

Add a shortcut for the Browser. Click on Browser Then click to give focus to the
text box under the Press keys for shortcut label.

8.

Add a shortcut for the Browser. Click on Browser Then click to give focus to the
text box under the Press keys for shortcut label.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE


9.

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

Press Ctrl-Shift-B on your keyboard. The text box will populate as follows:

Fast Track to PowerBuilder, Part I Version 1.0

9.

Lab 2 - 7

2010 Sybase, Inc.

Press Ctrl-Shift-B on your keyboard. The text box will populate as follows:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 7

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Lab 2 - 8

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

10. Click OK to close the Keyboard Shortcuts dialog and then test your work. Press
Ctrl+Shift+B and you should see the following:

10. Click OK to close the Keyboard Shortcuts dialog and then test your work. Press
Ctrl+Shift+B and you should see the following:

Remember the Browser. It is one of the most invaluable helpers you have in the
PowerBuilder IDE.

Remember the Browser. It is one of the most invaluable helpers you have in the
PowerBuilder IDE.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

Module 2: Understanding and Navigating the PowerBuilder IDE

11. Remember that Keyboard Shortcuts are context sensitive. Later, as you are in some
painters (like the Window or DataWindow painters), Ctrl+Shift+B is the default
shortcut to the Alternate Bold menu item. You cannot have duplicate Keyboard
Shortcuts. In order to use the Ctrl+Shift+B to access the Browser, you would have to
delete the duplicate Ctrl+Shift+B from the Alternate Bold menu item:

11. Remember that Keyboard Shortcuts are context sensitive. Later, as you are in some
painters (like the Window or DataWindow painters), Ctrl+Shift+B is the default
shortcut to the Alternate Bold menu item. You cannot have duplicate Keyboard
Shortcuts. In order to use the Ctrl+Shift+B to access the Browser, you would have to
delete the duplicate Ctrl+Shift+B from the Alternate Bold menu item:

(You cannot perform the Remove at this time, we have no Windows to open yet. This
step is strictly for information purposes.)

(You cannot perform the Remove at this time, we have no Windows to open yet. This
step is strictly for information purposes.)

12. Next, add the following shortcuts to the associated menu items:

12. Next, add the following shortcuts to the associated menu items:

a. ToolsDatabase Profile Ctrl+Shift+D

a. ToolsDatabase Profile Ctrl+Shift+D

b. WindowSystem Tree Ctrl+Shift+S

b. WindowSystem Tree Ctrl+Shift+S

c. WindowOutput Ctrl+Shift+O

c. WindowOutput Ctrl+Shift+O

d. WindowClip Ctrl+Shift+C

2010 Sybase, Inc.

d. WindowClip Ctrl+Shift+C

13. Close the Keyboard Shortcuts dialog.

13. Close the Keyboard Shortcuts dialog.

14. Test your work.

14. Test your work.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 9

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 9

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Task 3: Configuring System Options

Lab 2 - 10

Task 3: Configuring System Options

1.

Click on ToolsSystem Options on the PowerBuilder menu.

1.

Click on ToolsSystem Options on the PowerBuilder menu.

2.

On the General tab of the System Options dialog, enable Just-In-Time Debugging.
With this option enabled, when you are testing your application via the IDE and you
encounter a fatal error, the PowerBuilder Debugger will automatically open showing
the object/event/line of code where the error occurred. You will be able to view
variables and their values and hopefully have a better idea of what caused the
problem. Without this option, you simply receive an error message and the
application terminates.

2.

On the General tab of the System Options dialog, enable Just-In-Time Debugging.
With this option enabled, when you are testing your application via the IDE and you
encounter a fatal error, the PowerBuilder Debugger will automatically open showing
the object/event/line of code where the error occurred. You will be able to view
variables and their values and hopefully have a better idea of what caused the
problem. Without this option, you simply receive an error message and the
application terminates.

3.

Note that Automatically Clear Output Window is enabled by default so that its
contents are overwritten instead of being appended.

3.

Note that Automatically Clear Output Window is enabled by default so that its
contents are overwritten instead of being appended.

4.

Click the Help button and spend a few minutes learning about some of the other
options seen here.

4.

Click the Help button and spend a few minutes learning about some of the other
options seen here.

5.

Next, click on the Workspaces tab, note the defaults of the following options:

5.

Next, click on the Workspaces tab, note the defaults of the following options:

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 10

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

a. Reopen workspace on startup

a. Reopen workspace on startup

b. Reload painters when opening a workspace

b. Reload painters when opening a workspace

6.

Change the Recent Object list value from the default of 8 to 15.

6.

Change the Recent Object list value from the default of 8 to 15.

7.

Close the System Options dialog.

7.

Close the System Options dialog.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 11

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 11

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Lab 2-2: Experimenting with Workspaces and Targets

Lab 2-2: Experimenting with Workspaces and Targets

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Create your own application workspace

Create your own application workspace

Add and remove existing targets

Add and remove existing targets

Explore Workspace Properties

Explore Workspace Properties

Description:

In this lab, you will create the workspace that will be used for the remainder of the class.
You will add a target to this workspace that has already been created the PowerBuilder
Example Application as well as evaluate what happens when you remove a target. You
will also be exploring Workspace properties.

Description:

In this lab, you will create the workspace that will be used for the remainder of the class.
You will add a target to this workspace that has already been created the PowerBuilder
Example Application as well as evaluate what happens when you remove a target. You
will also be exploring Workspace properties.

Task Outline:

Task 1: Creating a Workspace

Task Outline:

Task 1: Creating a Workspace

Lab 2 - 12

Task 2: Adding Existing Targets

Task 2: Adding Existing Targets

Task 3: Evaluating Workspace Properties

Task 3: Evaluating Workspace Properties

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 12

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

Module 2: Understanding and Navigating the PowerBuilder IDE

Detailed Instructions

Detailed Instructions

Task 1: Creating a Workspace

Task 1: Creating a Workspace

2010 Sybase, Inc.

1.

Right-click (No Workspace) in the System Tree and select New from the context
menu:

1.

Right-click (No Workspace) in the System Tree and select New from the context
menu:

2.

In the New Workspace dialog, navigate to your Student folder (C:\Sybase


Courses\DEV133\Student) and then enter the name MyWorkspace in the File Name
field:

2.

In the New Workspace dialog, navigate to your Student folder (C:\Sybase


Courses\DEV133\Student) and then enter the name MyWorkspace in the File Name
field:

3.

Click Save.

3.

Click Save.

4.

You will see your new workspace in the System Tree.

4.

You will see your new workspace in the System Tree.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 13

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 13

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Task 2: Adding Existing Targets

Task 2: Adding Existing Targets

1.

In the System Tree, right-click over your workspace. Select Add Target from the
context menu.

1.

In the System Tree, right-click over your workspace. Select Add Target from the
context menu.

2.

In the Add Target to Workspace dialog, navigate to the following directory:

2.

In the Add Target to Workspace dialog, navigate to the following directory:

C:\Documents and Settings\All Users\Documents\Sybase\PowerBuilder 12.0\Code


Examples\Example App

C:\Documents and Settings\All Users\Documents\Sybase\PowerBuilder 12.0\Code


Examples\Example App

(Adjust directory above as needed for your version of PowerBuilder.)

(Adjust directory above as needed for your version of PowerBuilder.)

3.

Select the PB Examples.pbt (target) to add it to your workspace. Click Open:

3.

Select the PB Examples.pbt (target) to add it to your workspace. Click Open:

4.

Add another target to your workspace. This time, the target is in the following
directory:

4.

Add another target to your workspace. This time, the target is in the following
directory:

C:\Documents and Settings\All Users\Documents\Sybase\PowerBuilder 12.0\Code


Examples\Advanced GUI
5.

C:\Documents and Settings\All Users\Documents\Sybase\PowerBuilder 12.0\Code


Examples\Advanced GUI

Select the file (target) named advguisample.pbt and click Open.

5.

(The Advanced GUI target is only available in PowerBuilder 11 and greater. If you
are running an older version of PowerBuilder add the Example App\Benchmark target
instead.)

Lab 2 - 14

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Select the file (target) named advguisample.pbt and click Open.


(The Advanced GUI target is only available in PowerBuilder 11 and greater. If you
are running an older version of PowerBuilder add the Example App\Benchmark target
instead.)

Lab 2 - 14

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE


6.

You now have two targets in your workspace. The System Tree should display as
follows:

Task 3: Evaluating Workspace Properties

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE


6.

You now have two targets in your workspace. The System Tree should display as
follows:

Task 3: Evaluating Workspace Properties

1.

In the System Tree, right-click over your workspace.

1.

In the System Tree, right-click over your workspace.

2.

Notice you have Incremental Build, Full Build and Deploy options on the context
menu. When you Build a workspace, you are re-compiling every script in every
object, of every target in the workspace. This could be time consuming. When you
Deploy, you are creating the executables for each of the targets contained in the
workspace.

2.

Notice you have Incremental Build, Full Build and Deploy options on the context
menu. When you Build a workspace, you are re-compiling every script in every
object, of every target in the workspace. This could be time consuming. When you
Deploy, you are creating the executables for each of the targets contained in the
workspace.

3.

Select Properties from the workspace context menu.

3.

Select Properties from the workspace context menu.

4.

The Targets tab of Workspace Properties allows you to control which targets get built
or deployed when you perform that option at the workspace level. Selecting a target
here and using the Up or Down arrows also lets you control the order of your builds
or deploys.

4.

The Targets tab of Workspace Properties allows you to control which targets get built
or deployed when you perform that option at the workspace level. Selecting a target
here and using the Up or Down arrows also lets you control the order of your builds
or deploys.

5.

Move the advguisample target so that it builds/deploys first.

5.

Move the advguisample target so that it builds/deploys first.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 15

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 15

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

6.

Disable the build/deploy of the PB Examples target.

6.

Disable the build/deploy of the PB Examples target.

7.

Projects are created and used to generate executables in the PowerBuilder


environment. Using the Deploy Preview tab, write the name of the project associated
with PB Examples in the space provided below:

7.

Projects are created and used to generate executables in the PowerBuilder


environment. Using the Deploy Preview tab, write the name of the project associated
with PB Examples in the space provided below:

_____________________________________________________________________
8.

_____________________________________________________________________

Click the Source Control tab of the Properties of Workspace dialog. This is where
you come to enable the link between PowerBuilder and your Source Control system.
Write the names of the Source Control systems that are installed on your machine in
the space below:

8.

_____________________________________________________________________
9.

Lab 2 - 16

Click the Source Control tab of the Properties of Workspace dialog. This is where
you come to enable the link between PowerBuilder and your Source Control system.
Write the names of the Source Control systems that are installed on your machine in
the space below:
_____________________________________________________________________

This task has been for information purposes only. The class exercises do not require
use of Source Control. Make sure that the Source Control System option is set to
(None).

9.

This task has been for information purposes only. The class exercises do not require
use of Source Control. Make sure that the Source Control System option is set to
(None).

10. Using your System Tree, right-click over the advguisample target and select Remove
Target from the context menu.

10. Using your System Tree, right-click over the advguisample target and select Remove
Target from the context menu.

11. Removing a target does not delete the target from the machine. It just removes that
target from your workspace.

11. Removing a target does not delete the target from the machine. It just removes that
target from your workspace.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 16

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

Module 2: Understanding and Navigating the PowerBuilder IDE

Lab 2-3: Experimenting with PBLs

Lab 2-3: Experimenting with PBLs

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Add and remove existing PBLs to/from the Library List

Add and remove existing PBLs to/from the Library List

Create new PBLs for the Library List

Create new PBLs for the Library List

Create a no-frills Source Control scheme

Create a no-frills Source Control scheme

Description:

In this lab, you will be experimenting with PBLs and the Library List. PBLs are often
times re-used across multiple applications and/or between multiple developers. You will
add existing PBLs to the PB Examples application, remove PBLs and create new PBLs.
You will alter the order of the Library List evaluating the impact.

Description:

In this lab, you will be experimenting with PBLs and the Library List. PBLs are often
times re-used across multiple applications and/or between multiple developers. You will
add existing PBLs to the PB Examples application, remove PBLs and create new PBLs.
You will alter the order of the Library List evaluating the impact.

Task Outline:

Task 1: Adding / Removing Existing PBLs to/from the Library List

Task Outline:

Task 1: Adding / Removing Existing PBLs to/from the Library List

2010 Sybase, Inc.

Task 2: Creating New PBLs for the Library List

Task 2: Creating New PBLs for the Library List

Task 3: No Frills Source Control

Task 3: No Frills Source Control

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 17

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 17

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Detailed Instructions

Detailed Instructions

Task 1: Adding/Removing Existing PBLs to/from the Library List

Task 1: Adding/Removing Existing PBLs to/from the Library List

Lab 2 - 18

1.

In the PowerBuilder System Tree, expand the PB Examples target you added. Make
note that 12 PBLs make up the application.

1.

In the PowerBuilder System Tree, expand the PB Examples target you added. Make
note that 12 PBLs make up the application.

2.

Right-click over the PB Examples target and select Properties from the context menu.
Select the Library List tab.

2.

Right-click over the PB Examples target and select Properties from the context menu.
Select the Library List tab.

3.

Click on the Browse button to add existing PBLs to the Library List. Navigate to
the following directory:

3.

Click on the Browse button to add existing PBLs to the Library List. Navigate to
the following directory:

C:\Documents and Settings\All Users\Documents\Sybase\PowerBuilder 12.0\Code


Examples\Benchmark

C:\Documents and Settings\All Users\Documents\Sybase\PowerBuilder 12.0\Code


Examples\Benchmark

(Adjust the directory above for your version of PowerBuilder.)

(Adjust the directory above for your version of PowerBuilder.)

Select the pbexbm.pbl and click Open on the Select Library dialog.

Select the pbexbm.pbl and click Open on the Select Library dialog.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 18

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE


4.

You will see a new line has been added to the bottom of the library list:

4.

You will see a new line has been added to the bottom of the library list:

5.

Click OK to close the Target properties dialog.

5.

Click OK to close the Target properties dialog.

6.

In the System Tree, expand the PB Examples target and you will see the pbexbm.pbl
and can expand it to see its contents. Adding this PBL gave the target access to
several new objects.

6.

In the System Tree, expand the PB Examples target and you will see the pbexbm.pbl
and can expand it to see its contents. Adding this PBL gave the target access to
several new objects.

7.

Using the System Tree, right-click over the pbexbm.pbl and select Remove Library.
When prompted, click Yes. The System Tree will update to reflect that change.

7.

Using the System Tree, right-click over the pbexbm.pbl and select Remove Library.
When prompted, click Yes. The System Tree will update to reflect that change.

8.

Remove Library does not delete a PBL; it just removes it from a target.

8.

Remove Library does not delete a PBL; it just removes it from a target.

Task 2: Creating New PBLs for the Library List

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

Task 2: Creating New PBLs for the Library List

1.

In the System Tree, right-click the PB Examples target and select Properties from
the context menu.

1.

In the System Tree, right-click the PB Examples target and select Properties from
the context menu.

2.

On the Library List tab, click the New button.

2.

On the Library List tab, click the New button.

3.

Navigate to your Student folder (C:\Sybase Courses\DEV134\Student) and create a


new PBL named checkout (you do not need to add the .pbl extension). Click Save.

3.

Navigate to your Student folder (C:\Sybase Courses\DEV134\Student) and create a


new PBL named checkout (you do not need to add the .pbl extension). Click Save.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 19

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 19

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

4.

When prompted for comments, enter No Frills Source Control Checkout PBL.
Click OK.

4.

When prompted for comments, enter No Frills Source Control Checkout PBL.
Click OK.

5.

The Library List now shows your new checkout PBL at the bottom. Cut and paste,
moving that line to the top of the library list as shown below:

5.

The Library List now shows your new checkout PBL at the bottom. Cut and paste,
moving that line to the top of the library list as shown below:

6.

Click OK to close the targets properties.

6.

Click OK to close the targets properties.

7.

The System Tree now displays the checkout.pbl. This PBL is empty at this point.

7.

The System Tree now displays the checkout.pbl. This PBL is empty at this point.

Task 3: No Frills Source Control

Lab 2 - 20

Task 3: No Frills Source Control

1.

Right-click over the PB Examples Target in the System Tree and select Run.

1.

Right-click over the PB Examples Target in the System Tree and select Run.

2.

PB Examples main window displays categories of all of the examples. You can
expand a category to see a list of the example applications available.

2.

PB Examples main window displays categories of all of the examples. You can
expand a category to see a list of the example applications available.

3.

Under the Drag & Drop category, you will see three example applications. Double
click the Treeview Drag/Drop example.

3.

Under the Drag & Drop category, you will see three example applications. Double
click the Treeview Drag/Drop example.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 20

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

4.

You will see an example that looks like the following:

4.

You will see an example that looks like the following:

5.

Close the Employee Transfer window.

5.

Close the Employee Transfer window.

6.

In the PB Examples interface, click the Related Objects tab (upper right).

6.

In the PB Examples interface, click the Related Objects tab (upper right).

7.

The example you just ran contains a window named w_employee_xfer and a
DataWindow named d_emp_by_dept.

7.

The example you just ran contains a window named w_employee_xfer and a
DataWindow named d_emp_by_dept.

8.

Close the PB Examples interface by clicking FileExit.

8.

Close the PB Examples interface by clicking FileExit.

9.

All of the example windows are in the PBLs named pbexamw1, 2 and 3. In the
System Tree, expand the PBL named pbexamw2.

9.

All of the example windows are in the PBLs named pbexamw1, 2 and 3. In the
System Tree, expand the PBL named pbexamw2.

10. Right-click over w_employee_xfer and select Copy from the context menu.

10. Right-click over w_employee_xfer and select Copy from the context menu.

11. On the Select Library dialog, navigate to your Student folder and select the
checkout.pbl. Click Open. You now have two exact copies of the same object.

11. On the Select Library dialog, navigate to your Student folder and select the
checkout.pbl. Click Open. You now have two exact copies of the same object.

12. In the System Tree, go up to the checkout.pbl and expand it. Double-click to open
w_employee_xfer in PowerBuilders Window painter.

12. In the System Tree, go up to the checkout.pbl and expand it. Double-click to open
w_employee_xfer in PowerBuilders Window painter.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 21

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 21

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Lab 2 - 22

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

13. In the Properties view of the Window painter (far right), scroll down until you see the
BackColor property. Change the value from Button Face to Active Title Bar (blue).
You will see the background of the layout change:

13. In the Properties view of the Window painter (far right), scroll down until you see the
BackColor property. Change the value from Button Face to Active Title Bar (blue).
You will see the background of the layout change:

14. Close the Window painter. Always close painters by clicking the X icon that is on the
PainterBar (the PainterBar is the 2nd row of toolbar icons).

14. Close the Window painter. Always close painters by clicking the X icon that is on the
PainterBar (the PainterBar is the 2nd row of toolbar icons).

15. Closing will prompt you to save. Click Yes.

15. Closing will prompt you to save. Click Yes.

16. Now, re-run the PB Examples application, and the Treeview Drag/Drop example as
we did above in step 3. You should see the change in the background color of the
window.

16. Now, re-run the PB Examples application, and the Treeview Drag/Drop example as
we did above in step 3. You should see the change in the background color of the
window.

17. The point of this exercise was to show you how you could check out an object (copy)
to your checkout PBL, make changes and test while the object is in the checkout PBL.
Since Checkout is at the top of the Library List, that version of the window is found
first when you run the application. The original object is preserved until you have
tested your changes and move the changed window back to its original PBL.

17. The point of this exercise was to show you how you could check out an object (copy)
to your checkout PBL, make changes and test while the object is in the checkout PBL.
Since Checkout is at the top of the Library List, that version of the window is found
first when you run the application. The original object is preserved until you have
tested your changes and move the changed window back to its original PBL.

18. When you are happy with the results, move the object from the checkout PBL back to
the original PBL (pbexamw2.pbl). The goal should be to ultimately clear out your
checkout PBL when you are ready to create executables for the end users.

18. When you are happy with the results, move the object from the checkout PBL back to
the original PBL (pbexamw2.pbl). The goal should be to ultimately clear out your
checkout PBL when you are ready to create executables for the end users.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 22

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

Module 2: Understanding and Navigating the PowerBuilder IDE

Lab 2-4: Creating the SybHealth Application

Lab 2-4: Creating the SybHealth Application

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Create the SybHealth application target that will be used during the remainder of the
labs

Create the SybHealth application target that will be used during the remainder of the
labs

Add provided framework PBLS to the target

Add provided framework PBLS to the target

Description:

In this lab, you will be creating the SybHealth application target that will be used in the
remainder of the labs. You will add some provided PBLs to the Library List. These PBLs
contain framework objects that you will use when building SybHealth. We do this to show
you best practices within PowerBuilder. Do not worry about the contents of these PBLs
right now. That will be explained to you later. You will be given detailed instructions
about the use of this framework in a later module.

Description:

In this lab, you will be creating the SybHealth application target that will be used in the
remainder of the labs. You will add some provided PBLs to the Library List. These PBLs
contain framework objects that you will use when building SybHealth. We do this to show
you best practices within PowerBuilder. Do not worry about the contents of these PBLs
right now. That will be explained to you later. You will be given detailed instructions
about the use of this framework in a later module.

Task Outline:

Task 1: Creating the SybHealth Target

Task Outline:

Task 1: Creating the SybHealth Target

Task 2: Adding Framework PBLs to SybHealth

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Adding Framework PBLs to SybHealth

Lab 2 - 23

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 23

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Detailed Instructions

Detailed Instructions

Task 1: Creating the SybHealth Target

Task 1: Creating the SybHealth Target

Lab 2 - 24

1.

In the System Tree, right-click MyWorkspace and select New from the context
menu.

1.

In the System Tree, right-click MyWorkspace and select New from the context
menu.

2.

On the Target tab of the New dialog, select Application and click OK.

2.

On the Target tab of the New dialog, select Application and click OK.

3.

Enter application details exactly as shown below:

3.

Enter application details exactly as shown below:

4.

Click Finish.

4.

Click Finish.

5.

Right-click over SybHealth_target in the System Tree. Select Properties from the
context menu.

5.

Right-click over SybHealth_target in the System Tree. Select Properties from the
context menu.

6.

Clicking the New button, create three new PBLs for the Library List:

6.

Clicking the New button, create three new PBLs for the Library List:

a. C:\Sybase Courses\DEV134\Student\Patients.pbl

a. C:\Sybase Courses\DEV134\Student\Patients.pbl

b. C:\Sybase Courses\DEV134\Student\Doctors.pbl

b. C:\Sybase Courses\DEV134\Student\Doctors.pbl

c. C:\Sybase Courses\DEV134\Student\Claims.pbl

c. C:\Sybase Courses\DEV134\Student\Claims.pbl

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 24

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

Task 2: Adding Framework PBLs to SybHealth

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

Task 2: Adding Framework PBLs to SybHealth

1.

A framework is constantly evolving. To get you started, we have provided a miniframework that you will add to SybHealth. During labs, you will be using and/or
inheriting from objects in this framework. You will also be identifying changes
needed (properties and code) to framework objects. Dont try to understand it all
right now, you will by the end of the course.

1.

A framework is constantly evolving. To get you started, we have provided a miniframework that you will add to SybHealth. During labs, you will be using and/or
inheriting from objects in this framework. You will also be identifying changes
needed (properties and code) to framework objects. Dont try to understand it all
right now, you will by the end of the course.

2.

Add the following PBLs to the sybhealth_target Library List:

2.

Add the following PBLs to the sybhealth_target Library List:

a. C:\Sybase Courses\DEV134\Student\Framework\windows_base.pbl

a. C:\Sybase Courses\DEV134\Student\Framework\windows_base.pbl

b. C:\Sybase Courses\DEV134\Student\Framework\windows_abstract.pbl

b. C:\Sybase Courses\DEV134\Student\Framework\windows_abstract.pbl

c. C:\Sybase Courses\DEV134\Student\Framework\visual_controls_base.pbl

c. C:\Sybase Courses\DEV134\Student\Framework\visual_controls_base.pbl

d. C:\Sybase Courses\DEV134\Student\Framework\visual_controls_abstract.pbl

d. C:\Sybase Courses\DEV134\Student\Framework\visual_controls_abstract.pbl

3.

This will provide a starting point for our application. Other PBLs will be added later.

3.

This will provide a starting point for our application. Other PBLs will be added later.

4.

Your System Tree should now look as follows:

4.

Your System Tree should now look as follows:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 25

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 25

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Lab 2 - 26

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

5.

In the System Tree, expand your sybhealth PBL and double-click the a_sybhealth
Application Object to open the Application painter.

5.

In the System Tree, expand your sybhealth PBL and double-click the a_sybhealth
Application Object to open the Application painter.

6.

On the Properties view and enter SybHealth Patient Management System in the
DisplayName property.

6.

On the Properties view and enter SybHealth Patient Management System in the
DisplayName property.

7.

Enter Error Accessing Data in the DWMessageTitle property. This property will be
used in the title bar of default DataWindow error messages for your application:

7.

Enter Error Accessing Data in the DWMessageTitle property. This property will be
used in the title bar of default DataWindow error messages for your application:

8.

On the properties view, click the Additional Properties button.

8.

On the properties view, click the Additional Properties button.

9.

On the Icon tab, click the Browse button and select VOC.ICO from the Student
folder. This icon will be used as your application icon. The icon image will display
below the Browse button.

9.

On the Icon tab, click the Browse button and select VOC.ICO from the Student
folder. This icon will be used as your application icon. The icon image will display
below the Browse button.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 26

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

10. Remove the path name from the Icon Name field, leaving only the file name.

10. Remove the path name from the Icon Name field, leaving only the file name.

11. On the other tab pages, make sure the default Text, Column, Header, and Label fonts
are set to Tahoma 10 point.

11. On the other tab pages, make sure the default Text, Column, Header, and Label fonts
are set to Tahoma 10 point.

12. Click OK to close the Application dialog and then click the Save button (Ctrl-S) to
store your changes in the PBL. You will do more with the Application Object in later
labs.

12. Click OK to close the Application dialog and then click the Save button (Ctrl-S) to
store your changes in the PBL. You will do more with the Application Object in later
labs.

13. Close the Application Painter. Again, remember to close painters by clicking the X
icon on the PainterBar.

13. Close the Application Painter. Again, remember to close painters by clicking the X
icon on the PainterBar.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 27

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 27

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Lab 2-5: Using Utility Tools

Lab 2-5: Using Utility Tools

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Use PowerBuilders built-in File Editor

Use PowerBuilders built-in File Editor

Use the Library Painter

Use the Library Painter

Use the Database Profile Painter

Use the Database Profile Painter

Use the Database Painter to view the SybHealth Schema

Use the Database Painter to view the SybHealth Schema

Description:

In this lab, you will be introduced to some of PowerBuilders utility painters/tools. We


will be using the File Editor and reviewing an INI file; the Library Painter and how it
augments functionality available in the System Tree; the Database Profile Painter to create
profiles and connect and disconnect from databases; and the Database Painter to learn
about the SybHealth database schema.

Description:

In this lab, you will be introduced to some of PowerBuilders utility painters/tools. We


will be using the File Editor and reviewing an INI file; the Library Painter and how it
augments functionality available in the System Tree; the Database Profile Painter to create
profiles and connect and disconnect from databases; and the Database Painter to learn
about the SybHealth database schema.

Task Outline:

Task 1: Using the File Editor

Task Outline:

Task 1: Using the File Editor

Lab 2 - 28

Task 2: Using the Library Painter

Task 2: Using the Library Painter

Task 3: Using the Database Profile Painter

Task 3: Using the Database Profile Painter

Task 4: Using the Database Painter to view a Schema

Task 4: Using the Database Painter to view a Schema

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 28

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

Module 2: Understanding and Navigating the PowerBuilder IDE

Detailed Instructions

Detailed Instructions

Task 1: Using the File Editor

Task 1: Using the File Editor

1.

Click ToolsFile Editor on the PowerBuilder menu.

1.

Click ToolsFile Editor on the PowerBuilder menu.

2.

You cannot use FileOpen to edit a file within the editor. FileOpen opens
PowerBuilder objects. Instead, use FileOpen File (or click the Open icon on the
PainterBar).

2.

You cannot use FileOpen to edit a file within the editor. FileOpen opens
PowerBuilder objects. Instead, use FileOpen File (or click the Open icon on the
PainterBar).

3.

Look at the Files of Type drop down, to learn which types of files the File Editor is
capable of displaying.

3.

Look at the Files of Type drop down, to learn which types of files the File Editor is
capable of displaying.

4.

Set the Files of Type to Initialization files (INI). Navigate to your Student folder.
Select the SybHealth.ini file.

4.

Set the Files of Type to Initialization files (INI). Navigate to your Student folder.
Select the SybHealth.ini file.

5.

INI files are ASCII text files that contain key-value pairs of information. These keys
can be read by the application at any time, though typically at application startup,
hence the name Application Initialization file. Anyone may create an INI file with a
utility like PowerBuilders File Editor, or Windows Notepad.

5.

INI files are ASCII text files that contain key-value pairs of information. These keys
can be read by the application at any time, though typically at application startup,
hence the name Application Initialization file. Anyone may create an INI file with a
utility like PowerBuilders File Editor, or Windows Notepad.

6.

An INI file can have one to many sections. SybHealth.ini has only one section. Write
the section name below:

6.

An INI file can have one to many sections. SybHealth.ini has only one section. Write
the section name below:

_____________________________________________________________________
7.

2010 Sybase, Inc.

_____________________________________________________________________

Each section can have one to many key-value pairs. Write the key names below
(dont worry about noting the values, you will write code to obtain the values later):

7.

Each section can have one to many key-value pairs. Write the key names below
(dont worry about noting the values, you will write code to obtain the values later):

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

8.

While in the File Editor, note the icons on the PainterBar. The File Editor has Find,
Find and Replace, and Save icons.

8.

While in the File Editor, note the icons on the PainterBar. The File Editor has Find,
Find and Replace, and Save icons.

9.

Close the File Editor.

9.

Close the File Editor.

10. Re-open the File Editor (there is no option to start a new document while in the File
Editor).

10. Re-open the File Editor (there is no option to start a new document while in the File
Editor).

11. You are now going to create a PowerBuilder Resource file (or PBR). This file will be
used when you create executables. Resource files are text files that are your
responsibility to create. A PBR file contains lines that identify each of the resources
used during development. Resources include ICONS (in lab 2-4 we used the voc.ico
file), PICTURES (JPGs, Bitmaps, GIFs, etc.) and CURSORS, etc.

11. You are now going to create a PowerBuilder Resource file (or PBR). This file will be
used when you create executables. Resource files are text files that are your
responsibility to create. A PBR file contains lines that identify each of the resources
used during development. Resources include ICONS (in lab 2-4 we used the voc.ico
file), PICTURES (JPGs, Bitmaps, GIFs, etc.) and CURSORS, etc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 29

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 29

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

12. Whenever you use a resource, such as a GIF in a Picture control, you should add the
location and filename to your PBR file.

12. Whenever you use a resource, such as a GIF in a Picture control, you should add the
location and filename to your PBR file.

13. In the File Editor, place your first reference as follows:

13. In the File Editor, place your first reference as follows:

14. Click FileSave As

14. Click FileSave As

15. On the Save dialog, navigate to your Student directory, change the Save As Type drop
down to Resource Files, and name the file SybHealth. The PBR extension will
automatically be appended.

15. On the Save dialog, navigate to your Student directory, change the Save As Type drop
down to Resource Files, and name the file SybHealth. The PBR extension will
automatically be appended.

16. Close the File Editor.

16. Close the File Editor.

Task 2: Using the Library Painter

Lab 2 - 30

Task 2: Using the Library Painter

1.

Click ToolsLibrary Painter on the menu (or click the Library icon on the
PowerBar).

1.

Click ToolsLibrary Painter on the menu (or click the Library icon on the
PowerBar).

2.

The default Library Painter looks like Windows Explorer. It has very similar
functionality. However, the true use of the Library Painter, is to provide a utility to
manage your PowerBuilder libraries (PBLs).

2.

The default Library Painter looks like Windows Explorer. It has very similar
functionality. However, the true use of the Library Painter, is to provide a utility to
manage your PowerBuilder libraries (PBLs).

3.

The default Library Painter has two views, a tree (left) and a list (right). In the Tree
view, right-click in a null area. You will see the context menu:

3.

The default Library Painter has two views, a tree (left) and a list (right). In the Tree
view, right-click in a null area. You will see the context menu:

4.

Select Set Root and when prompted, select Current Workspace and click OK.

4.

Select Set Root and when prompted, select Current Workspace and click OK.

5.

The Tree view of the Library Painter should now mirror that of the System Tree.

5.

The Tree view of the Library Painter should now mirror that of the System Tree.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 30

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

Module 2: Understanding and Navigating the PowerBuilder IDE

6.

The Library Painter has been part of PowerBuilder for a long time. The System Tree
was new in PowerBuilder 8. Because it is typically in the foreground, developers tend
to use the System Tree more than the Library Painter; however, there are some good
reasons to use the Library Painter.

6.

The Library Painter has been part of PowerBuilder for a long time. The System Tree
was new in PowerBuilder 8. Because it is typically in the foreground, developers tend
to use the System Tree more than the Library Painter; however, there are some good
reasons to use the Library Painter.

7.

When in the Library Painter, remember is to use the Tree view as a navigator and the
List view when performing operations on the contents of PBLs. The Tree view does
not support multi-selecting objects. The List view does. The List view also provides
additional valuable information.

7.

When in the Library Painter, remember is to use the Tree view as a navigator and the
List view when performing operations on the contents of PBLs. The Tree view does
not support multi-selecting objects. The List view does. The List view also provides
additional valuable information.

8.

Using the Tree view of the Library Painter, expand the SybHealth_target and then
click (single-click), on the visual_controls_base.pbl. The contents of that PBL will
display in the List view as seen below:

8.

Using the Tree view of the Library Painter, expand the SybHealth_target and then
click (single-click), on the visual_controls_base.pbl. The contents of that PBL will
display in the List view as seen below:

9.

What valuable pieces of information does the List view contain beside the object
name?

9.

What valuable pieces of information does the List view contain beside the object
name?

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

10. On the menu, click EntryLibraryCreate or click the Create Library icon on the
PainterBar.

10. On the menu, click EntryLibraryCreate or click the Create Library icon on the
PainterBar.

11. When prompted, create a new PBL named Trash in your Student folder. No
comments need to be added. Click Save.

11. When prompted, create a new PBL named Trash in your Student folder. No
comments need to be added. Click Save.

12. Did the System Tree or Library Painter display your new PBL? Are PBLs created in
the Library Painter added to the Library List?

12. Did the System Tree or Library Painter display your new PBL? Are PBLs created in
the Library Painter added to the Library List?

_____________________________________________________________________

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 31

_____________________________________________________________________

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 31

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Lab 2 - 32

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

13. Use the Tree view of the Library Painter to navigate to the sybhealth_target. Expand
and click on the visual_controls_base.pbl, displaying its contents in the List view.

13. Use the Tree view of the Library Painter to navigate to the sybhealth_target. Expand
and click on the visual_controls_base.pbl, displaying its contents in the List view.

14. In the Library Painters List view, hold down the Ctrl key click to select the first 5
objects in that PBL. You could also perform a lasso select with the mouse.

14. In the Library Painters List view, hold down the Ctrl key click to select the first 5
objects in that PBL. You could also perform a lasso select with the mouse.

15. With your mouse over one of the selected objects, right-click and select Move from
the context menu. Move these objects to your new trash.pbl in your Student folder.
Click Open to complete the move. The point of the exercise is to never outright
delete objects. It is safer to move them to a temporary holding place, similar to the
Windows Recycle Bin.

15. With your mouse over one of the selected objects, right-click and select Move from
the context menu. Move these objects to your new trash.pbl in your Student folder.
Click Open to complete the move. The point of the exercise is to never outright
delete objects. It is safer to move them to a temporary holding place, similar to the
Windows Recycle Bin.

16. Now move those objects back into the visual_controls_base.pbl. There are many
ways to do this. One includes right-clicking over the Tree view of the Library Painter
and selecting Set Root

16. Now move those objects back into the visual_controls_base.pbl. There are many
ways to do this. One includes right-clicking over the Tree view of the Library Painter
and selecting Set Root

17. Select Directory under Set Root to. Browse to and select your Student folder. The
Tree view of the Library Painter will now show all PBLs in the directory you
specified. Click on the trash.pbl in the Tree view, select all of the objects, right-click
and Move back to the visual_controls_base.pbl that is in the \Student\Framework
folder.

17. Select Directory under Set Root to. Browse to and select your Student folder. The
Tree view of the Library Painter will now show all PBLs in the directory you
specified. Click on the trash.pbl in the Tree view, select all of the objects, right-click
and Move back to the visual_controls_base.pbl that is in the \Student\Framework
folder.

18. The Library Painter can also be used to compare contents of two PBLs. To do this,
you need to add a second List view to the painter. This is done by clicking
ViewList on the PowerBuilder menu bar.

18. The Library Painter can also be used to compare contents of two PBLs. To do this,
you need to add a second List view to the painter. This is done by clicking
ViewList on the PowerBuilder menu bar.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 32

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

19. The new List view will appear horizontally across the bottom of the Library Painter.
By dragging and dropping a view, rearrange the painter so that it looks like the
following:

19. The new List view will appear horizontally across the bottom of the Library Painter.
By dragging and dropping a view, rearrange the painter so that it looks like the
following:

20. Once you have two list views, you can drag a PBL from the Tree view to any List
view creating a tool that allows you to compare PBL contents.

20. Once you have two list views, you can drag a PBL from the Tree view to any List
view creating a tool that allows you to compare PBL contents.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 33

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 33

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Task 3: Using the Database Profile Painter

Lab 2 - 34

Task 3: Using the Database Profile Painter

1.

The Database Profile painter is where you set up profiles that allow the IDE to have a
design-time connection to your database. Design-time connections are needed if you
create DataWindow objects, Query objects, put embedded SQL into events or
functions, etc.

1.

The Database Profile painter is where you set up profiles that allow the IDE to have a
design-time connection to your database. Design-time connections are needed if you
create DataWindow objects, Query objects, put embedded SQL into events or
functions, etc.

2.

Click on ToolsDatabase Profile or click the DB Profile icon on the PowerBar.


You also set up a keyboard shortcut which was Ctrl-Shift-D.

2.

Click on ToolsDatabase Profile or click the DB Profile icon on the PowerBar.


You also set up a keyboard shortcut which was Ctrl-Shift-D.

3.

The DB Profile painter has a tree view showing installed database interfaces. You
must know which DBMS and how you plan to connect in order to choose the correct
interface. For instance, a developer connecting to Microsoft SQL Server 2005 could
choose from several interfaces: SNC, ADO.NET, OLE-DB or ODBC. The choice of
interface is a decision you have to make.

3.

The DB Profile painter has a tree view showing installed database interfaces. You
must know which DBMS and how you plan to connect in order to choose the correct
interface. For instance, a developer connecting to Microsoft SQL Server 2005 could
choose from several interfaces: SNC, ADO.NET, OLE-DB or ODBC. The choice of
interface is a decision you have to make.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 34

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

4.

PowerBuilder ships with a developer edition of Sybase SQL Anywhere 11, our
Mobile and Embedded database. In addition, PowerBuilder ships with a sample
database named EAS Demo DB V120. This database contains tables with customers,
products, employees, orders, etc. PowerBuilder installs a DB Profile for the EAS
Demo DB V120 automatically:

4.

PowerBuilder ships with a developer edition of Sybase SQL Anywhere 11, our
Mobile and Embedded database. In addition, PowerBuilder ships with a sample
database named EAS Demo DB V120. This database contains tables with customers,
products, employees, orders, etc. PowerBuilder installs a DB Profile for the EAS
Demo DB V120 automatically:

5.

Expand the ODBC node and you will see the EAS Demo DB V120 profile. Rightclick over that profile and select Connect from the context menu. If you receive no
errors, then you are successfully connected.

5.

Expand the ODBC node and you will see the EAS Demo DB V120 profile. Rightclick over that profile and select Connect from the context menu. If you receive no
errors, then you are successfully connected.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 35

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 35

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

6.

Re-open the DB Profile painter and look under the ODBC node again. Your painter
should look like the following:

6.

Re-open the DB Profile painter and look under the ODBC node again. Your painter
should look like the following:

7.

Notice the small green checkmark to the left of the EAS Demo DB V120 profile.
That mark indicates you are connected.

7.

Notice the small green checkmark to the left of the EAS Demo DB V120 profile.
That mark indicates you are connected.

8.

Next, right-click over the EAS Demo DB V120 Unicode profile and select Connect

8.

Next, right-click over the EAS Demo DB V120 Unicode profile and select Connect

9.

Re-open DB Profile.

9.

Re-open DB Profile.

10. Is it possible, at design time (in the IDE), to have concurrent active connections to
more than one database?

Lab 2 - 36

10. Is it possible, at design time (in the IDE), to have concurrent active connections to
more than one database?

_____________________________________________________________________

_____________________________________________________________________

11. Right-click over EAS Demo DB V120 again. Select Set As Active Connection. Note
how the green check mark is switching with the active connection.

11. Right-click over EAS Demo DB V120 again. Select Set As Active Connection. Note
how the green check mark is switching with the active connection.

12. Disconnect from any active database.

12. Disconnect from any active database.

13. Next, we will set up a DB Profile for the SybHealth database. Remember, that in
Module 1s lab, we created an ODBC DSN to the SybHealth database so that we
could run the final solution. That is the first step toward creating an ODBC profile.

13. Next, we will set up a DB Profile for the SybHealth database. Remember, that in
Module 1s lab, we created an ODBC DSN to the SybHealth database so that we
could run the final solution. That is the first step toward creating an ODBC profile.

14. In the DB Profile painter select the ODBC node. This enables the New button.
Click New to create a DB Profile.

14. In the DB Profile painter select the ODBC node. This enables the New button.
Click New to create a DB Profile.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 36

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

15. Set the Profile Name to SybHealth. Select the SybHealth Data Source (this is the
DSN we created in Lab 1) using the drop down.

15. Set the Profile Name to SybHealth. Select the SybHealth Data Source (this is the
DSN we created in Lab 1) using the drop down.

16. Click OK.

16. Click OK.

17. Connect using the SybHealth profile.

17. Connect using the SybHealth profile.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 37

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 37

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Task 4: Using the Database Painter to View a Schema

Task 4: Using the Database Painter to View a Schema

1.

Learning about the database schema is an important task to any developer. You will
now learn how to use the Database Painter to better understand the SybHealth
schema.

1.

Learning about the database schema is an important task to any developer. You will
now learn how to use the Database Painter to better understand the SybHealth
schema.

2.

Click on ToolsDatabase Painter or the Database icon on the PowerBar. The


Database Painter is shown below:

2.

Click on ToolsDatabase Painter or the Database icon on the PowerBar. The


Database Painter is shown below:

3.

The Tree view on the left looks like the DB Profile painter. However, it adds more
detail.

3.

The Tree view on the left looks like the DB Profile painter. However, it adds more
detail.

4.

Drill down into the SybHealth profile and then expand the Tables folder. You will
see all of the SybHealth table names listed.

4.

Drill down into the SybHealth profile and then expand the Tables folder. You will
see all of the SybHealth table names listed.

5.

Drill down into any table and you will be able to learn column names by expanding
the Columns folder.

5.

Drill down into any table and you will be able to learn column names by expanding
the Columns folder.

6.

Expand the claims table, and then expand the Columns folder. Double click the
amount_paid column. This will display the columns properties in the upper right
view.

6.

Expand the claims table, and then expand the Columns folder. Double click the
amount_paid column. This will display the columns properties in the upper right
view.

7.

What is the database data type for amount_paid?

7.

What is the database data type for amount_paid?

_____________________________________________________________________
8.

Lab 2 - 38

_____________________________________________________________________

In addition to using the Tree view, you can graphically depict tables and their
relationships in the Object Layout view (tab -- upper, center of the painter).
Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

8.

Lab 2 - 38

In addition to using the Tree view, you can graphically depict tables and their
relationships in the Object Layout view (tab -- upper, center of the painter).
Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE


9.

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

When the Object Layout is active, you can drag a table from the Tree view to the
Object Layout view. Drag the claims table there. In a null area of the Object Layout
view, right-click and enable the showing of data types. Your display should look as
follows:

9.

When the Object Layout is active, you can drag a table from the Tree view to the
Object Layout view. Drag the claims table there. In a null area of the Object Layout
view, right-click and enable the showing of data types. Your display should look as
follows:

10. The gold key indicates that claim_id is a primary key.

10. The gold key indicates that claim_id is a primary key.

11. The blue keys indicate columns that are foreign keys.

11. The blue keys indicate columns that are foreign keys.

12. Right-click over the blue key associated with the claim_code column. Select Open
Referenced Table on the context menu. Your object layout will look as follows:

12. Right-click over the blue key associated with the claim_code column. Select Open
Referenced Table on the context menu. Your object layout will look as follows:

13. You can view the entire schema graphically, where we show keys, indexes, and
column types. There is a print icon, but the printed version is text only, no graphics.

13. You can view the entire schema graphically, where we show keys, indexes, and
column types. There is a print icon, but the printed version is text only, no graphics.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 39

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 39

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Lab 2 - 40

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

14. You have learned that the Database Painter is an information utility that will help the
developer perform his job in writing PowerBuilder applications.

14. You have learned that the Database Painter is an information utility that will help the
developer perform his job in writing PowerBuilder applications.

15. If you had the appropriate database rights, you could alter tables, create tables, and
perform other DBA-type activities, here in PowerBuilders Database Painter. You
will learn more about the Database Painter in later modules.

15. If you had the appropriate database rights, you could alter tables, create tables, and
perform other DBA-type activities, here in PowerBuilders Database Painter. You
will learn more about the Database Painter in later modules.

16. Close the Database Painter.

16. Close the Database Painter.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 40

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

Module 2: Understanding and Navigating the PowerBuilder IDE

Lab 2-6: Painter Configuration

Lab 2-6: Painter Configuration

Objectives:

Objectives:

After completing this lab, you should be able to:

Description:

In this lab, you will be configuring the Window and DataWindow painter views so that
they allow you to be more productive during different phases of development by gaining
more screen real-estate in which to work.

Procedure

2010 Sybase, Inc.

After completing this lab, you should be able to:

Configure various painters to display their views differently


Description:

Configure various painters to display their views differently

In this lab, you will be configuring the Window and DataWindow painter views so that
they allow you to be more productive during different phases of development by gaining
more screen real-estate in which to work.

Procedure
1.

This task will use one of the windows from the PB Examples application to configure
the Window painter.

1.

This task will use one of the windows from the PB Examples application to configure
the Window painter.

2.

From the System Tree, expand the PB Examples target, then the pbexamfe.pbl.

2.

From the System Tree, expand the PB Examples target, then the pbexamfe.pbl.

3.

Double-click to open w_about.

3.

Double-click to open w_about.

4.

Using the Xs on each of the views, close all views, but do not close the Window
painter:

4.

Using the Xs on each of the views, close all views, but do not close the Window
painter:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 41

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 41

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE


5.

Lab 2 - 42

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

You will still see the Window painters title bar but no views:

5.

You will still see the Window painters title bar but no views:

6.

Click on ViewLayout on the menu bar.

6.

Click on ViewLayout on the menu bar.

7.

This is how your painter should look:

7.

This is how your painter should look:

8.

Click ViewLayoutsManage on the menu bar.

8.

Click ViewLayoutsManage on the menu bar.

9.

On the Layout dialog, click the New Layout icon.

9.

On the Layout dialog, click the New Layout icon.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 42

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

10. When prompted, name the new layout Window Layout Only:

10. When prompted, name the new layout Window Layout Only:

11. Click ViewLayoutsDefault to return the Window painter to the way it was
configured originally. Remember this option.

11. Click ViewLayoutsDefault to return the Window painter to the way it was
configured originally. Remember this option.

12. Configure the Window painter to contain only the Layout and Script Editor view.
Remember, after you add views, you can drag the views around anywhere within the
painter. You can also resize views. The point is to make the painters work for you.
Save your layout as Window Layout and Script. You can create many views for a
given painter. Your Window Painter should look like the following:

12. Configure the Window painter to contain only the Layout and Script Editor view.
Remember, after you add views, you can drag the views around anywhere within the
painter. You can also resize views. The point is to make the painters work for you.
Save your layout as Window Layout and Script. You can create many views for a
given painter. Your Window Painter should look like the following:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 43

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 43

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Lab 2 - 44

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

13. Reset the Window Painter to the default views (ViewLayoutsDefault) and close
the Window painter.

13. Reset the Window Painter to the default views (ViewLayoutsDefault) and close
the Window painter.

14. This process can be performed for any painter in PowerBuilder, not just the Window
Painter.

14. This process can be performed for any painter in PowerBuilder, not just the Window
Painter.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 44

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

Module 2: Understanding and Navigating the PowerBuilder IDE

Lab 2-7: Opening and Searching

Lab 2-7: Opening and Searching

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Open objects without knowing what PBL they reside in

Open objects without knowing what PBL they reside in

Use the PowerBuilder search capability

Use the PowerBuilder search capability

Description:

In this lab, you will be using the FileOpen dialog to locate objects when you do not
know which PBL they reside in. You will also experiment with the Search capabilities of
PowerBuilder. Searching will be especially important to the developer.

Description:

In this lab, you will be using the FileOpen dialog to locate objects when you do not
know which PBL they reside in. You will also experiment with the Search capabilities of
PowerBuilder. Searching will be especially important to the developer.

Task Outline:

Task 1: Navigating Objects in PowerBuilder

Task Outline:

Task 1: Navigating Objects in PowerBuilder

Task 2: Using the Search Feature

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Using the Search Feature

Lab 2 - 45

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 45

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Detailed Instructions

Detailed Instructions

Task 1: Navigating Objects in PowerBuilder

Task 1: Navigating Objects in PowerBuilder

Lab 2 - 46

1.

This task will allow you to see some navigation features that are built into the IDE.
You will again be using the PB Examples application in your workspace.

1.

This task will allow you to see some navigation features that are built into the IDE.
You will again be using the PB Examples application in your workspace.

2.

Using the System Tree, drill down into the w_about window in the pbexamfe.pbl.
After expanding the window, expand the Controls folder.

2.

Using the System Tree, drill down into the w_about window in the pbexamfe.pbl.
After expanding the window, expand the Controls folder.

3.

Locate the cb_ok command button and expand it.

3.

Locate the cb_ok command button and expand it.

4.

Expand the Events folder.

4.

Expand the Events folder.

5.

The icons tell which events have been coded for an object (this feature only available
in PowerBuilder 11 or greater).

5.

The icons tell which events have been coded for an object (this feature only available
in PowerBuilder 11 or greater).

6.

Double-click on the clicked( ) event. The painter should open taking you directly to
that event.

6.

Double-click on the clicked( ) event. The painter should open taking you directly to
that event.

7.

Close the Window Painter.

7.

Close the Window Painter.

8.

Next, we will make use of the PowerBuilder Open dialog to open an object instead of
using the System Tree.

8.

Next, we will make use of the PowerBuilder Open dialog to open an object instead of
using the System Tree.

9.

When using the Open dialog (FileOpen or Open icon on the PowerBar), you first
select a target, then select the PBLs (can multi-select PBLs) you wish to allow the
dialog to search through, and finally select the type of object (Objects of Type drop
down) you wish to view. PBLs and displayed objects can be multi-selected on the
Open dialog by holding down the Ctrl key while clicking.

9.

When using the Open dialog (FileOpen or Open icon on the PowerBar), you first
select a target, then select the PBLs (can multi-select PBLs) you wish to allow the
dialog to search through, and finally select the type of object (Objects of Type drop
down) you wish to view. PBLs and displayed objects can be multi-selected on the
Open dialog by holding down the Ctrl key while clicking.

10. Find and open the object w_calendar.

10. Find and open the object w_calendar.

11. Next, use the Open dialog to open w_date_functions, w_date_sort and
w_date_window simultaneously.

11. Next, use the Open dialog to open w_date_functions, w_date_sort and
w_date_window simultaneously.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 46

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

Module 2: Understanding and Navigating the PowerBuilder IDE

12. Remember, PowerBuilder itself is an MDI (Multiple Document Interface) type IDE.
On PowerBuilders menu, select Window to see the list of the four objects you have
opened in the IDE.

12. Remember, PowerBuilder itself is an MDI (Multiple Document Interface) type IDE.
On PowerBuilders menu, select Window to see the list of the four objects you have
opened in the IDE.

13. Click WindowClose All to close all painters.

13. Click WindowClose All to close all painters.

Task 2: Using the Search Feature


1.

2.

Task 2: Using the Search Feature

Using the System Tree and right-clicking, on what three levels can you Search?

1.

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

Search for all DataWindows that use the Employee table. Right-click over the PB
Examples target, select Search and enter the following criteria:

2.

TABLE(NAME=~"employee~"
3.

2010 Sybase, Inc.

Search for all DataWindows that use the Employee table. Right-click over the PB
Examples target, select Search and enter the following criteria:
TABLE(NAME=~"employee~"

Search details are displayed where?

3.

_____________________________________________________________________
4.

Using the System Tree and right-clicking, on what three levels can you Search?

Search details are displayed where?


_____________________________________________________________________

In the view identified above, what functions can you perform on the search results
list?

4.

In the view identified above, what functions can you perform on the search results
list?

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

5.

Search to determine if the function SetTransObject used in scripts in objects other


than windows.

5.

Search to determine if the function SetTransObject used in scripts in objects other


than windows.

6.

Double-click over a blue line in the Search results. PowerBuilder will open the
appropriate object/painter and position you on the code where SetTransObject was
found. The cursor is not positioned on the exact line where SetTransObject was
found. The Ctrl-Shift-G (Go To) keyboard shortcut, in conjunction with the line
number shown in the search results will get you to the code quickly.

6.

Double-click over a blue line in the Search results. PowerBuilder will open the
appropriate object/painter and position you on the code where SetTransObject was
found. The cursor is not positioned on the exact line where SetTransObject was
found. The Ctrl-Shift-G (Go To) keyboard shortcut, in conjunction with the line
number shown in the search results will get you to the code quickly.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 47

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 47

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Lab 2-8: Examine NewsGroups, ISUG, Codexchange

Lab 2-8: Examine NewsGroups, ISUG, Codexchange

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Find other valuable information about PowerBuilder from the provided resources

Find other valuable information about PowerBuilder from the provided resources

Description:

In this lab, you will be using Internet Explorer to locate valuable resources that will assist
you with PowerBuilder questions or help.

Description:

In this lab, you will be using Internet Explorer to locate valuable resources that will assist
you with PowerBuilder questions or help.

Procedure

1.

Online Books: In PowerBuilder, click on HelpSybase Online Books Site. In the


Browser, select PowerBuilder as the product and English as the language and click
Go.

Procedure

1.

Online Books: In PowerBuilder, click on HelpSybase Online Books Site. In the


Browser, select PowerBuilder as the product and English as the language and click
Go.

2.

Select the appropriate PowerBuilder version

2.

Select the appropriate PowerBuilder version

3.

Choose a book (hyperlink).

3.

Choose a book (hyperlink).

4.

Most of the books are also downloadable as PDF versions. Watch for the PDF icon.

4.

Most of the books are also downloadable as PDF versions. Watch for the PDF icon.

5.

PowerBuilder NewsGroups: Newsgroups offer an online support system where


people post questions and receive answers to; in this case, PowerBuilder related
topics. Newsgroups are monitored by people who probably arent Sybase employees.
You will see a few replies from Sybase employees, but for the most part, they are
developers like you answering questions.

5.

PowerBuilder NewsGroups: Newsgroups offer an online support system where


people post questions and receive answers to; in this case, PowerBuilder related
topics. Newsgroups are monitored by people who probably arent Sybase employees.
You will see a few replies from Sybase employees, but for the most part, they are
developers like you answering questions.

6.

Navigate to www.sybase.com. At the top of the Sybase Homepage, you will find a
Support & Downloads link that when clicked drops down a list of choices. One of the
choices is Newsgroups. Click Newsgroups.

6.

Navigate to www.sybase.com. At the top of the Sybase Homepage, you will find a
Support & Downloads link that when clicked drops down a list of choices. One of the
choices is Newsgroups. Click Newsgroups.

7.

Choose PowerBuilder as the product from the drop down.

7.

Choose PowerBuilder as the product from the drop down.

Lab 2 - 48

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 48

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

2010 Sybase, Inc.

Module 2: Understanding and Navigating the PowerBuilder IDE

8.

You should then see a list of PowerBuilder newsgroups:

8.

You should then see a list of PowerBuilder newsgroups:

9.

Click a hyperlink of an appropriate newsgroup to access more details. You will be


asked if you want to view the newsgroup with a Browser or a NewsGroup Reader:

9.

Click a hyperlink of an appropriate newsgroup to access more details. You will be


asked if you want to view the newsgroup with a Browser or a NewsGroup Reader:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 49

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 2 - 49

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

Lab 2 - 50

Module 2 Lab: Understanding and Navigating the PowerBuilder IDE

10. The topics are listed, but you can drill down into more detail by clicking the
hyperlinks. You can also see how people responded to questions.

10. The topics are listed, but you can drill down into more detail by clicking the
hyperlinks. You can also see how people responded to questions.

11. CodeXchange Web Site: Navigate to http://codexchange.sybase.com. You will need


a login to access this site. If you do not already have one, follow the links to create
one.

11. CodeXchange Web Site: Navigate to http://codexchange.sybase.com. You will need


a login to access this site. If you do not already have one, follow the links to create
one.

12. CodeXchange is a site, as the name suggests, where developers like you can share
code examples with the Sybase community. Download and use at your own risk.

12. CodeXchange is a site, as the name suggests, where developers like you can share
code examples with the Sybase community. Download and use at your own risk.

13. Spend a few minutes navigating thru CodeXchange. On entry to that site, look for the
PowerBuilder project hyperlink:

13. Spend a few minutes navigating thru CodeXchange. On entry to that site, look for the
PowerBuilder project hyperlink:

14. Once in the PowerBuilder project you have access to the examples:

14. Once in the PowerBuilder project you have access to the examples:

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 2 - 50

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 3: Coding Fundamentals

Module 3: Coding Fundamentals

Module 3: Coding Fundamentals

Module 3: Coding Fundamentals

Lab 3-1: Basic Coding Techniques

Lab 3-1: Basic Coding Techniques

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Code pre-defined PowerBuilder object events

Code pre-defined PowerBuilder object events

Declare variables of the appropriate scope

Declare variables of the appropriate scope

Read from and write to object properties

Read from and write to object properties

Write flow-of-control statements

Write flow-of-control statements

Create a structure

Create a structure

Description:

In this lab, you are given a window that will calculate the amount to be paid based on a
claim amount, the type of claim, and the policyholders insurance coverage type. You will
read values, perform a calculation and then write the payment amount back to a control on
the window. This window will also be used in later labs to implement other techniques as
you learn more.

Description:

In this lab, you are given a window that will calculate the amount to be paid based on a
claim amount, the type of claim, and the policyholders insurance coverage type. You will
read values, perform a calculation and then write the payment amount back to a control on
the window. This window will also be used in later labs to implement other techniques as
you learn more.

Task Outline:

Task 1: Import the Claim Calculator Window into SybHealth

Task Outline:

Task 1: Import the Claim Calculator Window into SybHealth

Task 2: Coding the Claim Calculator Window

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Coding the Claim Calculator Window

Lab 3 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 3 - 1

Lab Workbook

Lab Workbook

Detailed Instructions

Detailed Instructions

Task 1: Import the Claim Calculator Window into SybHealth

Task 1: Import the Claim Calculator Window into SybHealth

1.

In the Student folder you will find a w_claim_calculator.srw file. This source file
contains the window you see below, however, it contains no scripts. Scripting the
Claim Calculator window will be done during this lab.

1.

In the Student folder you will find a w_claim_calculator.srw file. This source file
contains the window you see below, however, it contains no scripts. Scripting the
Claim Calculator window will be done during this lab.

2.

Using the System Tree, right-click over the claims.pbl in the sybhealth_target. Select
Import. Navigate and select w_claim_calculator.srw in the \Student folder.

2.

Using the System Tree, right-click over the claims.pbl in the sybhealth_target. Select
Import. Navigate and select w_claim_calculator.srw in the \Student folder.

3.

After you have imported the source file, use the System Tree to open the
w_claim_calculator window. The window should look as follows:

3.

After you have imported the source file, use the System Tree to open the
w_claim_calculator window. The window should look as follows:

Task 2: Coding the Claim Calculator Window

Task 2: Coding the Claim Calculator Window

1.

There are always different coding techniques to complete a requirement. The coding
we will perform here may not be the most efficient, or use the best practice, but they
will correspond to what was taught in Module 3. More techniques will be learned in
later modules/labs. All learning is not complete at this point.

1.

There are always different coding techniques to complete a requirement. The coding
we will perform here may not be the most efficient, or use the best practice, but they
will correspond to what was taught in Module 3. More techniques will be learned in
later modules/labs. All learning is not complete at this point.

2.

When the window is run, the first thing a user will do is select a Coverage Type.
Determine the default event for a Radio button control and write that in the space
provided below:

2.

When the window is run, the first thing a user will do is select a Coverage Type.
Determine the default event for a Radio button control and write that in the space
provided below:

_____________________________________________________________________

Lab 3 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

_____________________________________________________________________

Lab 3 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 3: Coding Fundamentals


3.

Module 3: Coding Fundamentals

When the user clicks a Radio button, your code will set a value into a variable
indicating either Basic (B) or Premium (P) was selected. What data type will you
choose to hold B or P?

3.

_____________________________________________________________________

_____________________________________________________________________

4.

Since the clicking of the Radio button is independent of the clicking of the Calculate
button, create an Instance variable on the window of type Char with the name of
ic_cover_type. Set the default value of this variable to B. Always save after
creating an Instance variable.

4.

Since the clicking of the Radio button is independent of the clicking of the Calculate
button, create an Instance variable on the window of type Char with the name of
ic_cover_type. Set the default value of this variable to B. Always save after
creating an Instance variable.

5.

In the Clicked event of the Basic Coverage Radio button, code the following:

5.

In the Clicked event of the Basic Coverage Radio button, code the following:

ic_cover_type = B
6.

ic_cover_type = B

In the Clicked event of the Premium Coverage Radio button, code the following:

6.

ic_cover_type = P

2010 Sybase, Inc.

When the user clicks a Radio button, your code will set a value into a variable
indicating either Basic (B) or Premium (P) was selected. What data type will you
choose to hold B or P?

In the Clicked event of the Premium Coverage Radio button, code the following:
ic_cover_type = P

7.

The Calculate button is named cb_test. Right-click over the button and select Script
from the context menu. Verify that you are in cb_test and on its Clicked event.

7.

The Calculate button is named cb_test. Right-click over the button and select Script
from the context menu. Verify that you are in cb_test and on its Clicked event.

8.

Declare two double variables named ldbl_claim_amt and ldbl_amt_paid.

8.

Declare two double variables named ldbl_claim_amt and ldbl_amt_paid.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 3 - 3

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 3 - 3

Lab Workbook

Lab Workbook
9.

Claim Amount and Amount Paid are EditMask controls. Open WinHelp (F1) and on
the Index tab, type EditMask Control. Double click EditMask Control in the list box
to open the details:

9.

10. Any time you type an object into the WinHelp index, you will see a cover page for
that object, briefly describing that object. For any object, there will always be three
buttons across the top of the cover page Properties, Events and Functions. Click the
Functions button:

Lab 3 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Claim Amount and Amount Paid are EditMask controls. Open WinHelp (F1) and on
the Index tab, type EditMask Control. Double click EditMask Control in the list box
to open the details:

10. Any time you type an object into the WinHelp index, you will see a cover page for
that object, briefly describing that object. For any object, there will always be three
buttons across the top of the cover page Properties, Events and Functions. Click the
Functions button:

Lab 3 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 3: Coding Fundamentals

Module 3: Coding Fundamentals

11. When the Calculate button is clicked, your code will need to read from the Claim
Amount EditMask (named em_amount), putting the value read into the
ldbl_claim_amt variable. Looking at the function names in WinHelp, which one will
you call to read the data in an EditMask?

11. When the Calculate button is clicked, your code will need to read from the Claim
Amount EditMask (named em_amount), putting the value read into the
ldbl_claim_amt variable. Looking at the function names in WinHelp, which one will
you call to read the data in an EditMask?

_____________________________________________________________________

_____________________________________________________________________

12. Review the GetData function in WinHelp. When prompted, choose Syntax 2 (getting
unformatted data from an Edit Mask control).

12. Review the GetData function in WinHelp. When prompted, choose Syntax 2 (getting
unformatted data from an Edit Mask control).

13. Close WinHelp and go back to cb_tests Clicked event. After the variable
declarations, code the following:

13. Close WinHelp and go back to cb_tests Clicked event. After the variable
declarations, code the following:

em_amount.getdata(ldbl_claim_amt)

em_amount.getdata(ldbl_claim_amt)

14. The Claim Type is a DropDownListBox control named ddlb_claimtype. Click the
Layout tab at the bottom of the Window painter, and then click on the
DropDownListBox control, giving it focus.

14. The Claim Type is a DropDownListBox control named ddlb_claimtype. Click the
Layout tab at the bottom of the Window painter, and then click on the
DropDownListBox control, giving it focus.

15. Look to the right of the painter, in the Properties view. You will see tabs across the
top. Click the Items tab.

15. Look to the right of the painter, in the Properties view. You will see tabs across the
top. Click the Items tab.

16. List the items below:

16. List the items below:

_____________________________________________________________________

_____________________________________________________________________

17. Click the General tab in the Properties view. Notice there is a Text property on a
DropDownListBox. The item the user chooses will be placed into the Text property.

17. Click the General tab in the Properties view. Notice there is a Text property on a
DropDownListBox. The item the user chooses will be placed into the Text property.

18. Still in Properties of the DDLB, enable the AllowEdit property. The Text property
becomes enabled.

18. Still in Properties of the DDLB, enable the AllowEdit property. The Text property
becomes enabled.

19. Click on the Text property and set the value to HSPTL.

19. Click on the Text property and set the value to HSPTL.

20. Disable the AllowEdit property. You have just provided a default item for your list
box.

20. Disable the AllowEdit property. You have just provided a default item for your list
box.

21. Go back to the script of the Calculate button.

21. Go back to the script of the Calculate button.

22. At the top, declare another variable as follows:

22. At the top, declare another variable as follows:

string ls_claim_type

string ls_claim_type

23. After the statement getting the Claim Amount, write the following:
ls_claim_type = ddlb_claimtype.text

2010 Sybase, Inc.

23. After the statement getting the Claim Amount, write the following:

// reads the value chosen

ls_claim_type = ddlb_claimtype.text

// reads the value chosen

24. Next, write a CHOOSE CASE statement, evaluating the contents of ls_claim_type.
The three cases will be that of the items you identified above in the
DropDownListBox.

24. Next, write a CHOOSE CASE statement, evaluating the contents of ls_claim_type.
The three cases will be that of the items you identified above in the
DropDownListBox.

25. You will need to embed IF statements within the case to allow for the following
business rule(s):

25. You will need to embed IF statements within the case to allow for the following
business rule(s):

Fast Track to PowerBuilder, Part I Version 1.0

Lab 3 - 5

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 3 - 5

Lab Workbook

Lab Workbook
a. Type HSPTL (Hospital)

a. Type HSPTL (Hospital)

i. Basic pays 70%

i. Basic pays 70%

ii. Premium pays 90%

ii. Premium pays 90%

b. Type OUTPT (OutPatient)

b. Type OUTPT (OutPatient)

i. Basic pays 80%

i. Basic pays 80%

ii. Premium pays 95%

ii. Premium pays 95%

c. Type MEDEX

Lab 3 - 6

c. Type MEDEX

i. Basic pays 90%

i. Basic pays 90%

ii. Premium pays 100%

ii. Premium pays 100%

26. Code the above business logic into the event, catching the payment about into the
ldbl_amt_paid variable.

26. Code the above business logic into the event, catching the payment about into the
ldbl_amt_paid variable.

27. Write the contents of the ldbl_amt_paid variable out to the EditMask named
em_paids Text property. You will have to convert the double to a string using the
String( ) PowerScript function.

27. Write the contents of the ldbl_amt_paid variable out to the EditMask named
em_paids Text property. You will have to convert the double to a string using the
String( ) PowerScript function.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 3 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 3: Coding Fundamentals

2010 Sybase, Inc.

Module 3: Coding Fundamentals

28. Your final code in cb_tests Clicked event might look like:

28. Your final code in cb_tests Clicked event might look like:

29. Save w_claim_calculator.

29. Save w_claim_calculator.

30. Using the System Tree, right-click over w_claim_calculator and select
Run/Previewfrom the context menu.

30. Using the System Tree, right-click over w_claim_calculator and select
Run/Previewfrom the context menu.

31. Test your work using the business rules outlined in step 25.

31. Test your work using the business rules outlined in step 25.

32. Close the window after you are satisfied with your results.

32. Close the window after you are satisfied with your results.

33. Close any open painters. Remember to use the X icon on the PainterBar to close a
painter.

33. Close any open painters. Remember to use the X icon on the PainterBar to close a
painter.

34. Click the New icon on the PowerBar.

34. Click the New icon on the PowerBar.

35. On the PB Object tab, select the Structure icon and click OK.

35. On the PB Object tab, select the Structure icon and click OK.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 3 - 7

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 3 - 7

Lab Workbook

Lab Workbook
36. This structure will hold patient information that will be passed between objects in a
later lab.

36. This structure will hold patient information that will be passed between objects in a
later lab.

37. Add four variables to the structure:

37. Add four variables to the structure:

integer patient_id
string patient_first_name
string patient_last_name
string patient_state

Lab 3 - 8

integer patient_id
string patient_first_name
string patient_last_name
string patient_state

38. Save the structure with the name s_patient_info. Be sure to save the structure into the
patients.pbl.

38. Save the structure with the name s_patient_info. Be sure to save the structure into the
patients.pbl.

39. Close any open painters.

39. Close any open painters.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 3 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 4: Adding Functionality to Classes

Module 4: Adding Functionality to Classes

Module 4: Adding Functionality to Classes

Module 4: Adding Functionality to Classes

Lab 4-1: More Advanced Coding Techniques

Lab 4-1: More Advanced Coding Techniques

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Create your own mapped and un-mapped user events

Create your own mapped and un-mapped user events

Create object-level functions

Create object-level functions

Create global functions

Create global functions

Define and use external functions

Define and use external functions

Use PowerBuilder Pronouns

Use PowerBuilder Pronouns

Use the PowerBuilder Debugger

Use the PowerBuilder Debugger

Description:

In this lab, you will continue to use the Claim Calculator window to understand more
coding techniques. You will remove the functionality you wrote in the Calculate button in
Lab 3 and place the code in an un-mapped user event, then in an object (window) function,
then a global function. A true implementation would choose one of these methods, but the
labs purpose is to give you practice at creating and calling the various types of methods.
You will also create a mapped event looking for a certain keystroke combination. You
will make use of a Windows API function (external). Pronouns will also be used in this
lab. You will write a function in the Application object to write fatal errors out to a file
system. And, you will be walked through the use of the Debugger.

Description:

In this lab, you will continue to use the Claim Calculator window to understand more
coding techniques. You will remove the functionality you wrote in the Calculate button in
Lab 3 and place the code in an un-mapped user event, then in an object (window) function,
then a global function. A true implementation would choose one of these methods, but the
labs purpose is to give you practice at creating and calling the various types of methods.
You will also create a mapped event looking for a certain keystroke combination. You
will make use of a Windows API function (external). Pronouns will also be used in this
lab. You will write a function in the Application object to write fatal errors out to a file
system. And, you will be walked through the use of the Debugger.

Task Outline:

Task 1: Creating Mapped User Events

Task Outline:

Task 1: Creating Mapped User Events

2010 Sybase, Inc.

Task 2: Creating Unmapped User Events

Task 2: Creating Unmapped User Events

Task 3: Creating an Object Function

Task 3: Creating an Object Function

Task 4: Creating a Global Function

Task 4: Creating a Global Function

Task 5: Defining and Using External Functions

Task 5: Defining and Using External Functions

Task 6: Debugging an Application

Task 6: Debugging an Application

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 1

Module 4 Lab: Adding Functionality to Classes

Module 4 Lab: Adding Functionality to Classes

Detailed Instructions

Detailed Instructions

Task 1: Creating Mapped User Events

Task 1: Creating Mapped User Events

1.

This task will have you add functionality to the claim calculator so that when the user
has focus on the Amount Paid EditMask and presses the Ctrl+S key combination, a
prompt will ask if they want to save this information. For this exercise, you will not
actually save; just prompt the user.

1.

This task will have you add functionality to the claim calculator so that when the user
has focus on the Amount Paid EditMask and presses the Ctrl+S key combination, a
prompt will ask if they want to save this information. For this exercise, you will not
actually save; just prompt the user.

2.

Open w_claim_calculator.

2.

Open w_claim_calculator.

3.

Place yourself on the script view.

3.

Place yourself on the script view.

4.

The mapped event will be added to the em_paid EditMask, so make sure that em_paid
is displayed in the object dropdown (1st dropdown) in the script view.

4.

The mapped event will be added to the em_paid EditMask, so make sure that em_paid
is displayed in the object dropdown (1st dropdown) in the script view.

5.

Using the event list (2nd dropdown), select (New Event), which is always at the top of
the list.

5.

Using the event list (2nd dropdown), select (New Event), which is always at the top of
the list.

6.

Mapped events prototypes (or signatures) are protected, so tab to the Event name and
type ue_keydown and tab again.

6.

Mapped events prototypes (or signatures) are protected, so tab to the Event name and
type ue_keydown and tab again.

7.

Using the Event ID dropdown, select pbm_keydown.

7.

Using the Event ID dropdown, select pbm_keydown.

8.

List the pre-defined arguments of pbm_keydown below:

8.

List the pre-defined arguments of pbm_keydown below:

_____________________________________________________________________
9.

Lab 4 - 2

_____________________________________________________________________

Keycode is what kind of data type?

9.

Keycode is what kind of data type?

_____________________________________________________________________

_____________________________________________________________________

10. Open the Browser, and select the Enumerated tab. Locate and select Keycode. Then
double click properties. This will give you an idea of the enumerated values for keys.
Write below, the enumerated for the Alt key and the S key:

10. Open the Browser, and select the Enumerated tab. Locate and select Keycode. Then
double click properties. This will give you an idea of the enumerated values for keys.
Write below, the enumerated for the Alt key and the S key:

_____________________________________________________________________

_____________________________________________________________________

11. Close the Browser.

11. Close the Browser.

12. In WinHelp (F1), look up Key PowerScript event. Here, help defines for you how the
KeyFlags argument may be used. A value of 1 means the Shift key was used in
conjunction with the key press. 2 means the Ctrl key was used, etc.

12. In WinHelp (F1), look up Key PowerScript event. Here, help defines for you how the
KeyFlags argument may be used. A value of 1 means the Shift key was used in
conjunction with the key press. 2 means the Ctrl key was used, etc.

13. Code your ue_keydown event so that when Ctrl+S is pressed, you display a
MessageBox asking the user if they want to save. Provide two options on the
MessageBox, a Yes and a No button. Make the Yes button the default button. If the
user clicks Yes, display another MessageBox telling them the information was saved.
If the user clicks No, close the window (using a pronoun when calling the Close( )
function).

13. Code your ue_keydown event so that when Ctrl+S is pressed, you display a
MessageBox asking the user if they want to save. Provide two options on the
MessageBox, a Yes and a No button. Make the Yes button the default button. If the
user clicks Yes, display another MessageBox telling them the information was saved.
If the user clicks No, close the window (using a pronoun when calling the Close( )
function).

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 4 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 4: Adding Functionality to Classes

Module 4: Adding Functionality to Classes

14. Using the System Tree, right-click over w_claim_calculator and select
Run/Preview from the context menu. Test your work. Remember, focus has to be
on the Amount Paid control before you press Ctrl+S.

14. Using the System Tree, right-click over w_claim_calculator and select
Run/Preview from the context menu. Test your work. Remember, focus has to be
on the Amount Paid control before you press Ctrl+S.

15. Close the running claim calculator window and return to the Window painter.

15. Close the running claim calculator window and return to the Window painter.

16. A solution to the ue_keydown event follows:

16. A solution to the ue_keydown event follows:

Task 2: Creating UnMapped User Events

Task 2: Creating UnMapped User Events

1.

In Lab 3, you coded the Calculate buttons Clicked event. You will now create an unmapped user event, placing the code from the Clicked event into your user event
instead. You will then write code to trigger the user event.

1.

In Lab 3, you coded the Calculate buttons Clicked event. You will now create an unmapped user event, placing the code from the Clicked event into your user event
instead. You will then write code to trigger the user event.

2.

Navigate to the Script view of the claim calculator window.

2.

Navigate to the Script view of the claim calculator window.

3.

Add a new user event to the window. Make sure the first drop down reads
w_claim_calculator before you add the new event.

3.

Add a new user event to the window. Make sure the first drop down reads
w_claim_calculator before you add the new event.

4.

Remember, un-mapped user events are not all that different that writing a function.
You define the return type, event name and arguments if any.

4.

Remember, un-mapped user events are not all that different that writing a function.
You define the return type, event name and arguments if any.

5.

Leave the Return type (None). Tab to the Event Name field.

5.

Leave the Return type (None). Tab to the Event Name field.

6.

Name this event ue_calculate. Always press the tab key (or the Enter key) after
entering any data in the prototype of a method in PowerBuilder. Failure to do so will
cause errors.

6.

Name this event ue_calculate. Always press the tab key (or the Enter key) after
entering any data in the prototype of a method in PowerBuilder. Failure to do so will
cause errors.

7.

For this event you do not need to add any arguments.

7.

For this event you do not need to add any arguments.

8.

Using the first drop down in the Script view, navigate to cb_test. PowerBuilder will
take you to the last event you were coding. In this case, you should be returned to
cb_tests Clicked event.

8.

Using the first drop down in the Script view, navigate to cb_test. PowerBuilder will
take you to the last event you were coding. In this case, you should be returned to
cb_tests Clicked event.

9.

Click in the Script view, giving it focus. Press Ctrl-A which is the typical Windows
Select-All shortcut. Your code should all be highlighted.

9.

Click in the Script view, giving it focus. Press Ctrl-A which is the typical Windows
Select-All shortcut. Your code should all be highlighted.

10. Press Ctrl-C to copy the code to the Windows clipboard.


2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

10. Press Ctrl-C to copy the code to the Windows clipboard.


Lab 4 - 3

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 3

Module 4 Lab: Adding Functionality to Classes

Module 4 Lab: Adding Functionality to Classes

11. Click the Comment icon on the PainterBar. Every statement is now commented. The
window will no longer work as before.

11. Click the Comment icon on the PainterBar. Every statement is now commented. The
window will no longer work as before.

12. Using the Script views first drop down, change to w_claim_calculator and then use
the Event list drop down to navigate back to your new ue_calculate event. The Event
list is alphabetical in order, and only coded events display at the top of the list. Your
ue_calculate will be at the bottom of the Event list.

12. Using the Script views first drop down, change to w_claim_calculator and then use
the Event list drop down to navigate back to your new ue_calculate event. The Event
list is alphabetical in order, and only coded events display at the top of the list. Your
ue_calculate will be at the bottom of the Event list.

13. Paste (Ctrl-V) your code into ue_calculate.

13. Paste (Ctrl-V) your code into ue_calculate.

14. A good rule of thumb to remember: Save early, save often. Press Ctrl+S to save any
PowerBuilder object. Remember, that saving also causes a compile, so you are
performing two important tasks.

14. A good rule of thumb to remember: Save early, save often. Press Ctrl+S to save any
PowerBuilder object. Remember, that saving also causes a compile, so you are
performing two important tasks.

15. Un-mapped user events are like functions. The developer is responsible for calling
them when appropriate. From where will you call this new event?

15. Un-mapped user events are like functions. The developer is responsible for calling
them when appropriate. From where will you call this new event?

_____________________________________________________________________
16. In your Student Guide, Module 4, review your options for calling methods in
PowerBuilder. There are two syntaxes you could use to call the new event.

16. In your Student Guide, Module 4, review your options for calling methods in
PowerBuilder. There are two syntaxes you could use to call the new event.

17. Navigate back to cb_tests Clicked event.

17. Navigate back to cb_tests Clicked event.

18. At the top of this event, before the commented code, trigger ue_calculate using the
following:

18. At the top of this event, before the commented code, trigger ue_calculate using the
following:

parent.event ue_calculate( )

parent.event ue_calculate( )

OR

OR

parent.triggerevent(ue_calculate)

parent.triggerevent(ue_calculate)

19. Always think generic. Use your PowerBuilder pronouns wherever possible. It is
simply good practice.

19. Always think generic. Use your PowerBuilder pronouns wherever possible. It is
simply good practice.

20. Save and test making sure you are still calculating an amount paid.

20. Save and test making sure you are still calculating an amount paid.

Task 3: Creating an Object Function

Lab 4 - 4

_____________________________________________________________________

Task 3: Creating an Object Function

1.

As an alternative to un-mapped user events, you will now put your logic into an object
function on the window and then write code to trigger the function when appropriate.

1.

As an alternative to un-mapped user events, you will now put your logic into an object
function on the window and then write code to trigger the function when appropriate.

2.

Navigate to the Script view of the claim calculator window.

2.

Navigate to the Script view of the claim calculator window.

3.

Using the PowerBuilder menu bar, click InsertFunction. You will be placed in the
Function painter.

3.

Using the PowerBuilder menu bar, click InsertFunction. You will be placed in the
Function painter.

4.

Notice the prototype area of a function differs from an event. Events can only be
public, object functions can be public (default), private or protected. There is also no
Event ID drop down. The rest is the same.

4.

Notice the prototype area of a function differs from an event. Events can only be
public, object functions can be public (default), private or protected. There is also no
Event ID drop down. The rest is the same.

5.

While public is the default, good object-oriented programmers wont always use that
option. You do not always need to expose your object logic to the outside world
(other objects). Change the Access to private. Only the claim calculator window can
call this function.

5.

While public is the default, good object-oriented programmers wont always use that
option. You do not always need to expose your object logic to the outside world
(other objects). Change the Access to private. Only the claim calculator window can
call this function.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 4 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 4: Adding Functionality to Classes

Module 4: Adding Functionality to Classes

6.

Change the return type of this function to double (to match our code). Press tab.

6.

Change the return type of this function to double (to match our code). Press tab.

7.

Object functions should have the of_ prefix. Name this function of_calculate. Press
tab.

7.

Object functions should have the of_ prefix. Name this function of_calculate. Press
tab.

8.

Define two arguments to this function (all passed by value):

8.

Define two arguments to this function (all passed by value):

double
string

adbl_claim_amt
as_claim_type

double
string

(Be sure after you type the last argument name that you either press tab or enter. If
you tab, do not worry about the addition of a new argument line. It will be ignored.)
9.

(Be sure after you type the last argument name that you either press tab or enter. If
you tab, do not worry about the addition of a new argument line. It will be ignored.)

Script the new function by declaring a double variable named ldbl_ret.

9.

10. Code a return statement, returning ldbl_ret:

2010 Sybase, Inc.

adbl_claim_amt
as_claim_type

Script the new function by declaring a double variable named ldbl_ret.

10. Code a return statement, returning ldbl_ret:

11. As far as PowerBuilder is concerned, the function is complete. Save your work.

11. As far as PowerBuilder is concerned, the function is complete. Save your work.

12. Using the first drop down in the Function painter, navigate back to
w_claim_calculator. You should be positioned back on ue_calculate.

12. Using the first drop down in the Function painter, navigate back to
w_claim_calculator. You should be positioned back on ue_calculate.

13. Click in the Script view of ue_calculate, press Ctrl+A and then Ctrl+C to copy that
code to the clipboard.

13. Click in the Script view of ue_calculate, press Ctrl+A and then Ctrl+C to copy that
code to the clipboard.

14. Navigate back to your of_calculate function and paste the code before your return
statement.

14. Navigate back to your of_calculate function and paste the code before your return
statement.

15. Locate these three statements in the code:

15. Locate these three statements in the code:

a. em_amount.getdata()

a. em_amount.getdata()

b. ls_claim_type = ddlb_claimtype.text

b. ls_claim_type = ddlb_claimtype.text

c. em_paid.text =

c. em_paid.text =

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 5

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 5

Module 4 Lab: Adding Functionality to Classes

Lab 4 - 6

Module 4 Lab: Adding Functionality to Classes

16. We need to cut them (to the clipboard, Ctrl-X) and then paste them back into cb_tests
Clicked event, but we cant do that until the function is ready to compile. Since the
lines arent all together in the code, you will have to be creative. Use the
PowerBuilder File Editor as a temporary pasting area.

16. We need to cut them (to the clipboard, Ctrl-X) and then paste them back into cb_tests
Clicked event, but we cant do that until the function is ready to compile. Since the
lines arent all together in the code, you will have to be creative. Use the
PowerBuilder File Editor as a temporary pasting area.

17. Delete the statement declaring ls_claim_type. The function defined the claim type as
an argument. Function arguments become local variables usable within the function.
Change any statements in the code that used ls_claim_type to as_claim_type.

17. Delete the statement declaring ls_claim_type. The function defined the claim type as
an argument. Function arguments become local variables usable within the function.
Change any statements in the code that used ls_claim_type to as_claim_type.

18. Delete the declaration of ldbl_claim_amt and change any code references to use the
argument adbl_claim_amt. Any Script view, including the Function painter has a
Search and Replace feature (there is a Replace icon on the PainterBar or you can use
the Ctrl+H shortcut.).

18. Delete the declaration of ldbl_claim_amt and change any code references to use the
argument adbl_claim_amt. Any Script view, including the Function painter has a
Search and Replace feature (there is a Replace icon on the PainterBar or you can use
the Ctrl+H shortcut.).

19. Delete the declaration of ldbl_ret and change the Return statement to return
ldbl_amt_paid.

19. Delete the declaration of ldbl_ret and change the Return statement to return
ldbl_amt_paid.

20. Save your work, fixing any compiler errors as necessary.

20. Save your work, fixing any compiler errors as necessary.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 4 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 4: Adding Functionality to Classes

Module 4: Adding Functionality to Classes

21. The of_calculate( ) function code should look as follows:

21. The of_calculate( ) function code should look as follows:

22. Navigate back to cb_tests Clicked event.

22. Navigate back to cb_tests Clicked event.

23. Comment the call to ue_calculate( ).

23. Comment the call to ue_calculate( ).

24. Declare three variables:

24. Declare three variables:

double
string

ldbl_claim_amt, ldbl_amt_paid
ls_claim_type

double
string

25. Switch to the File Editor and cut the three lines of code we pasted there earlier into
your function, after the above declarations.

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 7

ldbl_claim_amt, ldbl_amt_paid
ls_claim_type

25. Switch to the File Editor and cut the three lines of code we pasted there earlier into
your function, after the above declarations.

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 7

Module 4 Lab: Adding Functionality to Classes

Lab 4 - 8

Module 4 Lab: Adding Functionality to Classes

26. Before the statement that writes back to em_paid, call your function, catching the
return in the ldbl_amt_paid variable. Sample cb_test Clicked event code follows:

26. Before the statement that writes back to em_paid, call your function, catching the
return in the ldbl_amt_paid variable. Sample cb_test Clicked event code follows:

27. Save and test. After successfully testing, close any open painters.

27. Save and test. After successfully testing, close any open painters.

28. Open your Application object, a_sybhealth (sybhealth.pbl).

28. Open your Application object, a_sybhealth (sybhealth.pbl).

29. Begin by examining the event list. Which event fires when a fatal application error
has occurred?

29. Begin by examining the event list. Which event fires when a fatal application error
has occurred?

_____________________________________________________________________

_____________________________________________________________________

30. Look at the Application objects Properties view. Click the Additional Properties
button. What object is automatically populated with information when an application
experiences a runtime problem?

30. Look at the Application objects Properties view. Click the Additional Properties
button. What object is automatically populated with information when an application
experiences a runtime problem?

_____________________________________________________________________

_____________________________________________________________________

31. Open the Browser (ToolsBrowser). Click the System tab. Click the Error object in
the left-hand list. Then double click Properties in the right-hand list.

31. Open the Browser (ToolsBrowser). Click the System tab. Click the Error object in
the left-hand list. Then double click Properties in the right-hand list.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 4 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 4: Adding Functionality to Classes

Module 4: Adding Functionality to Classes

32. Note the properties of Error below:

32. Note the properties of Error below:

33. When a runtime error occurs, the global Error objects properties are automatically
populated with details about the error (number, text), and where the error occurred
(object, objectevent and line).

33. When a runtime error occurs, the global Error objects properties are automatically
populated with details about the error (number, text), and where the error occurred
(object, objectevent and line).

34. Close the Browser.

34. Close the Browser.

35. Create an object function on the a_sybhealth Application object to be called when the
SystemError event fires by clicking InsertFunction on the PowerBuilder menu bar.

35. Create an object function on the a_sybhealth Application object to be called when the
SystemError event fires by clicking InsertFunction on the PowerBuilder menu bar.

36. If not explicitly stated, take defaults when performing lab steps. Set the function to
return (None). Dont forget the parenthesis around the word None.

36. If not explicitly stated, take defaults when performing lab steps. Set the function to
return (None). Dont forget the parenthesis around the word None.

37. Name the function of_report_error. You do not need to define any arguments for this
function.

37. Name the function of_report_error. You do not need to define any arguments for this
function.

38. The function will display the fatal error information in a MessageBox, and ask the
user if they wish to save the information to a file as well. You will be concatenating
the values of the Error properties into a string for displaying and writing that string
out to a file. Some notes to help you with this task:

38. The function will display the fatal error information in a MessageBox, and ask the
user if they wish to save the information to a file as well. You will be concatenating
the values of the Error properties into a string for displaying and writing that string
out to a file. Some notes to help you with this task:

a. Use the MessageBox( ) function to display the information.

a. Use the MessageBox( ) function to display the information.

b. Include a date and time in the error information.

b. Include a date and time in the error information.

c. Error is the global name given to the error object instance.

c. Error is the global name given to the error object instance.

d. Some properties are numeric and will need to be casted to a string for
displaying and writing to the file.

d. Some properties are numeric and will need to be casted to a string for
displaying and writing to the file.

e. Use the tilde characters to place each piece of error information in a separate
line. Put descriptions on the information.

e. Use the tilde characters to place each piece of error information in a separate
line. Put descriptions on the information.

f.

f.

Write the error information out to the same directory as the application (in
your case, the Student directory) with a file name of SybHealth_error.log.

g. Use WinHelp to look up FileOpen( ), FileWriteEx( ) and FileClose( )


functions. When you are looking at the FileWriteEx( ) function, click the
Examples button for almost-complete code, copy and paste into the function,
and adapt. Dont forget the FileClose( ).

g. Use WinHelp to look up FileOpen( ), FileWriteEx( ) and FileClose( )


functions. When you are looking at the FileWriteEx( ) function, click the
Examples button for almost-complete code, copy and paste into the function,
and adapt. Dont forget the FileClose( ).

(Some older versions of PowerBuilder do not have the FileWriteEx( )


function. Use FileWrite( ) instead.)

(Some older versions of PowerBuilder do not have the FileWriteEx( )


function. Use FileWrite( ) instead.)

h. Open the file in append mode so error messages are kept. But append a blank
line (or some form of separator) between errors that get written.
2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Write the error information out to the same directory as the application (in
your case, the Student directory) with a file name of SybHealth_error.log.

Lab 4 - 9

h. Open the file in append mode so error messages are kept. But append a blank
line (or some form of separator) between errors that get written.
2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 9

Module 4 Lab: Adding Functionality to Classes

Lab 4 - 10

Module 4 Lab: Adding Functionality to Classes

39. A possible solution for the of_report_error( ) function is shown below:

39. A possible solution for the of_report_error( ) function is shown below:

40. After coding your of_report_error( ) save your work.

40. After coding your of_report_error( ) save your work.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 4 - 10

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 4: Adding Functionality to Classes

Module 4: Adding Functionality to Classes

41. Navigate to the a_sybhealth SystemError event. Call the function from the event as
follows:

41. Navigate to the a_sybhealth SystemError event. Call the function from the event as
follows:

this.of_report_error( )

2010 Sybase, Inc.

this.of_report_error( )

42. Add a HALT CLOSE after the function call in the SystemError event. HALT alone
terminates a running PowerBuilder application. HALT CLOSE does the same; it just
fires the Application objects Close event first, giving the application a chance to
clean up before terminating.

42. Add a HALT CLOSE after the function call in the SystemError event. HALT alone
terminates a running PowerBuilder application. HALT CLOSE does the same; it just
fires the Application objects Close event first, giving the application a chance to
clean up before terminating.

43. Save your Application object.

43. Save your Application object.

44. Test your work, simulating a fatal error by coding a divide by zero in the Application
objects Open event:

44. Test your work, simulating a fatal error by coding a divide by zero in the Application
objects Open event:

45. To run the application you need to right-click over the SybHealth_target in the
System Tree and select Run from the context menu. This will cause the entire
application to run as opposed to Run/Preview we have been doing to run a single
window. Remember, we have enabled Just In Time Debugging in an earlier lab.
When prompted, click the Ignore button, but you will be placed into the Debugger.
Your message box from the function may be hidden behind some open windows.
Check your error log file to make sure you wrote information there.

45. To run the application you need to right-click over the SybHealth_target in the
System Tree and select Run from the context menu. This will cause the entire
application to run as opposed to Run/Preview we have been doing to run a single
window. Remember, we have enabled Just In Time Debugging in an earlier lab.
When prompted, click the Ignore button, but you will be placed into the Debugger.
Your message box from the function may be hidden behind some open windows.
Check your error log file to make sure you wrote information there.

46. When satisfied with your work, take the divide by zero code out of the Application
objects Open event, leaving it empty for now.

46. When satisfied with your work, take the divide by zero code out of the Application
objects Open event, leaving it empty for now.

47. Save and close the Application object painter.

47. Save and close the Application object painter.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 11

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 11

Module 4 Lab: Adding Functionality to Classes

Module 4 Lab: Adding Functionality to Classes

Task 4: Creating a Global Function

Task 4: Creating a Global Function

1.

To provide another alternative to un-mapped events and object functions, you will
now put your logic into a global function.

1.

To provide another alternative to un-mapped events and object functions, you will
now put your logic into a global function.

2.

Using the System Tree, right-click over your SybHealth_target and select New
from the context menu.

2.

Using the System Tree, right-click over your SybHealth_target and select New
from the context menu.

3.

On the PB Object tab, click Function and then click OK.

3.

On the PB Object tab, click Function and then click OK.

4.

What does the (Global) Function painter should look like the object-function or event
painter.

4.

What does the (Global) Function painter should look like the object-function or event
painter.

5.

How are Global functions similar to un-mapped user events? How do they differ
from object functions?

5.

How are Global functions similar to un-mapped user events? How do they differ
from object functions?

6.

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

Name the function f_calculate, creating the global functions prototype the same way
you did the object function, returning a double and with the same two arguments:
double
string

6.

adbl_claim_amt
as_claim_type

double
string

adbl_claim_amt
as_claim_type

7.

Re-open w_claim_calculator and navigate to the of_calculate( ) function. Copy the


code verbatim from the object function in the claim calculator window to your global
function.

7.

Re-open w_claim_calculator and navigate to the of_calculate( ) function. Copy the


code verbatim from the object function in the claim calculator window to your global
function.

8.

Save your work.

8.

Save your work.

9.

Why did the code not compile?

9.

Why did the code not compile?

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

10. The instance variable ic_cover_type belonged to the w_claim_calculator window.


You are now writing a global function, which is not affiliated to that window.

10. The instance variable ic_cover_type belonged to the w_claim_calculator window.


You are now writing a global function, which is not affiliated to that window.

11. How will you correct this situation?

11. How will you correct this situation?

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

12. Add a third argument to the function, as follows:


character

12. Add a third argument to the function, as follows:

ac_cover_type

character

13. After adding the argument to the function, make the appropriate changes to your code.
A solution can be seen on the next page:
Lab 4 - 12

Name the function f_calculate, creating the global functions prototype the same way
you did the object function, returning a double and with the same two arguments:

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

ac_cover_type

13. After adding the argument to the function, make the appropriate changes to your code.
A solution can be seen on the next page:
Lab 4 - 12

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 4: Adding Functionality to Classes

Module 4: Adding Functionality to Classes

14. Save. When saving a global function, you are prompted again to name your function
and select which PBL you wish to put the function into. Choose the claims.pbl. If
you forget and put an object in the wrong PBL, you can always Move objects by
right-clicking over them in the System Tree.

14. Save. When saving a global function, you are prompted again to name your function
and select which PBL you wish to put the function into. Choose the claims.pbl. If
you forget and put an object in the wrong PBL, you can always Move objects by
right-clicking over them in the System Tree.

15. Close the Global Function painter.

15. Close the Global Function painter.

16. Using the System Tree, locate your global function.

16. Using the System Tree, locate your global function.

17. Can you see your object function or your user event (ue_calculate) in the System
Tree?

17. Can you see your object function or your user event (ue_calculate) in the System
Tree?

_____________________________________________________________________

_____________________________________________________________________

18. In the System Tree, expand the window w_claim_calculator.


2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

18. In the System Tree, expand the window w_claim_calculator.


Lab 4 - 13

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 13

Module 4 Lab: Adding Functionality to Classes

Module 4 Lab: Adding Functionality to Classes

19. Expand the Events and/or Functions folders to answer the above question.
Remember, the icons look different if an event or function is coded. Using the
System Tree, double-click either of_calculate or ue_calculate and it should open in
the painter taking you directly to your code (a new feature available since
PowerBuilder 11).

19. Expand the Events and/or Functions folders to answer the above question.
Remember, the icons look different if an event or function is coded. Using the
System Tree, double-click either of_calculate or ue_calculate and it should open in
the painter taking you directly to your code (a new feature available since
PowerBuilder 11).

20. This was an exercise in creating global functions. You do not need to call the
function from the claim calculator window. Remember that if you have a global
function, it can be called from anywhere in the application. If you use an object
function instead, a) the object has to be instantiated before you call the function and b)
you can limit access to the object level functions.

20. This was an exercise in creating global functions. You do not need to call the
function from the claim calculator window. Remember that if you have a global
function, it can be called from anywhere in the application. If you use an object
function instead, a) the object has to be instantiated before you call the function and b)
you can limit access to the object level functions.

Task 5: Defining and Using External Functions

Task 5: Defining and Using External Functions

1.

External functions are those written in another language, like C++, but are accessible
from your PowerScript objects and their events or functions. Why re-invent the wheel
when you can call work provided by others? The most common examples of using
External Functions are to call Windows API functions.

1.

External functions are those written in another language, like C++, but are accessible
from your PowerScript objects and their events or functions. Why re-invent the wheel
when you can call work provided by others? The most common examples of using
External Functions are to call Windows API functions.

2.

Some useful documents for defining and using External Functions can be found on
the Sybase web site. Go to www.sybase.com and search for PowerBuilder and
Windows API. Look for the documents named 32-bit Windows API Calls for
PowerBuilder and Prototyping API Calls for PowerBuilder.

2.

Some useful documents for defining and using External Functions can be found on
the Sybase web site. Go to www.sybase.com and search for PowerBuilder and
Windows API. Look for the documents named 32-bit Windows API Calls for
PowerBuilder and Prototyping API Calls for PowerBuilder.

3.

Re-open the claim calculator window.

3.

Re-open the claim calculator window.

4.

Click the Declare Instance Variables tab in the Window painter (lower, middle of the
painter).

4.

Click the Declare Instance Variables tab in the Window painter (lower, middle of the
painter).

5.

Using the middle drop down, change to Global External Functions. Declare the
external function as follows:

5.

Using the middle drop down, change to Global External Functions. Declare the
external function as follows:

(If using PowerBuilder 9 or earlier do not add the alias for clause to the declaration.)

Lab 4 - 14

(If using PowerBuilder 9 or earlier do not add the alias for clause to the declaration.)

6.

The above example was found in the document named 32-bit Windows API Calls
for PowerBuilder. GetUserNameA( ) is a Windows function that will return the
name of the user who is currently logged into the Operating System.

6.

The above example was found in the document named 32-bit Windows API Calls
for PowerBuilder. GetUserNameA( ) is a Windows function that will return the
name of the user who is currently logged into the Operating System.

7.

Save your work.

7.

Save your work.

8.

Navigate to w_claim_calculators Open event.

8.

Navigate to w_claim_calculators Open event.

9.

Write code to call the GetUserNameA function and write the returned value to the
Claim Calculators Title property, in addition to the value already in the title. A
solution to this step can be found on the next page:

9.

Write code to call the GetUserNameA function and write the returned value to the
Claim Calculators Title property, in addition to the value already in the title. A
solution to this step can be found on the next page:

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 4 - 14

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 4: Adding Functionality to Classes

Module 4: Adding Functionality to Classes

10. Save and Run/Preview the claim calculator window to test your work. You may
need to resize the window to see more information in the title bar.

10. Save and Run/Preview the claim calculator window to test your work. You may
need to resize the window to see more information in the title bar.

11. Close any open painters when you have completed your testing.

11. Close any open painters when you have completed your testing.

Task 6: Debugging an Application

Task 6: Debugging an Application

1.

This task has you using the PowerBuilder Debugger. We will use the claim calculator
to learn how to use this utility.

1.

This task has you using the PowerBuilder Debugger. We will use the claim calculator
to learn how to use this utility.

2.

To debug, you will need to run the application in its entirety, which you are not yet set
up to do.

2.

To debug, you will need to run the application in its entirety, which you are not yet set
up to do.

3.

Re-open the a_sybhealth Application object.

3.

Re-open the a_sybhealth Application object.

4.

Navigate to the Open event.

4.

Navigate to the Open event.

5.

Code the Open event to open the w_claim_calculator window:

5.

Code the Open event to open the w_claim_calculator window:

Open(w_claim_calculator)

2010 Sybase, Inc.

Open(w_claim_calculator)

6.

Close and save your Application object.

6.

Close and save your Application object.

7.

Click on the Run menu item on PowerBuilders menu bar.

7.

Click on the Run menu item on PowerBuilders menu bar.

8.

On the drop down menu, you will see two options: Debug sybhealth_target and
Select and Debug. Your current workspace has two targets. If you needed to debug a
target other than SybHealth_target, you would have to use the Select and Debug
option. Select and Debug displays a dialog letting you select which target you wish to
debug. There are also icons on the PowerBar to accomplish the same task.

8.

On the drop down menu, you will see two options: Debug sybhealth_target and
Select and Debug. Your current workspace has two targets. If you needed to debug a
target other than SybHealth_target, you would have to use the Select and Debug
option. Select and Debug displays a dialog letting you select which target you wish to
debug. There are also icons on the PowerBar to accomplish the same task.

9.

Click the Debug sybhealth_target option on the Run menu.

9.

Click the Debug sybhealth_target option on the Run menu.

10. The Debugger opens.

10. The Debugger opens.

11. In the upper-right of the Debugger is a view named the Source Browser. It has a tree
view containing the generic PowerBuilder object types. Expand Windows.

11. In the upper-right of the Debugger is a view named the Source Browser. It has a tree
view containing the generic PowerBuilder object types. Expand Windows.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 15

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 15

Module 4 Lab: Adding Functionality to Classes

Lab 4 - 16

Module 4 Lab: Adding Functionality to Classes

12. Expand w_claim_calculator.

12. Expand w_claim_calculator.

13. Expand cb_test.

13. Expand cb_test.

14. The Source Browser only shows events that have been coded, simplifying the setup of
the Debugger. Double-click on the clicked( ) event of cb_test.

14. The Source Browser only shows events that have been coded, simplifying the setup of
the Debugger. Double-click on the clicked( ) event of cb_test.

15. The Clicked event code is now displaying in the upper right view of the Debugger.
You are now ready to set a breakpoint. You can set as many breakpoints as you need,
but for this exercise, keep things simple.

15. The Clicked event code is now displaying in the upper right view of the Debugger.
You are now ready to set a breakpoint. You can set as many breakpoints as you need,
but for this exercise, keep things simple.

16. Double-click on the statement where you are getting the data from the em_amount
EditMask. Double clicking will result in a red dot being placed to the left of the code.
This is a breakpoint. When you come into the debugger, you should have some idea
of where the application is breaking and set breakpoints accordingly.

16. Double-click on the statement where you are getting the data from the em_amount
EditMask. Double clicking will result in a red dot being placed to the left of the code.
This is a breakpoint. When you come into the debugger, you should have some idea
of where the application is breaking and set breakpoints accordingly.

17. On the menu, click DebugStart sybhealth_target, or click the first icon on the
PainterBar.

17. On the menu, click DebugStart sybhealth_target, or click the first icon on the
PainterBar.

18. The window will appear to be running as normal until you hit a breakpoint.

18. The window will appear to be running as normal until you hit a breakpoint.

19. Enter a claim amount of 100.00 and a type of HSPTL. Click the Calculate button.
The window disappears and you are back in the Debugger.

19. Enter a claim amount of 100.00 and a type of HSPTL. Click the Calculate button.
The window disappears and you are back in the Debugger.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 4 - 16

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 4: Adding Functionality to Classes

2010 Sybase, Inc.

Module 4: Adding Functionality to Classes

20. You will see a yellow arrow over the breakpoint indicator (red dot). Code execution
has been suspended, awaiting your input.

20. You will see a yellow arrow over the breakpoint indicator (red dot). Code execution
has been suspended, awaiting your input.

21. If not selected, click the Local tab (middle of Debugger), where you will see the
values of any declared local variables.

21. If not selected, click the Local tab (middle of Debugger), where you will see the
values of any declared local variables.

22. Press the F8 (Step) key one time. The yellow arrow moves to the next statement and
the value of the ldb_claim_amt local variable has been updated.

22. Press the F8 (Step) key one time. The yellow arrow moves to the next statement and
the value of the ldb_claim_amt local variable has been updated.

23. Double-click the ldb_claim_amt variable in the Debugger. A dialog opens, allowing
you to change the value. Change the value to 200 and click OK.

23. Double-click the ldb_claim_amt variable in the Debugger. A dialog opens, allowing
you to change the value. Change the value to 200 and click OK.

24. Press the F8 two times.

24. Press the F8 two times.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 17

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 4 - 17

Module 4 Lab: Adding Functionality to Classes

Lab 4 - 18

Module 4 Lab: Adding Functionality to Classes

25. When in the Debugger, it is always helpful to watch the title bars. In the upper-left
view (where the code displays), you should now see that you have entered the code
for your of_calculate( ) function you wrote earlier.

25. When in the Debugger, it is always helpful to watch the title bars. In the upper-left
view (where the code displays), you should now see that you have entered the code
for your of_calculate( ) function you wrote earlier.

26. You can continue to F8 to step thru code until you have found what you are looking
for in the Debugger. You could also choose to Step Out (Shift-F8) the of_calculate( )
function if you dont need to walk the code there. There is also a Step Over (F10) that
you could use to have totally avoided the function altogether.

26. You can continue to F8 to step thru code until you have found what you are looking
for in the Debugger. You could also choose to Step Out (Shift-F8) the of_calculate( )
function if you dont need to walk the code there. There is also a Step Over (F10) that
you could use to have totally avoided the function altogether.

27. Spend a few minutes exploring the Debugger. You may have to start and stop the
Debugger to explore fully.

27. Spend a few minutes exploring the Debugger. You may have to start and stop the
Debugger to explore fully.

28. When done, close the Debugger.

28. When done, close the Debugger.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 4 - 18

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 5: User Interfaces in PowerBuilder

Module 5: User Interfaces in PowerBuilder

Module 5: User Interfaces in PowerBuilder

Module 5: User Interfaces in PowerBuilder

Lab 5-1: Exploring and Creating Framework Objects

Lab 5-1: Exploring and Creating Framework Objects

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Identify the type and use of mini-framework objects provided

Identify the type and use of mini-framework objects provided

Create some additional framework windows (by-style)

Create some additional framework windows (by-style)

Create common method stubs in framework windows

Create common method stubs in framework windows

Create Standard Visual Objects

Create Standard Visual Objects

Description:

In this lab, you will begin by evaluating the provided mini-framework objects (added to
the SybHealth target Library List in the lab for Module 2). You will then add, through
inheritance, some new framework windows that will be coded later, as you learn additional
concepts. To get some additional practice adding methods to classes, you will put some
stub methods into the framework windows no code just the declaration of the
methods. These methods will be coded in later labs. Last, you will create your own
Standard Visual User Object(s) to augment the mini-framework provided.

Description:

In this lab, you will begin by evaluating the provided mini-framework objects (added to
the SybHealth target Library List in the lab for Module 2). You will then add, through
inheritance, some new framework windows that will be coded later, as you learn additional
concepts. To get some additional practice adding methods to classes, you will put some
stub methods into the framework windows no code just the declaration of the
methods. These methods will be coded in later labs. Last, you will create your own
Standard Visual User Object(s) to augment the mini-framework provided.

Task Outline:

Task 1: Reviewing Provided Framework Classes

Task Outline:

Task 1: Reviewing Provided Framework Classes

2010 Sybase, Inc.

Task 2: Creating Additional Framework Windows

Task 2: Creating Additional Framework Windows

Task 3: Adding Methods to Framework Windows

Task 3: Adding Methods to Framework Windows

Task 4: Creating Standard Visual User Objects

Task 4: Creating Standard Visual User Objects

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 1

Lab Workbook

Lab Workbook

Detailed Instructions

Detailed Instructions

Task 1: Reviewing Provided Framework Classes

Task 1: Reviewing Provided Framework Classes

Lab 5 - 2

1. This task has you gain a better understanding of the contents of the four framework
PBLs you added in the lab for Module 2 (windows_base, windows_abstract,
visual_controls_base, visual_controls_abstract).

1. This task has you gain a better understanding of the contents of the four framework
PBLs you added in the lab for Module 2 (windows_base, windows_abstract,
visual_controls_base, visual_controls_abstract).

2. Expand and review the contents of the windows_base and windows_abstract PBLs.

2. Expand and review the contents of the windows_base and windows_abstract PBLs.

3. w_master is the top-most ancestor of the hierarchy. Every window you create will
ultimately inherit from w_master. Why have one window that every window
ultimately inherits from?

3. w_master is the top-most ancestor of the hierarchy. Every window you create will
ultimately inherit from w_master. Why have one window that every window
ultimately inherits from?

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

4. Every window in the window_abstract.pbl is inherited from w_master. The


inheritance hierarchy can be viewed by opening the Browser and clicking the Window
tab. This tab shows all windows created for the associated target, in alphabetical
order.

4. Every window in the window_abstract.pbl is inherited from w_master. The


inheritance hierarchy can be viewed by opening the Browser and clicking the Window
tab. This tab shows all windows created for the associated target, in alphabetical
order.

5. In a null area of the left-hand list, right-click and select Show Hierarchy from the
context menu:

5. In a null area of the left-hand list, right-click and select Show Hierarchy from the
context menu:

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 5 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 5: User Interfaces in PowerBuilder

Module 5: User Interfaces in PowerBuilder

6. The Browser is now showing the windows in hierarchical order. You may have to
expand w_master to see the descendant objects. The Window tree view does not
show a plus symbol beside objects that can be expanded:

6. The Browser is now showing the windows in hierarchical order. You may have to
expand w_master to see the descendant objects. The Window tree view does not
show a plus symbol beside objects that can be expanded:

7. There was a reason for the window names provided. Those names indicate what?

7. There was a reason for the window names provided. Those names indicate what?

_____________________________________________________________________
8. Close the Browser.

8. Close the Browser.

9. Open w_child in the Window painter. Navigate to the Properties view. Check the
Window type property.

9. Open w_child in the Window painter. Navigate to the Properties view. Check the
Window type property.

10. Repeat step 9 opening w_popup and reviewing its Window type property.

10. Repeat step 9 opening w_popup and reviewing its Window type property.

11. Close any painters.

11. Close any painters.

12. The provided framework windows are referred to as a hierarchy-by-type (for Window
type).

12. The provided framework windows are referred to as a hierarchy-by-type (for Window
type).

13. There is no code in any of the framework objects. They were given to you as a starting
point.

13. There is no code in any of the framework objects. They were given to you as a starting
point.

Task 2: Creating Additional Framework Windows

2010 Sybase, Inc.

_____________________________________________________________________

Task 2: Creating Additional Framework Windows

1. In addition to a hierarchy-by-type, it is common to identify patterns within your


application development and then create a hierarchy-by-style. Where the by-type
windows have no controls on them, in a by-style hierarchy, windows are created with
controls and pre-coded to some extent.

1. In addition to a hierarchy-by-type, it is common to identify patterns within your


application development and then create a hierarchy-by-style. Where the by-type
windows have no controls on them, in a by-style hierarchy, windows are created with
controls and pre-coded to some extent.

2. For example, if you had identified a pattern where you had many windows that either
display or manipulate data, you probably need a window that has a DataWindow
control on it. Rather than constantly having to drag a DataWindow control to a new
window, do it one time in an ancestor object.

2. For example, if you had identified a pattern where you had many windows that either
display or manipulate data, you probably need a window that has a DataWindow
control on it. Rather than constantly having to drag a DataWindow control to a new
window, do it one time in an ancestor object.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 3

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 3

Lab Workbook

Lab 5 - 4

Lab Workbook
3. Another common example (pattern) is the Master-Detail. In a Master-Detail, you have
two DataWindow controls on a single window. Anywhere you identify a pattern; you
should ask yourself should this be put in my framework?

3. Another common example (pattern) is the Master-Detail. In a Master-Detail, you have


two DataWindow controls on a single window. Anywhere you identify a pattern; you
should ask yourself should this be put in my framework?

4. Using the System Tree, right-click over w_main and select Inherit from on the context
menu. A new untitled window appears in the Window painter.

4. Using the System Tree, right-click over w_main and select Inherit from on the context
menu. A new untitled window appears in the Window painter.

5. Save this window as w_sheet in the windows_abstract.pbl. You will have to click
FileSave As since no changes have been made. This will be the ancestor of all
sheets in our MDI (Multiple Document Interface) application. You will be learning
more about MDI and sheets in the next module.

5. Save this window as w_sheet in the windows_abstract.pbl. You will have to click
FileSave As since no changes have been made. This will be the ancestor of all
sheets in our MDI (Multiple Document Interface) application. You will be learning
more about MDI and sheets in the next module.

6. Close the painter.

6. Close the painter.

7. Using the System Tree, inherit from w_sheet., creating w_data_sheet. Save this
window in the windows_abstract.pbl. Controls will be put on this window later in this
lab.

7. Using the System Tree, inherit from w_sheet., creating w_data_sheet. Save this
window in the windows_abstract.pbl. Controls will be put on this window later in this
lab.

8. Close the painter.

8. Close the painter.

9. Again, inherit from w_sheet, creating w_master_detail_sheet. Save this window in the
windows_abstract.pbl.

9. Again, inherit from w_sheet, creating w_master_detail_sheet. Save this window in the
windows_abstract.pbl.

10. Close the painter.

10. Close the painter.

11. Use the Browser to ensure you have the following hierarchy:

11. Use the Browser to ensure you have the following hierarchy:

12. Close the Browser and any open painters.

12. Close the Browser and any open painters.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 5 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 5: User Interfaces in PowerBuilder

Task 3: Adding Methods to Framework Windows

Module 5: User Interfaces in PowerBuilder

Task 3: Adding Methods to Framework Windows

1. Many tasks are repetitive within one or many applications. Try to avoid coding the
same thing multiple times. If you create method signatures (prototypes) in your
framework, you wont have to constantly repeat that step. Some times you will just
define the method signature in the framework object, and then override the method in
the descendant object(s). Some times you will put code in the ancestor. These are
design decisions.

1. Many tasks are repetitive within one or many applications. Try to avoid coding the
same thing multiple times. If you create method signatures (prototypes) in your
framework, you wont have to constantly repeat that step. Some times you will just
define the method signature in the framework object, and then override the method in
the descendant object(s). Some times you will put code in the ancestor. These are
design decisions.

2. Name some common tasks that will be invoked by an end-user who is working with a
window (especially windows that allow data and/or data manipulations):

2. Name some common tasks that will be invoked by an end-user who is working with a
window (especially windows that allow data and/or data manipulations):

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

3. Placement of methods within the hierarchy is a critical decision. Where do the


ue_insert and ue_delete methods belong in the framework?

3. Placement of methods within the hierarchy is a critical decision. Where do the


ue_insert and ue_delete methods belong in the framework?

_____________________________________________________________________

2010 Sybase, Inc.

_____________________________________________________________________

4. The answer to that question is always it depends. Object-oriented programming


takes much design work. If your Master-Detail windows could be editable, then you
would have to put the above methods in w_sheet in our hierarchy. You want to be
careful about where you place methods so as to avoid over-engineering descendant
classes.

4. The answer to that question is always it depends. Object-oriented programming


takes much design work. If your Master-Detail windows could be editable, then you
would have to put the above methods in w_sheet in our hierarchy. You want to be
careful about where you place methods so as to avoid over-engineering descendant
classes.

5. The decision to make your methods functions or events is also a design issue. This
needs to be a thought-out before you arbitrarily create methods. A good rule of thumb
is if it is initiated by an end-user, it is an event. If it is something the system initiates
internally, it is a function. But you need to also remember that only functions can be
overloaded. Only functions allow you to set an access privilege such as Private or
Protected. Review Module 4 for more details about choosing events or functions.

5. The decision to make your methods functions or events is also a design issue. This
needs to be a thought-out before you arbitrarily create methods. A good rule of thumb
is if it is initiated by an end-user, it is an event. If it is something the system initiates
internally, it is a function. But you need to also remember that only functions can be
overloaded. Only functions allow you to set an access privilege such as Private or
Protected. Review Module 4 for more details about choosing events or functions.

6. Open w_sheet in the Window painter.

6. Open w_sheet in the Window painter.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 5

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 5

Lab Workbook

Lab Workbook
7. Add the following new user events (un-mapped). All of these events return (None)
and have no arguments:

7. Add the following new user events (un-mapped). All of these events return (None)
and have no arguments:

ue_print( )
ue_save( )

ue_print( )
ue_save( )

An example follows:

An example follows:

8. Add the following new user events (un-mapped). These events return a long and have
one integer argument named as seen below:

8. Add the following new user events (un-mapped). These events return a long and have
one integer argument named as seen below:

ue_delete( integer ai_del_location )


ue_insert( integer ai_ins_location )

ue_delete( integer ai_del_location )


ue_insert( integer ai_ins_location )

An example follows:

An example follows:

9. Save and close w_sheet.

9. Save and close w_sheet.

10. Because of inheritance, descendants will inherit any non-private members of their
ancestors.

10. Because of inheritance, descendants will inherit any non-private members of their
ancestors.

11. Open w_data_sheet and verify the existence of the four new events.
Lab 5 - 6

Fast Track to PowerBuilder, Part I Version 1.0

11. Open w_data_sheet and verify the existence of the four new events.
2010 Sybase, Inc.

Lab 5 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 5: User Interfaces in PowerBuilder

Module 5: User Interfaces in PowerBuilder

12. Close w_data_sheet.

12. Close w_data_sheet.

13. Verify existence of the four events on w_master_detail_sheet. You have reduced the
amount of effort necessary by half because of inheritance. Remember, code will be
added later, as we learn new concepts and techniques.

13. Verify existence of the four events on w_master_detail_sheet. You have reduced the
amount of effort necessary by half because of inheritance. Remember, code will be
added later, as we learn new concepts and techniques.

14. Before closing the Window painter, select Tools-Keyboard Shortcuts from the menu
and then add the following shortcuts:

14. Before closing the Window painter, select Tools-Keyboard Shortcuts from the menu
and then add the following shortcuts:

15. EditGo To Events Ctrl+Shift+E

15. EditGo To Events Ctrl+Shift+E

16. EditGo To Functions Ctrl+Shift+F

16. EditGo To Functions Ctrl+Shift+F

17. EditGo To Instance Variables Ctrl+Shift+I

17. EditGo To Instance Variables Ctrl+Shift+I

18. EditActivate AutoScript Ctrl+Tab

18. EditActivate AutoScript Ctrl+Tab

19. You will want to commit to memory some of the default shortcuts under Additional
Painter Shortcuts. While you will not immediately understand their use, as we start
into modules where coding is involved, you will use these many times. Good
shortcuts to remember are:

19. You will want to commit to memory some of the default shortcuts under Additional
Painter Shortcuts. While you will not immediately understand their use, as we start
into modules where coding is involved, you will use these many times. Good
shortcuts to remember are:

a. Control Drop-down Ctrl+1

a. Control Drop-down Ctrl+1

b. Script Drop-down Ctrl+2

b. Script Drop-down Ctrl+2

c. Show/Hide Prototype Ctrl+4

c. Show/Hide Prototype Ctrl+4

20. Close any open painters.

20. Close any open painters.

Task 4: Creating Standard Visual User Objects

Task 4: Creating Standard Visual User Objects

1. View the contents of visual_controls_base and visual_controls_abstract.pbls using the


System Tree.

1. View the contents of visual_controls_base and visual_controls_abstract.pbls using the


System Tree.

2. What does the prefix of u_ stand for?

2. What does the prefix of u_ stand for?

_____________________________________________________________________

_____________________________________________________________________

3. SVUO stands for?

3. SVUO stands for?

_____________________________________________________________________

2010 Sybase, Inc.

_____________________________________________________________________

4. We provided some SVUOs in the mini-framework to save time and allow us to teach
you more concepts. We have already created User Object versions of common
Window controls like SingleLineEdit (u_sle), Radio Button (u_rb), CommandButton
(u_cb), etc.

4. We provided some SVUOs in the mini-framework to save time and allow us to teach
you more concepts. We have already created User Object versions of common
Window controls like SingleLineEdit (u_sle), Radio Button (u_rb), CommandButton
(u_cb), etc.

5. You are going to create your own DataWindow control.

5. You are going to create your own DataWindow control.

6. Right-click over the SybHealth_target in the System Tree and select New from the
context menu.

6. Right-click over the SybHealth_target in the System Tree and select New from the
context menu.

7. On the PB Object tab, select Standard Visual and then click OK.

7. On the PB Object tab, select Standard Visual and then click OK.

8. Select DataWindow (control) on the Select dialog. Click OK.

8. Select DataWindow (control) on the Select dialog. Click OK.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 7

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 7

Lab Workbook

Lab Workbook
9. You have just inherited from the PowerBuilder System Class DataWindow control, as
the title bar of the User Object painter indicates.

9. You have just inherited from the PowerBuilder System Class DataWindow control, as
the title bar of the User Object painter indicates.

10. Enable the HScrollBar and VScrollBar properties of the DataWindow control.

10. Enable the HScrollBar and VScrollBar properties of the DataWindow control.

11. On the Other property tab, set the Width to 2000 and Height to 1000.

11. On the Other property tab, set the Width to 2000 and Height to 1000.

12. Navigate to the Declare Instance Variables tab where we will add some custom
properties:

12. Navigate to the Declare Instance Variables tab where we will add some custom
properties:

Boolean
Boolean

Lab 5 - 8

ib_single_select
ib_multi_select

Boolean
Boolean

ib_single_select
ib_multi_select

13. Save your DataWindow control as u_dw in the visual_controls_base.pbl.

13. Save your DataWindow control as u_dw in the visual_controls_base.pbl.

14. Now that you have a DataWindow control, re-open w_data_sheet.

14. Now that you have a DataWindow control, re-open w_data_sheet.

15. Drag the u_dw from the System Tree on top of the w_data_sheet (on the Layout).
Resize the DataWindow so that it occupies the majority of the window. In the
Properties view, name the DataWindow control dw_data.

15. Drag the u_dw from the System Tree on top of the w_data_sheet (on the Layout).
Resize the DataWindow so that it occupies the majority of the window. In the
Properties view, name the DataWindow control dw_data.

16. Save your work and close the painter.

16. Save your work and close the painter.

17. Re-open w_master_detail_sheet.

17. Re-open w_master_detail_sheet.

18. Set the windows width to 3500 and height to 2000.

18. Set the windows width to 3500 and height to 2000.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 5 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 5: User Interfaces in PowerBuilder

2010 Sybase, Inc.

Module 5: User Interfaces in PowerBuilder

19. Drag two u_dws on top of w_master_detail_sheet in a top-to-bottom fashion. Name


the top DataWindow dw_master and the bottom dw_detail. Resize your DataWindow
controls as appropriate. Your window should look like the following:

19. Drag two u_dws on top of w_master_detail_sheet in a top-to-bottom fashion. Name


the top DataWindow dw_master and the bottom dw_detail. Resize your DataWindow
controls as appropriate. Your window should look like the following:

20. While one of the DataWindow controls has focus, check the Properties view, General
tab (scroll to the bottom) and you should see your two custom properties,
ib_single_select and ib_multi_select.

20. While one of the DataWindow controls has focus, check the Properties view, General
tab (scroll to the bottom) and you should see your two custom properties,
ib_single_select and ib_multi_select.

21. Save your work and close the painter.

21. Save your work and close the painter.

22. Allowing the user to choose where the toolbars display is a common feature. We have
created the window already. All you have to do is import it.

22. Allowing the user to choose where the toolbars display is a common feature. We have
created the window already. All you have to do is import it.

23. In the System Tree, right-click over the sybhealth.pbl and select Import

23. In the System Tree, right-click over the sybhealth.pbl and select Import

24. Navigate to the \Student folder and select w_toolbars.srw.

24. Navigate to the \Student folder and select w_toolbars.srw.

25. Click OK.

25. Click OK.

26. Open w_toolbars to see what functionality it contains.

26. Open w_toolbars to see what functionality it contains.

27. Close any open painters.

27. Close any open painters.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 9

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 9

Lab Workbook

Lab Workbook

Lab 5-2: Building SybHealth Windows

Lab 5-2: Building SybHealth Windows

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Create the Login window for SybHealth

Create the Login window for SybHealth

Create the About window for SybHealth

Create the About window for SybHealth

Create a window that reads from an INI file

Create a window that reads from an INI file

Dynamically change property settings

Dynamically change property settings

Use the PowerBuilder Timer Function and Event

Use the PowerBuilder Timer Function and Event

Description:

In this lab, you will be creating two of the basic windows for the SybHealth application
Login and About. In order to reinforce some of the concepts taught in earlier modules, you
will be asked to have the Login window read and display values from an INI file. You will
also be dynamically setting property values of controls on the Login window. Then, you
will, by using the Timer( ) function and event, set the About window so that it remains
open only for 10 seconds, then automatically closes itself.

Description:

In this lab, you will be creating two of the basic windows for the SybHealth application
Login and About. In order to reinforce some of the concepts taught in earlier modules, you
will be asked to have the Login window read and display values from an INI file. You will
also be dynamically setting property values of controls on the Login window. Then, you
will, by using the Timer( ) function and event, set the About window so that it remains
open only for 10 seconds, then automatically closes itself.

Task Outline:

Task 1: Creating the Login Window

Task Outline:

Task 1: Creating the Login Window

Lab 5 - 10

Task 2: Creating the About Window

Task 2: Creating the About Window

Task 3: Reading from INI Files / Dynamic Property Settings

Task 3: Reading from INI Files / Dynamic Property Settings

Task 4: Using the Timer Function and Event

Task 4: Using the Timer Function and Event

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 5 - 10

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 5: User Interfaces in PowerBuilder

Module 5: User Interfaces in PowerBuilder

Detailed Instructions

Detailed Instructions

Task 1: Creating the Login Window

Task 1: Creating the Login Window

2010 Sybase, Inc.

1. Using the System Tree, locate the w_response window (windows_abstract.pbl), rightclick over it, and select Inherit from on the context menu.

1. Using the System Tree, locate the w_response window (windows_abstract.pbl), rightclick over it, and select Inherit from on the context menu.

2. Change the windows Title property to SybHealth Login.

2. Change the windows Title property to SybHealth Login.

3. The finished window should look as follows in the Window painter:

3. The finished window should look as follows in the Window painter:

4. To create Login, drag from visual_controls_base, a u_st (StaticText control SVUO) to


the upper left of the window. While it still has focus, type &User Name:.

4. To create Login, drag from visual_controls_base, a u_st (StaticText control SVUO) to


the upper left of the window. While it still has focus, type &User Name:.

5. While the User Name static text control still has focus, press Ctrl-T (duplicate). Give
the second static text control text of &Password:. Repeat for the third, Database:.

5. While the User Name static text control still has focus, press Ctrl-T (duplicate). Give
the second static text control text of &Password:. Repeat for the third, Database:.

6. Size all of the static text controls so they are the same width and align their right edges
to that of the User Name text control. Use the aligning and sizing tool
(FormatAlign) discussed in the module.

6. Size all of the static text controls so they are the same width and align their right edges
to that of the User Name text control. Use the aligning and sizing tool
(FormatAlign) discussed in the module.

7. Right-justify the text of the three static text controls.

7. Right-justify the text of the three static text controls.

8. Drag, from visual_controls_base, a u_sle (SingleLineEdit SVUO) and align to the right
of the User Name static text control. Set the Width property to 1000.

8. Drag, from visual_controls_base, a u_sle (SingleLineEdit SVUO) and align to the right
of the User Name static text control. Set the Width property to 1000.

9. Ctrl-T creating two more copies of u_sle. Align the second to the right of Password
and the third to the right of Database. Name the three u_sles: sle_user, sle_pwd and
sle_db respectively.

9. Ctrl-T creating two more copies of u_sle. Align the second to the right of Password
and the third to the right of Database. Name the three u_sles: sle_user, sle_pwd and
sle_db respectively.

10. Always name your controls. Failure to do so causes confusion when coding. We
didnt have you name the StaticText controls because it is rare to need to code or
identify those controls.

10. Always name your controls. Failure to do so causes confusion when coding. We
didnt have you name the StaticText controls because it is rare to need to code or
identify those controls.

11. Set the Accelerator property of sle_user to u and sle_pwd to p. The user can press
Alt-U or Alt-P to access those controls directly.

11. Set the Accelerator property of sle_user to u and sle_pwd to p. The user can press
Alt-U or Alt-P to access those controls directly.

12. Enable sle_pwds Password property to mask characters typed into that control.

12. Enable sle_pwds Password property to mask characters typed into that control.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 11

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 11

Lab Workbook

Lab Workbook
13. Disable sle_db and turn off its Border property.

13. Disable sle_db and turn off its Border property.

14. From visual_controls_abstract, drag the u_cb_ok and u_cb_cancel into locations as
shown above. Name them cb_ok and cb_cancel respectively. Disable the OK button.

14. From visual_controls_abstract, drag the u_cb_ok and u_cb_cancel into locations as
shown above. Name them cb_ok and cb_cancel respectively. Disable the OK button.

15. From visual_controls_base, drag a u_pb (PictureButton) just to the right of sle_db.
Name this control pb_chg_db and set the PictureName property to DatabaseProfile5!.
Set the PowerTipText property to a value of: Change current database.

15. From visual_controls_base, drag a u_pb (PictureButton) just to the right of sle_db.
Name this control pb_chg_db and set the PictureName property to DatabaseProfile5!.
Set the PowerTipText property to a value of: Change current database.

16. Set the windows Width property to 1965 and the Height to 430.

16. Set the windows Width property to 1965 and the Height to 430.

17. Click FormatTab Order (or the Tab Order icon on the PainterBar). Set the tabs in
the order of: sle_user, sle_pwd, cb_ok, cb_cancel and the remaining controls to a
value of 0 (zero). Remember, a value of 0 does not mean the control is disabled, it
means the user cannot tab there. They can always click a control with a tab stop of 0.

17. Click FormatTab Order (or the Tab Order icon on the PainterBar). Set the tabs in
the order of: sle_user, sle_pwd, cb_ok, cb_cancel and the remaining controls to a
value of 0 (zero). Remember, a value of 0 does not mean the control is disabled, it
means the user cannot tab there. They can always click a control with a tab stop of 0.

18. Click the Preview icon on the PainterBar. Running this Preview would not execute
any code you may have in your windows. Your window should look similar to the
following:

18. Click the Preview icon on the PainterBar. Running this Preview would not execute
any code you may have in your windows. Your window should look similar to the
following:

19. Save your window as w_login in the sybhealth.pbl.

19. Save your window as w_login in the sybhealth.pbl.

Task 2: Creating the About Window

Lab 5 - 12

Task 2: Creating the About Window

1. Using the System Tree, right- click over w_response window (windows_abstract.pbl),
and select Inherit from on the context menu.

1. Using the System Tree, right- click over w_response window (windows_abstract.pbl),
and select Inherit from on the context menu.

2. Change the windows Title property to About SybHealth.

2. Change the windows Title property to About SybHealth.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 5 - 12

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 5: User Interfaces in PowerBuilder

Module 5: User Interfaces in PowerBuilder

3. The finished window should look as follows in the Window painter:

3. The finished window should look as follows in the Window painter:

4. To create About, drag from visual_controls_base, a u_p (Picture Control SVUO) to the
upper left of the window. While it still has focus, set its name property to p_logo.

4. To create About, drag from visual_controls_base, a u_p (Picture Control SVUO) to the
upper left of the window. While it still has focus, set its name property to p_logo.

5. Assign the PictureName property by clicking the ellipsis button () and browsing to
your Student directory. Select the healthcare3.jpg. Notice the PictureName property
will contain the fully-qualified directory and name. This is dangerous. Never fullyqualify a resource like a picture, icon, etc. Delete the directory from the PictureName
property, leaving only healthcare3.jpg. PowerBuilder will find the file because it
exists in the same directory you are working in.

5. Assign the PictureName property by clicking the ellipsis button () and browsing to
your Student directory. Select the healthcare3.jpg. Notice the PictureName property
will contain the fully-qualified directory and name. This is dangerous. Never fullyqualify a resource like a picture, icon, etc. Delete the directory from the PictureName
property, leaving only healthcare3.jpg. PowerBuilder will find the file because it
exists in the same directory you are working in.

6. Set p_logos PowerTipText to SybHealth Patient Management System. The


OriginalSize property is typically enabled.

6. Set p_logos PowerTipText to SybHealth Patient Management System. The


OriginalSize property is typically enabled.

7. Any time you use a resource (picture, icon, cursor), you should put that resources
location in your resource file. Using the File Editor as we did in Module 2, open the
SybHealth.pbr file and add the following as a new line item:

7. Any time you use a resource (picture, icon, cursor), you should put that resources
location in your resource file. Using the File Editor as we did in Module 2, open the
SybHealth.pbr file and add the following as a new line item:

C:\Sybase Courses\DEV134\Student\healthcare3.jpg

2010 Sybase, Inc.

C:\Sybase Courses\DEV134\Student\healthcare3.jpg

8. To the right of the picture control you will drag a u_st. While it has focus, type
SybHealth, Incorporated.

8. To the right of the picture control you will drag a u_st. While it has focus, type
SybHealth, Incorporated.

9. While the static text control still has focus, press Ctrl-T (duplicate). Give the second
static text control text of Patient Management System. Repeat for Version 1.0 and
Copyrighted, DaveCo, Inc.. Make all the static text controls have the same width as
that of Patient Management System. Then align all static text left edges. Use the
aligning and sizing tool where possible. Center-justify their text.

9. While the static text control still has focus, press Ctrl-T (duplicate). Give the second
static text control text of Patient Management System. Repeat for Version 1.0 and
Copyrighted, DaveCo, Inc.. Make all the static text controls have the same width as
that of Patient Management System. Then align all static text left edges. Use the
aligning and sizing tool where possible. Center-justify their text.

10. Set the windows Width to 1615 and Height to 550.

10. Set the windows Width to 1615 and Height to 550.

11. If using PowerBuilder 11 or greater, set the windows Transparency property to 10,
OpenAnimation to centeranimation!, CloseAnimation to fadeanimation! and
Animation Time to 500.

11. If using PowerBuilder 11 or greater, set the windows Transparency property to 10,
OpenAnimation to centeranimation!, CloseAnimation to fadeanimation! and
Animation Time to 500.

12. Save your window as w_about in the sybhealth.pbl.

12. Save your window as w_about in the sybhealth.pbl.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 13

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 13

Lab Workbook

Lab Workbook
13. Using the System Tree, right-click w_about and Run/Preview. You should see the
following:

13. Using the System Tree, right-click w_about and Run/Preview. You should see the
following:

14. Close the Preview and any open painters.

14. Close the Preview and any open painters.

Task 3: Reading from INI Files / Dynamic Property Settings

Lab 5 - 14

Task 3: Reading from INI Files / Dynamic Property Settings

1. Recall that you looked at the SybHealth.ini file in the lab for Module 2. Open that file
again using the File Editor.

1. Recall that you looked at the SybHealth.ini file in the lab for Module 2. Open that file
again using the File Editor.

2. You will be reading from the DBMS, LogId, and Database keys in this task and
writing their values to the Login window controls and variables for use later when we
write database connection logic.

2. You will be reading from the DBMS, LogId, and Database keys in this task and
writing their values to the Login window controls and variables for use later when we
write database connection logic.

3. Re-open w_login.

3. Re-open w_login.

4. When you are about to write code, you should always ask yourself two questions. In
what object am I going to put this code, and in what event of that object. Then, use the
script painter to position yourself to that location.

4. When you are about to write code, you should always ask yourself two questions. In
what object am I going to put this code, and in what event of that object. Then, use the
script painter to position yourself to that location.

5. Go the w_logins Open event.

5. Go the w_logins Open event.

6. Code the Open to read LogId key from the sybhealth.ini file and write its value to
sle_users Text property.

6. Code the Open to read LogId key from the sybhealth.ini file and write its value to
sle_users Text property.

7. Do the same reading the Database key and writing to sle_dbs Text property.

7. Do the same reading the Database key and writing to sle_dbs Text property.

8. Declare a String Instance variable on w_login named is_dbms.

8. Declare a String Instance variable on w_login named is_dbms.

9. Back in the Open event, read one more time from the DBMS key of the INI file,
placing the returned value into is_dbms.

9. Back in the Open event, read one more time from the DBMS key of the INI file,
placing the returned value into is_dbms.

10. Code for your Open event should look as follows:

10. Code for your Open event should look as follows:

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 5 - 14

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 5: User Interfaces in PowerBuilder

2010 Sybase, Inc.

Module 5: User Interfaces in PowerBuilder

11. Using the System Tree, Run/Preview w_login. It should look as follows:

11. Using the System Tree, Run/Preview w_login. It should look as follows:

12. Close the running window.

12. Close the running window.

13. Next, you are going to dynamically set some control properties. Since we are reading
the User Name from the INI file, once the user has entered his password, dynamically
enable the OK button.

13. Next, you are going to dynamically set some control properties. Since we are reading
the User Name from the INI file, once the user has entered his password, dynamically
enable the OK button.

14. You could code the Modified event of sle_pwd, but that would imply that the user
types in his password and then tabs. If the user doesnt tab, the OK button would
remain disabled. Review Lab 3 where you created a mapped user event ue_keydown.
That might be a better solution for this example.

14. You could code the Modified event of sle_pwd, but that would imply that the user
types in his password and then tabs. If the user doesnt tab, the OK button would
remain disabled. Review Lab 3 where you created a mapped user event ue_keydown.
That might be a better solution for this example.

15. In the Script view, navigate to sle_pwd. Add a new User Event named ue_keydown.
Map this event to pbm_keydown.

15. In the Script view, navigate to sle_pwd. Add a new User Event named ue_keydown.
Map this event to pbm_keydown.

16. Code the new event as follows:

16. Code the new event as follows:

17. Run/Preview w_login and test your work.

17. Run/Preview w_login and test your work.

18. You saw that the OK button didnt activate until you pressed a key the second time.

18. You saw that the OK button didnt activate until you pressed a key the second time.

19. Go back to the Script view for sle_pwd.

19. Go back to the Script view for sle_pwd.

20. Create another new event ue_keyup. Map this event to pbm_keyup.

20. Create another new event ue_keyup. Map this event to pbm_keyup.

21. Cut the code from your ue_keydown and paste into ue_keyup.

21. Cut the code from your ue_keydown and paste into ue_keyup.

22. Delete the ue_keydown event.

22. Delete the ue_keydown event.

23. Test your work.

23. Test your work.

24. Next script the PictureButton, pb_chg_db. If the user clicks that button, enable the
sle_db control by setting the appropriate property with code and then
programmatically set focus to sle_db. Look up the SetFocus( ) function in WinHelp to
assist with this step. This feature will allow the user to change the database they wish
to connect to.

24. Next script the PictureButton, pb_chg_db. If the user clicks that button, enable the
sle_db control by setting the appropriate property with code and then
programmatically set focus to sle_db. Look up the SetFocus( ) function in WinHelp to
assist with this step. This feature will allow the user to change the database they wish
to connect to.

25. In sle_dbs Modified event, disable the control again.

25. In sle_dbs Modified event, disable the control again.

26. Test your work.

26. Test your work.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 15

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 15

Lab Workbook

Lab 5 - 16

Lab Workbook
27. Have you noticed that when you have SingleLineEdit controls that contain text, when
focus is given to them, the existing text is not highlighted? This makes it difficult
when the user wants to change the text. This one Login window has three
SingleLineEdit controls. Would you want to put the code to highlight existing text in
three places, or just one? Which object will you put this code in?

27. Have you noticed that when you have SingleLineEdit controls that contain text, when
focus is given to them, the existing text is not highlighted? This makes it difficult
when the user wants to change the text. This one Login window has three
SingleLineEdit controls. Would you want to put the code to highlight existing text in
three places, or just one? Which object will you put this code in?

_____________________________________________________________________

_____________________________________________________________________

28. Close w_login.

28. Close w_login.

29. Open u_sle (visual_controls_base).

29. Open u_sle (visual_controls_base).

30. Navigate to the GetFocus event.

30. Navigate to the GetFocus event.

31. Code this event to highlight any text that is there. Using WinHelp, look up the
SelectText function and the Len function. Remember, in PowerBuilder, we are mainly
one-based, so you will want to select the text starting at position 1 and thru the end
(the length) of the existing text. Be sure to think generic. Use your pronouns.

31. Code this event to highlight any text that is there. Using WinHelp, look up the
SelectText function and the Len function. Remember, in PowerBuilder, we are mainly
one-based, so you will want to select the text starting at position 1 and thru the end
(the length) of the existing text. Be sure to think generic. Use your pronouns.

32. A solution follows:

32. A solution follows:

33. Close u_sle.

33. Close u_sle.

34. Open u_cb_cancel (visual_controls_abstract.pbl).

34. Open u_cb_cancel (visual_controls_abstract.pbl).

35. Navigate to the Clicked event.

35. Navigate to the Clicked event.

36. A cancel button will typically close its associated window. Write the code to do so,
again thinking generically.

36. A cancel button will typically close its associated window. Write the code to do so,
again thinking generically.

37. The solution follows:

37. The solution follows:

38. Close any open painters.

38. Close any open painters.

39. These last few steps have been building up your framework. There is no reason these
objects cant be reused later when you have returned and started working on your own
applications. Bear in mind that you can also re-factor existing applications to use
SVUOs.

39. These last few steps have been building up your framework. There is no reason these
objects cant be reused later when you have returned and started working on your own
applications. Bear in mind that you can also re-factor existing applications to use
SVUOs.

40. Close w_login.

40. Close w_login.

41. In the System Tree, right-click and select Edit Source

41. In the System Tree, right-click and select Edit Source

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 5 - 16

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 5: User Interfaces in PowerBuilder

2010 Sybase, Inc.

Module 5: User Interfaces in PowerBuilder

42. A sample is seen below:

42. A sample is seen below:

43. If you used native controls initially, before you created SVUOs, you can always refactor the application. Edit Source and then Replace all occurrences of (for example)
singlelineedit with u_sle. You would want to replace all occurrences, not just those
shown above. But be safe. On the replace dialog, click the Replace button, not the
Replace All.

43. If you used native controls initially, before you created SVUOs, you can always refactor the application. Edit Source and then Replace all occurrences of (for example)
singlelineedit with u_sle. You would want to replace all occurrences, not just those
shown above. But be safe. On the replace dialog, click the Replace button, not the
Replace All.

44. Close the Source editor.

44. Close the Source editor.

45. Run/Preview w_login to test your work.

45. Run/Preview w_login to test your work.

46. Re-open w_login. You can use FileRecent Objects to quickly re-open objects.

46. Re-open w_login. You can use FileRecent Objects to quickly re-open objects.

47. Declare a Boolean Instance variable named ib_chg_db on the w_login.

47. Declare a Boolean Instance variable named ib_chg_db on the w_login.

48. In the sle_dbs Modified event, add a statement to set ib_chg_db to true.

48. In the sle_dbs Modified event, add a statement to set ib_chg_db to true.

49. Using the SetProfileString( ) function taught in Module 4, code the Clicked event of
the OK button to write back out to the sybhealth.ini file the values entered into
sle_user and sle_db, but only if it changed. After writing to the INI file, close
w_login.

49. Using the SetProfileString( ) function taught in Module 4, code the Clicked event of
the OK button to write back out to the sybhealth.ini file the values entered into
sle_user and sle_db, but only if it changed. After writing to the INI file, close
w_login.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 17

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 5 - 17

Lab Workbook

Lab Workbook
50. A solution follows:

50. A solution follows:

51. Run/Preview to test your work. You will need to run several times to thoroughly test.
Change the user name and database name, making sure those changes are written back
to the INI file. Be sure that after testing, you run to put the LogId back to a value of
SybInsure and the Database back to a value of SybHealth.

51. Run/Preview to test your work. You will need to run several times to thoroughly test.
Change the user name and database name, making sure those changes are written back
to the INI file. Be sure that after testing, you run to put the LogId back to a value of
SybInsure and the Database back to a value of SybHealth.

52. Close any running windows and any open painters.

52. Close any running windows and any open painters.

Task 4: Using the Timer Function and Event

Lab 5 - 18

Task 4: Using the Timer Function and Event

1. Re-open w_about.

1. Re-open w_about.

2. Navigate to the windows Open event.

2. Navigate to the windows Open event.

3. Add a statement calling the PowerScript Timer( ) function, passing 10 (seconds) to the
function.

3. Add a statement calling the PowerScript Timer( ) function, passing 10 (seconds) to the
function.

4. This statement starts an internal timer object, that every 10 seconds will fire w_abouts
Timer event. Dont confuse the Timer( ) function with the Timer event. The Timer
event is where you will code what you wish to happen.

4. This statement starts an internal timer object, that every 10 seconds will fire w_abouts
Timer event. Dont confuse the Timer( ) function with the Timer event. The Timer
event is where you will code what you wish to happen.

5. Navigate to the Timer event of w_about.

5. Navigate to the Timer event of w_about.

6. Code the Timer event to close w_about be generic.

6. Code the Timer event to close w_about be generic.

7. Save your work.

7. Save your work.

8. Using Run/Preview, test w_about. Remember to wait 10 seconds before the window
will automatically close itself.

8. Using Run/Preview, test w_about. Remember to wait 10 seconds before the window
will automatically close itself.

9. In the Properties view, disable the Control Menu. Most people associate the Control
Menu with the drop down menu that appears when you click the icon in a windows
upper left corner. The response window has no icon displaying, however.

9. In the Properties view, disable the Control Menu. Most people associate the Control
Menu with the drop down menu that appears when you click the icon in a windows
upper left corner. The response window has no icon displaying, however.

10. Run/Preview the w_about window. What did disabling the Control Menu property do?

10. Run/Preview the w_about window. What did disabling the Control Menu property do?

11. Close the running window and any open painters.

11. Close the running window and any open painters.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 5 - 18

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 6: Working with Menus

Module 6: Working with Menus

Module 6: Working with Menus

Module 6: Working with Menus

Lab 6-1: Creating a Menu Hierarchy

Lab 6-1: Creating a Menu Hierarchy

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Create a menu hierarchy to add to your mini-framework

Create a menu hierarchy to add to your mini-framework

Move menu items around in descendant menus

Move menu items around in descendant menus

Description:

In this lab, you will add some menu classes to your framework. The base menu will
contain typical menu options seen in the majority of applications. From there, you will
inherit and create a menu to be used on your MDI frame window. Unlike Microsoft who
displays all items (though disabled), when the MDI frame is active, we will hide all
irrelevant choices for the frame window. You will also create a menu that will be the
ancestor for all MDI sheets you will open. To gain the experience, we will add a new
menu item to the sheet menu so that you will have seen what it takes to move menu items
in a descendant.

Description:

In this lab, you will add some menu classes to your framework. The base menu will
contain typical menu options seen in the majority of applications. From there, you will
inherit and create a menu to be used on your MDI frame window. Unlike Microsoft who
displays all items (though disabled), when the MDI frame is active, we will hide all
irrelevant choices for the frame window. You will also create a menu that will be the
ancestor for all MDI sheets you will open. To gain the experience, we will add a new
menu item to the sheet menu so that you will have seen what it takes to move menu items
in a descendant.

Task Outline:

Task 1: Creating a Menus Framework PBL

Task Outline:

Task 1: Creating a Menus Framework PBL

2010 Sybase, Inc.

Task 2: Creating the m_master Base Menu

Task 2: Creating the m_master Base Menu

Task 3: Creating the m_frame Menu

Task 3: Creating the m_frame Menu

Task 4: Creating the m_sheet Menu

Task 4: Creating the m_sheet Menu

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 1

Module 6 Lab: Working with Menus

Module 6 Lab: Working with Menus

Detailed Instructions

Detailed Instructions

Task 1: Creating a Menus Framework PBL

Task 1: Creating a Menus Framework PBL

1.

Menus are reusable objects, reusable across multiple applications. In order for you to
share menus across multiple applications, it would be best to put them in a separate
PBL (or PBLs), that can be added to the Library List of future applications.

1.

Menus are reusable objects, reusable across multiple applications. In order for you to
share menus across multiple applications, it would be best to put them in a separate
PBL (or PBLs), that can be added to the Library List of future applications.

2.

Create one new PBL to hold your menus. Do so by going to Properties of your
SybHealth_target (via the System Tree). This takes you back to the Library List.
Click the New button and be sure you navigate to your C:\Sybase
Courses\DEV134\Student\Framework directory. Name the new library menus.pbl.

2.

Create one new PBL to hold your menus. Do so by going to Properties of your
SybHealth_target (via the System Tree). This takes you back to the Library List.
Click the New button and be sure you navigate to your C:\Sybase
Courses\DEV134\Student\Framework directory. Name the new library menus.pbl.

3.

Click OK to close the target properties dialog.

3.

Click OK to close the target properties dialog.

Task 2: Creating the m_master Base Menu

Lab 6 - 2

Task 2: Creating the m_master Base Menu

1.

Over your SybHealth_target in the System Tree, right-click and select New from
the context menu.

1.

Over your SybHealth_target in the System Tree, right-click and select New from
the context menu.

2.

On the PB Object tab of the New dialog, select Menu and click OK.

2.

On the PB Object tab of the New dialog, select Menu and click OK.

3.

Locate the Tree view in the Menu painter (where you see untitled0). This is your
work area, where you build your menus.

3.

Locate the Tree view in the Menu painter (where you see untitled0). This is your
work area, where you build your menus.

4.

The view just to the right is called the WYSIWYG menu view. As you build the
menu in the Tree view, you can see what your users will see in the WYSIWYG view.
You could build the menu from the WYSIWYG view, but it is not recommended.

4.

The view just to the right is called the WYSIWYG menu view. As you build the
menu in the Tree view, you can see what your users will see in the WYSIWYG view.
You could build the menu from the WYSIWYG view, but it is not recommended.

5.

The view at the bottom is the typical Script view. Notice this is one painter that does
not have the typical Declare Instance Variables tab. That does not mean you cannot
put Instance Variables on a menu.

5.

The view at the bottom is the typical Script view. Notice this is one painter that does
not have the typical Declare Instance Variables tab. That does not mean you cannot
put Instance Variables on a menu.

6.

In the Script view, click on the first drop down. There you can see the Declare option.
Choosing this option puts you on the Declare Instance Variables view.

6.

In the Script view, click on the first drop down. There you can see the Declare option.
Choosing this option puts you on the Declare Instance Variables view.

7.

Over untitled0 in the Tree view, right-click and select Insert Submenu Item. You are
building the Menu Bar.

7.

Over untitled0 in the Tree view, right-click and select Insert Submenu Item. You are
building the Menu Bar.

8.

Type &File. Press the Tab key (DO NOT PRESS THE ENTER KEY). Tabbing
opens a new menu item without you having to constantly right-click.

8.

Type &File. Press the Tab key (DO NOT PRESS THE ENTER KEY). Tabbing
opens a new menu item without you having to constantly right-click.

9.

Type &Edit. Press the Tab key.

9.

Type &Edit. Press the Tab key.

10. Type &Window. Press the Tab key.

10. Type &Window. Press the Tab key.

11. Type &Help. Now you may press ENTER as this is the last menu item on the Menu
Bar.

11. Type &Help. Now you may press ENTER as this is the last menu item on the Menu
Bar.

12. Save your menu in the menus.pbl as m_master.

12. Save your menu in the menus.pbl as m_master.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 6 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 6: Working with Menus

2010 Sybase, Inc.

Module 6: Working with Menus

13. Your WYSIWYG should look as follows:

13. Your WYSIWYG should look as follows:

14. Next, you will build the drop down menus, beginning with File. In the Tree view of
the painter, right-click over File and select Insert Submenu Item. Enter the following
items: &New, &Open, &Close, - (A dash is a separator line, allowing you to
logically group menu items within a drop down. Do not enter the quotes.), &Save,
Save &As, - (separator), Page Set&up, Print Pre&view, &Print, -, E&xit.

14. Next, you will build the drop down menus, beginning with File. In the Tree view of
the painter, right-click over File and select Insert Submenu Item. Enter the following
items: &New, &Open, &Close, - (A dash is a separator line, allowing you to
logically group menu items within a drop down. Do not enter the quotes.), &Save,
Save &As, - (separator), Page Set&up, Print Pre&view, &Print, -, E&xit.

15. In the menu items properties, add the following Shortcut keys: Ctrl+F4 for Close,
Ctrl+S for Save, Ctrl+P for Print and Alt+F4 for Exit.

15. In the menu items properties, add the following Shortcut keys: Ctrl+F4 for Close,
Ctrl+S for Save, Ctrl+P for Print and Alt+F4 for Exit.

16. On the Exit menu item, put in Exits the application for the MicroHelp property.
You can add other MicroHelp as time permits.

16. On the Exit menu item, put in Exits the application for the MicroHelp property.
You can add other MicroHelp as time permits.

17. WYSIWYG should look as follows:

17. WYSIWYG should look as follows:

18. Build the drop down for Edit next with the following items: Cu&t, &Copy, &Paste,
-, &Find, &Go To

18. Build the drop down for Edit next with the following items: Cu&t, &Copy, &Paste,
-, &Find, &Go To

19. Add the following Shortcuts: Ctrl+C for Copy, Ctrl+V for Paste, Ctrl+X for Cut,
Ctrl+F for Find, Ctrl+G for Go To.

19. Add the following Shortcuts: Ctrl+C for Copy, Ctrl+V for Paste, Ctrl+X for Cut,
Ctrl+F for Find, Ctrl+G for Go To.

20. Verify your work:

20. Verify your work:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 3

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 3

Module 6 Lab: Working with Menus

Lab 6 - 4

Module 6 Lab: Working with Menus

21. Save your menu.

21. Save your menu.

22. Under Window, add the following: Tile &Vertical, Tile &Horizontal, &Layer,
&Cascade, -, Arrange &Icons, -, Close &All.

22. Under Window, add the following: Tile &Vertical, Tile &Horizontal, &Layer,
&Cascade, -, Arrange &Icons, -, Close &All.

23. Verify:

23. Verify:

24. Under Help, add the following: &SybHealth Help, &Contact Us, -, &About

24. Under Help, add the following: &SybHealth Help, &Contact Us, -, &About

25. Verify:

25. Verify:

26. Save your work.

26. Save your work.

27. In the Tree view, go back to FileNew and Insert a submenu item. This will create a
cascaded menu. Name the new item &Claim, followed by a separator, then &Patient
and then P&olicy. The WYSIWYG should now look as follows:

27. In the Tree view, go back to FileNew and Insert a submenu item. This will create a
cascaded menu. Name the new item &Claim, followed by a separator, then &Patient
and then P&olicy. The WYSIWYG should now look as follows:

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 6 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 6: Working with Menus

2010 Sybase, Inc.

Module 6: Working with Menus

28. In the Tree view, go back to FileOpen and Insert a submenu item. This will create
a cascaded menu. Name the new item &Doctors List, followed by a separator, then
Claims &Search, another separator and then &Patient Details, another separator and
then &Reports. The WYSIWYG should now look as follows:

28. In the Tree view, go back to FileOpen and Insert a submenu item. This will create
a cascaded menu. Name the new item &Doctors List, followed by a separator, then
Claims &Search, another separator and then &Patient Details, another separator and
then &Reports. The WYSIWYG should now look as follows:

29. Now, make the menu a contemporary-style menu (PowerBuilder 10.5 and greater).
Select m_master from the Tree view of the Menu painter and then in Properties,
change the Menu Style property.

29. Now, make the menu a contemporary-style menu (PowerBuilder 10.5 and greater).
Select m_master from the Tree view of the Menu painter and then in Properties,
change the Menu Style property.

30. Go back to these individual menu items and put set the following MenuImage values:
Save Save!, Print Print! and Exit Exit!.

30. Go back to these individual menu items and put set the following MenuImage values:
Save Save!, Print Print! and Exit Exit!.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 5

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 5

Module 6 Lab: Working with Menus

Lab 6 - 6

Module 6 Lab: Working with Menus

31. Verify your work:

31. Verify your work:

32. Add the following MenuImages under Edit: Find Find!, Go To OutputNext!.

32. Add the following MenuImages under Edit: Find Find!, Go To OutputNext!.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 6 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 6: Working with Menus

2010 Sybase, Inc.

Module 6: Working with Menus

33. Verify:

33. Verify:

34. Save your work.

34. Save your work.

35. Next add toolbar icons to common menu items. Remember, toolbar icons are set on
the menu items Toolbar tab in the Properties view. Below, is a list of menu items
that need icons along with the icon values. Add ToolBarItemText where appropriate
and as time permits:

35. Next add toolbar icons to common menu items. Remember, toolbar icons are set on
the menu items Toolbar tab in the Properties view. Below, is a list of menu items
that need icons along with the icon values. Add ToolBarItemText where appropriate
and as time permits:

a. Save: Save!

a. Save: Save!

b. Exit: Exit!

b. Exit: Exit!

c. Find: Find!

c. Find: Find!

d. Go To: OutputNext!

d. Go To: OutputNext!

36. Notice the order of the toolbar icons in the WYSIWYG view. They are out of order.
The Exit icon should always be last on the toolbar.

36. Notice the order of the toolbar icons in the WYSIWYG view. They are out of order.
The Exit icon should always be last on the toolbar.

37. In the Tree view, click on Exit. On the Toolbar tab of Properties, set the
ToolBarItemOrder to 1. This will put the Exit icon on the end of the toolbar. Also set
the ToolBarItemSpace to 1. This puts a small break between the Exit icon and the
others.

37. In the Tree view, click on Exit. On the Toolbar tab of Properties, set the
ToolBarItemOrder to 1. This will put the Exit icon on the end of the toolbar. Also set
the ToolBarItemSpace to 1. This puts a small break between the Exit icon and the
others.

38. Next, click on the root item, m_master, in the Tree view. On the Properties view,
change the Toolbar Style to a contemporary toolbar.

38. Next, click on the root item, m_master, in the Tree view. On the Properties view,
change the Toolbar Style to a contemporary toolbar.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 7

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 7

Module 6 Lab: Working with Menus

Module 6 Lab: Working with Menus

39. Note the differences in the WYSIWYG view between traditional and contemporary
toolbars.

39. Note the differences in the WYSIWYG view between traditional and contemporary
toolbars.

40. Save m_master and close the painter.

40. Save m_master and close the painter.

Task 3: Creating the m_frame Menu

Task 3: Creating the m_frame Menu

1.

Over m_master in the System Tree, right-click and select Inherit from on the context
menu.

1.

Over m_master in the System Tree, right-click and select Inherit from on the context
menu.

2.

Save this menu as m_frame in the menus.pbl.

2.

Save this menu as m_frame in the menus.pbl.

3.

Rather than do what Microsoft does, which is to show the menu items on the frame
window, but disable them, you are going to hide them. The items that should display
when the MDI frame window is active are File and Help.

3.

Rather than do what Microsoft does, which is to show the menu items on the frame
window, but disable them, you are going to hide them. The items that should display
when the MDI frame window is active are File and Help.

4.

Using menu item properties hide Edit and Window on the Menu Bar. Also hide the
following menu items on the File drop down: Start with the Separator under the
Close menu item, down to the Print menu item. Hide everything in-between.

4.

Using menu item properties hide Edit and Window on the Menu Bar. Also hide the
following menu items on the File drop down: Start with the Separator under the
Close menu item, down to the Print menu item. Hide everything in-between.

5.

Those items still appear in the WYSIWYG, but will not be there at runtime. Help will
move left to occupy that space.

5.

Those items still appear in the WYSIWYG, but will not be there at runtime. Help will
move left to occupy that space.

6.

The toolbar icons for Save, Print, Find and Go To do not need to be visible when only
the frame window is active. Disable their ToolBarItemVisible property.

6.

The toolbar icons for Save, Print, Find and Go To do not need to be visible when only
the frame window is active. Disable their ToolBarItemVisible property.

7.

Verify:

7.

Verify:

8.

Save your work and close the painter.

8.

Save your work and close the painter.

Task 4: Creating the m_sheet Menu

Lab 6 - 8

Task 4: Creating the m_sheet Menu

1.

Over m_master in the System Tree, right-click and select Inherit from on the context
menu.

1.

Over m_master in the System Tree, right-click and select Inherit from on the context
menu.

2.

Save this menu as m_sheet in the menus.pbl.

2.

Save this menu as m_sheet in the menus.pbl.

3.

What you are about to do is merely an exercise. The item you will add could have
been put into m_master, but you will be learning of a common PowerBuilder menu
property, ShiftToRight.

3.

What you are about to do is merely an exercise. The item you will add could have
been put into m_master, but you will be learning of a common PowerBuilder menu
property, ShiftToRight.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 6 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 6: Working with Menus

2010 Sybase, Inc.

Module 6: Working with Menus

4.

Over m_sheet in the Tree view of the Menu Painter, right-click and select Insert
Submenu Item. Name the new menubar item &Tools.

4.

Over m_sheet in the Tree view of the Menu Painter, right-click and select Insert
Submenu Item. Name the new menubar item &Tools.

5.

In the Tree view, attempt to drag the Tools item between Edit and Window. Though
it appears to be draggable, you will see an error message in the PowerBuilder status
bar that This item is inheritable and cannot be deleted or moved. This is expected.
Menu items that are inherited cannot be moved.

5.

In the Tree view, attempt to drag the Tools item between Edit and Window. Though
it appears to be draggable, you will see an error message in the PowerBuilder status
bar that This item is inheritable and cannot be deleted or moved. This is expected.
Menu items that are inherited cannot be moved.

6.

To place the menu items in the GUI-accepted position, PowerBuilder menu items
have a ShiftToRight property.

6.

To place the menu items in the GUI-accepted position, PowerBuilder menu items
have a ShiftToRight property.

7.

In the Tree view of the Menu Painter, click on Window and then in Properties enable
ShiftToRight. Look at the WYSIWYG to see the impact. Window is now at the end
of the menu bar.

7.

In the Tree view of the Menu Painter, click on Window and then in Properties enable
ShiftToRight. Look at the WYSIWYG to see the impact. Window is now at the end
of the menu bar.

8.

Repeat the above step by shifting the Help menu item. Tools have now been shifted
into the correct location.

8.

Repeat the above step by shifting the Help menu item. Tools have now been shifted
into the correct location.

9.

In the Tree view, right-click over Tools and select Insert Submenu Item. Add the
following items: &Insert, &Delete, -, &Toolbars, &Options, -, &Export
Data

9.

In the Tree view, right-click over Tools and select Insert Submenu Item. Add the
following items: &Insert, &Delete, -, &Toolbars, &Options, -, &Export
Data

10. For the Insert menu item, set the MenuImage (General Tab of Properties), and
ToolBarItemName properties to use Insert!. For the Delete menu item, use
DeleteRow! for MenuImage and ToolBarItemName. For the Export Data menu item,
use Export5! for MenuImage and ToolBarItemName. Set all of the ToolBarItemText
properties appropriately.

10. For the Insert menu item, set the MenuImage (General Tab of Properties), and
ToolBarItemName properties to use Insert!. For the Delete menu item, use
DeleteRow! for MenuImage and ToolBarItemName. For the Export Data menu item,
use Export5! for MenuImage and ToolBarItemName. Set all of the ToolBarItemText
properties appropriately.

11. Set Exits ToolBarItemOrder to 2 to move that icon out to the end of the toolbar if it is
not already at the end.

11. Set Exits ToolBarItemOrder to 2 to move that icon out to the end of the toolbar if it is
not already at the end.

12. Click again on Insert and Delete menu items, setting their ToolBarItemBarIndex to a
value of 2, noting what that does by looking at the WYSIWYG.

12. Click again on Insert and Delete menu items, setting their ToolBarItemBarIndex to a
value of 2, noting what that does by looking at the WYSIWYG.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 9

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 9

Module 6 Lab: Working with Menus

Lab 6 - 10

Module 6 Lab: Working with Menus

13. Verify your work:

13. Verify your work:

14. The ShiftToRight property is somewhat mis-named. It also will shift items down, in a
drop down menu.

14. The ShiftToRight property is somewhat mis-named. It also will shift items down, in a
drop down menu.

15. In the Tree view, right-click over File and select Insert Submenu Item from the
context menu.

15. In the Tree view, right-click over File and select Insert Submenu Item from the
context menu.

16. Name the new item Save A&ll.

16. Name the new item Save A&ll.

17. Use the ShiftToRight property (which in this case will shift down), all of the menu
items under File starting at the Separator after Save As

17. Use the ShiftToRight property (which in this case will shift down), all of the menu
items under File starting at the Separator after Save As

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 6 - 10

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 6: Working with Menus

2010 Sybase, Inc.

Module 6: Working with Menus

18. Verify your work:

18. Verify your work:

19. Save the menu.

19. Save the menu.

20. Close the Menu painter and then re-open m_sheet.

20. Close the Menu painter and then re-open m_sheet.

21. It will appear that the ShiftToRight settings did not get saved. They did. This is a
painter issue. Your menu items will appear correctly when you put the menu on a
window and it displays at runtime.

21. It will appear that the ShiftToRight settings did not get saved. They did. This is a
painter issue. Your menu items will appear correctly when you put the menu on a
window and it displays at runtime.

22. Close the painter.

22. Close the painter.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 11

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 11

Module 6 Lab: Working with Menus

Module 6 Lab: Working with Menus

Lab 6-2: Coding Basic Menu Items

Lab 6-2: Coding Basic Menu Items

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Associate a menu to a window

Associate a menu to a window

Place appropriate code in common menu items

Place appropriate code in common menu items

Description:

In this lab, you will associate the menus you just created with application windows. You
will also be coding some of the common menu items.

Description:

In this lab, you will associate the menus you just created with application windows. You
will also be coding some of the common menu items.

Task Outline:

Task 1: Associating Menus to Windows

Task Outline:

Task 1: Associating Menus to Windows

Task 2: Coding Common Menu Items

Lab 6 - 12

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Coding Common Menu Items

2010 Sybase, Inc.

Lab 6 - 12

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 6: Working with Menus

Module 6: Working with Menus

Detailed Instructions

Detailed Instructions

Task 1: Associating Menus to Windows

Task 1: Associating Menus to Windows

1.

Menus are associated with windows. Open w_sheet (windows_abstract.pbl).

1.

Menus are associated with windows. Open w_sheet (windows_abstract.pbl).

2.

In the Properties view, locate the MenuName property.

2.

In the Properties view, locate the MenuName property.

3.

Click the ellipsis button () to the right of that property.

3.

Click the ellipsis button () to the right of that property.

4.

In the Select Object dialog, select the menus.pbl.

4.

In the Select Object dialog, select the menus.pbl.

5.

Then select m_sheet and click OK.

5.

Then select m_sheet and click OK.

6.

Close and save w_sheet.

6.

Close and save w_sheet.

7.

Using the System Tree, Run/Preview w_data_sheet.

7.

Using the System Tree, Run/Preview w_data_sheet.

8.

Do you see your menu? Are the items shifted into the correct location as promised?

8.

Do you see your menu? Are the items shifted into the correct location as promised?

_____________________________________________________________________
9.

_____________________________________________________________________

If you are running this lab in PowerBuilder 9 or 10, you will not see the toolbar icons.
Be aware that when using Run/Preview, you are running the application in SDI mode.
It was not until PowerBuilder 10.5 that toolbars displayed for SDI applications.

9.

10. Close the running window.

10. Close the running window.

11. If you were to run w_master_detail_sheet, would you see m_sheets menu? Why or
why not?

11. If you were to run w_master_detail_sheet, would you see m_sheets menu? Why or
why not?

_____________________________________________________________________

2010 Sybase, Inc.

If you are running this lab in PowerBuilder 9 or 10, you will not see the toolbar icons.
Be aware that when using Run/Preview, you are running the application in SDI mode.
It was not until PowerBuilder 10.5 that toolbars displayed for SDI applications.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 13

_____________________________________________________________________

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 13

Module 6 Lab: Working with Menus

Module 6 Lab: Working with Menus

12. Open w_child and/or w_response. Can you associate m_sheet with these windows?
Why or why not?

12. Open w_child and/or w_response. Can you associate m_sheet with these windows?
Why or why not?

_____________________________________________________________________

_____________________________________________________________________

13. When associating menus to windows it will not be necessary to write any code to
instantiate the menu. The window does it for you.

13. When associating menus to windows it will not be necessary to write any code to
instantiate the menu. The window does it for you.

14. Using the System Tree, right-click over w_sheet and select Edit Source from the
context menu.

14. Using the System Tree, right-click over w_sheet and select Edit Source from the
context menu.

15. In the Class Definition, look for the section named on w_sheet.create. You should see
that menus associated as we have are automatically instantiated (created) behind the
scenes by PowerBuilder. PowerBuilder also automatically destroys the menu (see the
on w_sheet.destroy section).

15. In the Class Definition, look for the section named on w_sheet.create. You should see
that menus associated as we have are automatically instantiated (created) behind the
scenes by PowerBuilder. PowerBuilder also automatically destroys the menu (see the
on w_sheet.destroy section).

16. Also, while we are here, remember in the lab for Module 4, you placed shell events
into w_sheet named: ue_delete, ue_insert, ue_save and ue_print. The fact that those
shells have already been created has bearing on upcoming tasks.

16. Also, while we are here, remember in the lab for Module 4, you placed shell events
into w_sheet named: ue_delete, ue_insert, ue_save and ue_print. The fact that those
shells have already been created has bearing on upcoming tasks.

17. Close the Source editor (Class Definition).

17. Close the Source editor (Class Definition).

Task 2: Coding Common Menu Items

Task 2: Coding Common Menu Items

1.

Re-open m_master in the menus.pbl.

1.

Re-open m_master in the menus.pbl.

2.

All coding steps in this task will have you code the default event, Clicked, of the
menu items.

2.

All coding steps in this task will have you code the default event, Clicked, of the
menu items.

3.

Script the FileSave item, generically calling the attached windows ue_save event.
Use the dot notation syntax you learned in Module 4 for firing events. You have two
options here; you can make a DYNAMIC call or a STATIC call (preferred). Two
options you have are shown below:

3.

Script the FileSave item, generically calling the attached windows ue_save event.
Use the dot notation syntax you learned in Module 4 for firing events. You have two
options here; you can make a DYNAMIC call or a STATIC call (preferred). Two
options you have are shown below:

DYNAMIC: ParentWindow.EVENT DYNAMIC ue_save( )

DYNAMIC: ParentWindow.EVENT DYNAMIC ue_save( )

OR:

OR:

STATIC:
w_sheet
lw_sheet
lw_sheet = ParentWindow
lw_sheet.EVENT ue_save( )

STATIC:
w_sheet
lw_sheet
lw_sheet = ParentWindow
lw_sheet.EVENT ue_save( )

4.

Repeating the above step, code the FilePrint item to call ue_print( ).

4.

Repeating the above step, code the FilePrint item to call ue_print( ).

5.

Script the FileExit menu item as follows:

5.

Script the FileExit menu item as follows:

Close(ParentWindow)

Lab 6 - 14

Fast Track to PowerBuilder, Part I Version 1.0

Close(ParentWindow)

2010 Sybase, Inc.

Lab 6 - 14

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 6: Working with Menus


6.

Module 6: Working with Menus

Code WindowTile Vertical as follows:

6.

ParentWindow.ArrangeSheets(tile!)

2010 Sybase, Inc.

Code WindowTile Vertical as follows:


ParentWindow.ArrangeSheets(tile!)

7.

Using WinHelp, look up the appropriate enumerated type to the ArrangeSheets( )


function and code the remaining items under Window except for Close All.

7.

Using WinHelp, look up the appropriate enumerated type to the ArrangeSheets( )


function and code the remaining items under Window except for Close All.

8.

Save your work.

8.

Save your work.

9.

Code the HelpSybHealth Help menu item. You will not be creating a HELP file for
this application, instead, you will just have this item open the PowerBuilder help
system. In this items script, call the ShowHelp( ) PowerScript function. Look at
WinHelp for an example of how to use this function. The name of the PowerBuilder
help file is PBHLP120.hlp and is in the Student folder.

9.

Code the HelpSybHealth Help menu item. You will not be creating a HELP file for
this application, instead, you will just have this item open the PowerBuilder help
system. In this items script, call the ShowHelp( ) PowerScript function. Look at
WinHelp for an example of how to use this function. The name of the PowerBuilder
help file is PBHLP120.hlp and is in the Student folder.

10. Code HelpAbout to open w_about created in the lab for Module 5.

10. Code HelpAbout to open w_about created in the lab for Module 5.

11. Save your work.

11. Save your work.

12. Re-script the Save menu item.

12. Re-script the Save menu item.

13. Copy the code you put in the Save item to the Windows Clipboard.

13. Copy the code you put in the Save item to the Windows Clipboard.

14. Close the painter. There are reasons we always have you close painters. First, they
are a resource drain on the IDE. If you dont need them open, close them. Second,
you cannot have an ancestor and descendant objects opened at the same time.
PowerBuilder does not allow that.

14. Close the painter. There are reasons we always have you close painters. First, they
are a resource drain on the IDE. If you dont need them open, close them. Second,
you cannot have an ancestor and descendant objects opened at the same time.
PowerBuilder does not allow that.

15. Open m_sheet.

15. Open m_sheet.

16. Script the ToolsInsert item by pasting from your clipboard and then changing the
event name to ue_insert( ). Pass a value of 1 to the argument of this event.

16. Script the ToolsInsert item by pasting from your clipboard and then changing the
event name to ue_insert( ). Pass a value of 1 to the argument of this event.

17. Script ToolsDelete the same as above firing ue_delete( ). Pass a value of 1 to the
argument of this event.

17. Script ToolsDelete the same as above firing ue_delete( ). Pass a value of 1 to the
argument of this event.

18. Script ToolsToolbars to open the w_toolbars window you imported in the last
lab. Use the following code:

18. Script ToolsToolbars to open the w_toolbars window you imported in the last
lab. Use the following code:

OpenWithParm(w_toolbars, parentwindow)

OpenWithParm(w_toolbars, parentwindow)

(OpenWithParm( ) will be explained in the next module.)

(OpenWithParm( ) will be explained in the next module.)

19. Save your work.

19. Save your work.

20. Close the painter.

20. Close the painter.

21. More menu items will be coded as you build more components of the SybHealth
system.

21. More menu items will be coded as you build more components of the SybHealth
system.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 15

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 6 - 15

Module 6 Lab: Working with Menus

Lab 6 - 16

Module 6 Lab: Working with Menus

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 6 - 16

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 7: Working with MDI Applications

Module 7: Working with MDI Applications

Module 7: Working with MDI Applications

Module 7: Working with MDI Applications

Lab 7-1: Building Application Windows

Lab 7-1: Building Application Windows

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Create an MDI Frame Window

Create an MDI Frame Window

Create MDI Sheets

Create MDI Sheets

Description:

In this lab, you will build the SybHealth MDI Frame window and some of the application
sheets that will open inside of the frame.

Description:

In this lab, you will build the SybHealth MDI Frame window and some of the application
sheets that will open inside of the frame.

Task Outline:

Task 1: Creating an MDI Frame Window

Task Outline:

Task 1: Creating an MDI Frame Window

Task 2: Creating MDI Sheets

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Creating MDI Sheets

Lab 7 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 7 - 1

Module 7 Lab: Working with MDI Applications

Module 7 Lab: Working with MDI Applications

Detailed Instructions

Detailed Instructions

Task 1: Creating an MDI Frame Window

Task 1: Creating an MDI Frame Window

1.

Using the System Tree, inherit from w_master (windows_base.pbl).

1.

Using the System Tree, inherit from w_master (windows_base.pbl).

2.

In the Properties view, set the following:

2.

In the Properties view, set the following:

Title:
MenuName:
WindowType:
WindowState:

SybHealth Patient Management System


m_frame
mdihelp! (with status bar)
maximized!

Title:
MenuName:
WindowType:
WindowState:

(You must put a menu on an MDI Frame window.)

(You must put a menu on an MDI Frame window.)

3.

Controls cannot be placed on this window, or the Client Area (where sheets are
opened) will shrink to the size of a dot. Controls will go on the sheets that open
inside of the MDI Frame window.

3.

Controls cannot be placed on this window, or the Client Area (where sheets are
opened) will shrink to the size of a dot. Controls will go on the sheets that open
inside of the MDI Frame window.

4.

Save your new window as w_frame in the sybhealth.pbl and close the painter.

4.

Save your new window as w_frame in the sybhealth.pbl and close the painter.

5.

Open the a_sybhealth Application object.

5.

Open the a_sybhealth Application object.

6.

Navigate to the Open event.

6.

Navigate to the Open event.

7.

Change the code there to Open(w_frame).

7.

Change the code there to Open(w_frame).

8.

Run the application. To run, you can either right-click over the SybHealth_target in
the System Tree and select Run, or you can click the Running Man icon on the
PowerBar, or you can click RunRun sybhealth_target from the menu.

8.

Run the application. To run, you can either right-click over the SybHealth_target in
the System Tree and select Run, or you can click the Running Man icon on the
PowerBar, or you can click RunRun sybhealth_target from the menu.

9.

The MDI Frame window will appear.

9.

The MDI Frame window will appear.

10. Click the Exit icon on your SybHealth toolbar. The application will terminate and
you will be returned to your Application object Open event.

10. Click the Exit icon on your SybHealth toolbar. The application will terminate and
you will be returned to your Application object Open event.

11. Close the Application object.

11. Close the Application object.

12. Now that you have an MDI Frame window (w_frame), you can go back to your
menu(s) and code some additional menu items.

12. Now that you have an MDI Frame window (w_frame), you can go back to your
menu(s) and code some additional menu items.

13. Re-open m_master.

13. Re-open m_master.

14. Script the FileClose item to get a handle to the active sheet within the frame
window and then pass that handle to the Close( ) function. A solution for this was
provided in the Student Guide in Module 6.

14. Script the FileClose item to get a handle to the active sheet within the frame
window and then pass that handle to the Close( ) function. A solution for this was
provided in the Student Guide in Module 6.

15. Script FileExit. The code there is working right now, but it is possible that it will
not continue to work properly depending on your use of the menu hierarchy. Change
the code to:

15. Script FileExit. The code there is working right now, but it is possible that it will
not continue to work properly depending on your use of the menu hierarchy. Change
the code to:

Close(w_frame)

Lab 7 - 2

SybHealth Patient Management System


m_frame
mdihelp! (with status bar)
maximized!

Close(w_frame)

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 7 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 7: Working with MDI Applications

Module 7: Working with MDI Applications

16. Script WindowClose All. This item will close all of the sheets that have been
opened within the MDI Frame.

16. Script WindowClose All. This item will close all of the sheets that have been
opened within the MDI Frame.

a. Declare a variable of type w_sheet

a. Declare a variable of type w_sheet

b. Assign to the above variable by calling w_frames GetActiveSheet( ) function.

b. Assign to the above variable by calling w_frames GetActiveSheet( ) function.

c. In a do-while loop, test to see if the above variable contains a sheet, using the
IsValid( ) PowerScript function. Use WinHelp to look up this function.

c. In a do-while loop, test to see if the above variable contains a sheet, using the
IsValid( ) PowerScript function. Use WinHelp to look up this function.

d. If you have a valid sheet, pass the variable to the Close( ) function.

d. If you have a valid sheet, pass the variable to the Close( ) function.

e. Get the next active sheet.

e. Get the next active sheet.

17. Close m_master, saving your work.

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

17. Close m_master, saving your work.

Lab 7 - 3

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 7 - 3

Module 7 Lab: Working with MDI Applications

Module 7 Lab: Working with MDI Applications

Task 2: Creating MDI Sheets

Task 2: Creating MDI Sheets

1.

Using the System Tree, Inherit from w_data_sheet (windows_abstract.pbl).

1.

Using the System Tree, Inherit from w_data_sheet (windows_abstract.pbl).

2.

You are creating the Claim Search window. Save the window as w_claims_search in
the claims.pbl. The final window will look as follows:

2.

You are creating the Claim Search window. Save the window as w_claims_search in
the claims.pbl. The final window will look as follows:

3.

Change the windows Title property to Claims Search.

3.

Change the windows Title property to Claims Search.

4.

Set the windows height to 1800.

4.

Set the windows height to 1800.

5.

Set the DataWindow control location as follows: X 20, Y 470. This will leave
room at the top of the window for entering search criteria.

5.

Set the DataWindow control location as follows: X 20, Y 470. This will leave
room at the top of the window for entering search criteria.

6.

Users can search claims based on a claim number, a patient number, or a claim date.

6.

Users can search claims based on a claim number, a patient number, or a claim date.

7.

Drag a u_st to the top left of the window. Give this control Text of Claim ID:.

7.

Drag a u_st to the top left of the window. Give this control Text of Claim ID:.

8.

With focus on the static text control, press Ctrl-T to duplicate two others whose text
you will set to Patient ID: and Claim Date: respectively.

8.

With focus on the static text control, press Ctrl-T to duplicate two others whose text
you will set to Patient ID: and Claim Date: respectively.

9.

Drag a u_sle onto the window beside the Claim ID static text. Name this control
sle_claim_id.

9.

Drag a u_sle onto the window beside the Claim ID static text. Name this control
sle_claim_id.

10. Duplicate to create another u_sle beside Patient ID. Name this control sle_pat_id.

Lab 7 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

10. Duplicate to create another u_sle beside Patient ID. Name this control sle_pat_id.

Lab 7 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 7: Working with MDI Applications

2010 Sybase, Inc.

Module 7: Working with MDI Applications

11. Drag a u_cb to the right of sle_pat_id. Name this control cb_patid_search. Set other
properties as follows: Text = . Font Bold, Width 140, Height 110. Later,
clicking this button will display a modal window showing patients, letting you select a
patient to obtain his ID.

11. Drag a u_cb to the right of sle_pat_id. Name this control cb_patid_search. Set other
properties as follows: Text = . Font Bold, Width 140, Height 110. Later,
clicking this button will display a modal window showing patients, letting you select a
patient to obtain his ID.

12. Drag a u_em to the right of Claim Date. Name this control em_claim_date. Set the
MaskDataType as datemask!, the Mask property to mm/dd/yyyy and enable the
DropDown Calendar property. Older versions of PowerBuilder may not allow for the
DropDown Calendar. If this is the case, you can still manually enter a date into the
Edit Mask.

12. Drag a u_em to the right of Claim Date. Name this control em_claim_date. Set the
MaskDataType as datemask!, the Mask property to mm/dd/yyyy and enable the
DropDown Calendar property. Older versions of PowerBuilder may not allow for the
DropDown Calendar. If this is the case, you can still manually enter a date into the
Edit Mask.

13. Drag another u_cb to the right of sle_claim_id. Name this button cb_search and
enable the default property.

13. Drag another u_cb to the right of sle_claim_id. Name this button cb_search and
enable the default property.

14. Drag a u_gb (GroupBox control) on top of the above controls and resize the group
box as seen in the illustration shown earlier. Change the group boxs Text to Enter
Search Criteria.

14. Drag a u_gb (GroupBox control) on top of the above controls and resize the group
box as seen in the illustration shown earlier. Change the group boxs Text to Enter
Search Criteria.

15. Verify your work to the picture shown above. The functionality (and DataWindows)
will be finished in later labs.

15. Verify your work to the picture shown above. The functionality (and DataWindows)
will be finished in later labs.

16. Set an appropriate Tab Order for this window.

16. Set an appropriate Tab Order for this window.

17. Save your work.

17. Save your work.

18. Close the painter.

18. Close the painter.

19. Inherit from w_data_sheet.

19. Inherit from w_data_sheet.

20. Change the Title to Doctor Directory.

20. Change the Title to Doctor Directory.

21. Save the window as w_doctor_list in the doctors.pbl.

21. Save the window as w_doctor_list in the doctors.pbl.

22. Close the painter.

22. Close the painter.

23. Inherit from w_data_sheet.

23. Inherit from w_data_sheet.

24. Change the Title to SybHealth Reports.

24. Change the Title to SybHealth Reports.

25. Save the window as w_reports in the SybHealth.pbl.

25. Save the window as w_reports in the SybHealth.pbl.

26. Close the painter.

26. Close the painter.

27. Inherit from w_master_detail_sheet.

27. Inherit from w_master_detail_sheet.

28. Change the Title to Patient Details.

28. Change the Title to Patient Details.

29. Save this window as w_patient_master_detail in the patients.pbl.

29. Save this window as w_patient_master_detail in the patients.pbl.

30. Close the painter.

30. Close the painter.

31. Inherit from w_response.

31. Inherit from w_response.

32. Change the windows Width to 2500 and Height to 1500.

32. Change the windows Width to 2500 and Height to 1500.

33. Drag a u_dw on top of the window and resize the control so that it covers the majority
of the window.

33. Drag a u_dw on top of the window and resize the control so that it covers the majority
of the window.

34. Name the DataWindow control dw_data.

34. Name the DataWindow control dw_data.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 7 - 5

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 7 - 5

Module 7 Lab: Working with MDI Applications

Lab 7 - 6

Module 7 Lab: Working with MDI Applications

35. Verify your work:

35. Verify your work:

36. Save the window in the windows_abstract.pbl as w_data_response.

36. Save the window in the windows_abstract.pbl as w_data_response.

37. Close the painter.

37. Close the painter.

38. Inherit from w_data_response.

38. Inherit from w_data_response.

39. Change the Title to New Claim.

39. Change the Title to New Claim.

40. Save this window as w_claim_new in the claims.pbl.

40. Save this window as w_claim_new in the claims.pbl.

41. Close the painter.

41. Close the painter.

42. Inherit from w_data_response.

42. Inherit from w_data_response.

43. Change the Title to Patient Search.

43. Change the Title to Patient Search.

44. Save the window as w_patient_search in the patients.pbl.

44. Save the window as w_patient_search in the patients.pbl.

45. Close the painter.

45. Close the painter.

46. Inherit from w_data_response.

46. Inherit from w_data_response.

47. Change the Title to New Patient.

47. Change the Title to New Patient.

48. Save this window as w_patient_new in the patients.pbl.

48. Save this window as w_patient_new in the patients.pbl.

49. Close the painter.

49. Close the painter.

50. Inherit from w_data_response.

50. Inherit from w_data_response.

51. Change the Title to New Policy.

51. Change the Title to New Policy.

52. Save this window as w_policy_new in the patients.pbl.

52. Save this window as w_policy_new in the patients.pbl.

53. Close the painter.

53. Close the painter.


Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 7 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 7: Working with MDI Applications

Module 7: Working with MDI Applications

Lab 7-2: Opening Sheets and Resizing Code

Lab 7-2: Opening Sheets and Resizing Code

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Open Response Windows in an MDI application

Open Response Windows in an MDI application

Open Sheets in an MDI application

Open Sheets in an MDI application

Dynamically resize controls when a window resizes

Dynamically resize controls when a window resizes

Description:

In this lab, you will be coding menu items to open the application windows (sheets) you
created in Lab 7-1.

Description:

In this lab, you will be coding menu items to open the application windows (sheets) you
created in Lab 7-1.

Task Outline:

Task 1: Opening Windows within the MDI Frame

Task Outline:

Task 1: Opening Windows within the MDI Frame

Task 2: Dynamically Resizing Controls

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Dynamically Resizing Controls

Lab 7 - 7

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 7 - 7

Module 7 Lab: Working with MDI Applications

Module 7 Lab: Working with MDI Applications

Detailed Instructions

Detailed Instructions

Task 1: Opening Windows within the MDI Frame

Task 1: Opening Windows within the MDI Frame

1.

Until now, you have been opening windows using the Open( ) PowerScript function.
There are several variations of the Open( ) function which you will explore in this lab.

1.

Until now, you have been opening windows using the Open( ) PowerScript function.
There are several variations of the Open( ) function which you will explore in this lab.

2.

Simple rule: If the window is a Response-type window, it is modal and is not opened
within the boundaries of the frame. Response windows are still displayed with the
Open( ) function. It is common practice to use Response windows for displaying
messages, but also for inputting information.

2.

Simple rule: If the window is a Response-type window, it is modal and is not opened
within the boundaries of the frame. Response windows are still displayed with the
Open( ) function. It is common practice to use Response windows for displaying
messages, but also for inputting information.

3.

If the window will act as a sheet, you will use a new function, OpenSheet( ) as
defined in the materials for Module 7 (see your Student Guide).

3.

If the window will act as a sheet, you will use a new function, OpenSheet( ) as
defined in the materials for Module 7 (see your Student Guide).

4.

Re-open the menu m_master.

4.

Re-open the menu m_master.

5.

You will be scripting the items under the FileNew cascade. These windows are all
Response type windows so use Open( ).

5.

You will be scripting the items under the FileNew cascade. These windows are all
Response type windows so use Open( ).

6.

Script FileNewClaim Clicked event:

6.

Script FileNewClaim Clicked event:

Open(w_claim_new)

Open(w_claim_new)

7.

Repeat the above to open w_patient_new under the FileNewPatient, and


w_policy_new under the FileNewPolicy menu items respectively.

7.

Repeat the above to open w_patient_new under the FileNewPatient, and


w_policy_new under the FileNewPolicy menu items respectively.

8.

Save your work.

8.

Save your work.

9.

Next code the FileOpen cascade menu items. These are all sheets so use the
OpenSheet( ) function instead of Open( ). Use 0 as the Position argument for all of
these menu items. Use Layered! as the ArrangeOpen value for these items.

9.

Next code the FileOpen cascade menu items. These are all sheets so use the
OpenSheet( ) function instead of Open( ). Use 0 as the Position argument for all of
these menu items. Use Layered! as the ArrangeOpen value for these items.

10. Script the FileOpenDoctor List menu item Clicked event:

10. Script the FileOpenDoctor List menu item Clicked event:

OpenSheet(w_doctor_list, w_frame, 0, Layered!)

Lab 7 - 8

OpenSheet(w_doctor_list, w_frame, 0, Layered!)

11. Repeat the above writing code to open w_claims_search in the Claims Search menu
item, w_patient_master_detail in the Patient Details menu item and w_reports in the
Reports menu item.

11. Repeat the above writing code to open w_claims_search in the Claims Search menu
item, w_patient_master_detail in the Patient Details menu item and w_reports in the
Reports menu item.

12. Close and save your menu.

12. Close and save your menu.

13. Re-open m_sheet.

13. Re-open m_sheet.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 7 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 7: Working with MDI Applications

Module 7: Working with MDI Applications

14. In the Tree view, right-click over Tools and Insert Submenu Item. Add a separator () and add an item Claim Calculator.

14. In the Tree view, right-click over Tools and Insert Submenu Item. Add a separator () and add an item Claim Calculator.

15. Script the Claim Calculator item to open w_claim_calculator (it is a Response-type
window).

15. Script the Claim Calculator item to open w_claim_calculator (it is a Response-type
window).

16. Save your menu and close the painter.

16. Save your menu and close the painter.

17. On the System Tree, right-click over the SybHealth_target and select Full Build. A
Full Build recompiles every script in every object of the target. This should be done
periodically during development. The Output view will display any errors found.

17. On the System Tree, right-click over the SybHealth_target and select Full Build. A
Full Build recompiles every script in every object of the target. This should be done
periodically during development. The Output view will display any errors found.

18. Run the application via the Running Man icon on the PowerBar.

18. Run the application via the Running Man icon on the PowerBar.

19. When the frame appears, use the FileNew cascade menu items making sure your
Response windows all open. Being modal, you can only open one of these at a time.
You cannot click on the icons or menu items while a response window is open.

19. When the frame appears, use the FileNew cascade menu items making sure your
Response windows all open. Being modal, you can only open one of these at a time.
You cannot click on the icons or menu items while a response window is open.

20. Close any open response windows.

20. Close any open response windows.

21. Use the FileOpen cascade menu items making sure your Sheet windows all open.
The purpose of an MDI type application is to allow multiple sheets to be opened
within the frame at a given time. You should be able to open multiple sheets within
the frame.

21. Use the FileOpen cascade menu items making sure your Sheet windows all open.
The purpose of an MDI type application is to allow multiple sheets to be opened
within the frame at a given time. You should be able to open multiple sheets within
the frame.

22. With a sheet opened in the Frame, look at your toolbars. You should see some
duplicate icons. This is normal PowerBuilder behavior. The top toolbar comes from
m_frame and the bottom two toolbars come from m_sheet. Both were inherited from
the same menu (m_master), giving them some similar icons.

22. With a sheet opened in the Frame, look at your toolbars. You should see some
duplicate icons. This is normal PowerBuilder behavior. The top toolbar comes from
m_frame and the bottom two toolbars come from m_sheet. Both were inherited from
the same menu (m_master), giving them some similar icons.

23. Close the running application.

23. Close the running application.

24. To control this duplication, you need to re-open m_sheet and disable the
ToolBarItemVisible property (Toolbar tab) for the following menu items:

24. To control this duplication, you need to re-open m_sheet and disable the
ToolBarItemVisible property (Toolbar tab) for the following menu items:

a. FileExit

a. FileExit

25. Still in m_sheet, set the ToolBarItemBarIndex to 1 for the following menu items (too
many rows of toolbars if you dont do this):

25. Still in m_sheet, set the ToolBarItemBarIndex to 1 for the following menu items (too
many rows of toolbars if you dont do this):

a. ToolsInsert

a. ToolsInsert

b. ToolsDelete

2010 Sybase, Inc.

b. ToolsDelete

26. Close m_sheet, saving your work.

26. Close m_sheet, saving your work.

27. Since Exit is currently the only icon on the Frames toolbar, re-open m_frame and
assign the following toolbar icons:

27. Since Exit is currently the only icon on the Frames toolbar, re-open m_frame and
assign the following toolbar icons:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 7 - 9

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 7 - 9

Module 7 Lab: Working with MDI Applications

Module 7 Lab: Working with MDI Applications

a. FileOpenClaims Search: Custom071!

a. FileOpenClaims Search: Custom071!

b. FileOpenPatient Details: ScriptYes!

b. FileOpenPatient Details: ScriptYes!

c. FileOpenDoctors List: RunReport5!

c. FileOpenDoctors List: RunReport5!

d. Add appropriate ToolbarItemText to the above icons.

d. Add appropriate ToolbarItemText to the above icons.

28. Run the application and make sure the toolbars look better when opening sheets.

28. Run the application and make sure the toolbars look better when opening sheets.

29. With the application running and a sheet open, click on Window on your menu bar.
You should see the list of open sheets under that menu item. If you wish, open
multiple sheets and verify that you can use that feature to switch between open sheets.
Setting the Position argument to OpenSheet( ) to a value of 0 made the sheet list
appear under the next to last (Window) menu item.

29. With the application running and a sheet open, click on Window on your menu bar.
You should see the list of open sheets under that menu item. If you wish, open
multiple sheets and verify that you can use that feature to switch between open sheets.
Setting the Position argument to OpenSheet( ) to a value of 0 made the sheet list
appear under the next to last (Window) menu item.

30. You also passed Layered! to the OpenSheet( ) function. This made the sheets fill the
Client Area of the frame and covers any other opened sheets. The window was
automatically resized on opening.

30. You also passed Layered! to the OpenSheet( ) function. This made the sheets fill the
Client Area of the frame and covers any other opened sheets. The window was
automatically resized on opening.

31. You also learned that any controls you place on a window do not automatically resize
when the user (or code) resizes the window. This will be covered in the next lab task.

31. You also learned that any controls you place on a window do not automatically resize
when the user (or code) resizes the window. This will be covered in the next lab task.

32. Close any sheets youve opened, but do not close the SybHealth application.

32. Close any sheets youve opened, but do not close the SybHealth application.

Task 2: Dynamically Resizing Controls


1.

Lab 7 - 10

Task 2: Dynamically Resizing Controls

The SybHealth MDI Frame window should still be visible.

1.

The SybHealth MDI Frame window should still be visible.

2.

Click on FileNewClaim.

2.

Click on FileNewClaim.

3.

Attempt to resize the New Claim window. You should not be able to. Response-type
windows are not resizable.

3.

Attempt to resize the New Claim window. You should not be able to. Response-type
windows are not resizable.

4.

Close New Claim.

4.

Close New Claim.

5.

Click on FileOpenReports.

5.

Click on FileOpenReports.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 7 - 10

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 7: Working with MDI Applications


6.

2010 Sybase, Inc.

Module 7: Working with MDI Applications

The window fills the Client Area of the frame, but the DataWindow control did not
resize.

6.

The window fills the Client Area of the frame, but the DataWindow control did not
resize.

7.

You will write the code to resize the DataWindow when the window resizes.

7.

You will write the code to resize the DataWindow when the window resizes.

8.

Exit the application.

8.

Exit the application.

9.

Re-open w_reports.

9.

Re-open w_reports.

10. Go to a Script view for the window (first drop down shows w_reports).

10. Go to a Script view for the window (first drop down shows w_reports).

11. Using the second drop down (the Events list), navigate to the Resize event. This
event automatically fires whenever the window is resized.

11. Using the second drop down (the Events list), navigate to the Resize event. This
event automatically fires whenever the window is resized.

12. Notice the arguments for the Resize event. You may need to click the Show/Hide
Prototype icon in the upper right of the Script view to see the arguments. You should
see two useful arguments, newwidth and newheight. When the Resize event fires,
these arguments get populated with the windows new width and new height. You
will use those values to resize the windows controls:

12. Notice the arguments for the Resize event. You may need to click the Show/Hide
Prototype icon in the upper right of the Script view to see the arguments. You should
see two useful arguments, newwidth and newheight. When the Resize event fires,
these arguments get populated with the windows new width and new height. You
will use those values to resize the windows controls:

13. Code w_reports Resize event:

13. Code w_reports Resize event:

a. Move the DataWindow control (named dw_data) to X coordinate 10, and Y


coordinate 10).

a. Move the DataWindow control (named dw_data) to X coordinate 10, and Y


coordinate 10).

b. Resize the DataWindow control using its Resize( ) function using the new
width and new height of the window (arguments) minus a small factor so you
leave a border around the DataWindow control.

b. Resize the DataWindow control using its Resize( ) function using the new
width and new height of the window (arguments) minus a small factor so you
leave a border around the DataWindow control.

14. A solution to the above is listed below:

14. A solution to the above is listed below:

15. Copy the above code to the w_doctor_list Resize event.

15. Copy the above code to the w_doctor_list Resize event.

16. Run the application and open SybHealth Reports. The DataWindow control now
expands, almost covering the window.

16. Run the application and open SybHealth Reports. The DataWindow control now
expands, almost covering the window.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 7 - 11

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 7 - 11

Module 7 Lab: Working with MDI Applications

Lab 7 - 12

Module 7 Lab: Working with MDI Applications

17. Exit the application.

17. Exit the application.

18. The above example was provided to help you better understand how to resize controls
in a PowerBuilder application. These examples only had one control. Think about
how much code would be written if a window had 50 controls.

18. The above example was provided to help you better understand how to resize controls
in a PowerBuilder application. These examples only had one control. Think about
how much code would be written if a window had 50 controls.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 7 - 12

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

Module 8: Using the Database Painter and Working with Extended Attributes

Module 8: Using the Database Painter and Working with


Extended Attributes

Module 8: Using the Database Painter and Working with


Extended Attributes

Lab 8-1: Using the Database Painter

Lab 8-1: Using the Database Painter

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Use the Database Painter to build Extended Attributes

Use the Database Painter to build Extended Attributes

Description:

In Lab 2, you looked at the Database Painter and its informative value. In this lab, you
will build some Extended Attributes. These attributes will be stored in the database and
associated to columns in your database tables. This will allow them to be used in the
SybHealth DataWindow objects that you will create in the lab for the next module.
Creating Extended Attributes in the database versus the DataWindow allows for reuse and
consistency of data display. You will be building some simple DataWindow objects in this
module because the two topics are related. More information about DataWindows comes
in the next module.

Description:

In Lab 2, you looked at the Database Painter and its informative value. In this lab, you
will build some Extended Attributes. These attributes will be stored in the database and
associated to columns in your database tables. This will allow them to be used in the
SybHealth DataWindow objects that you will create in the lab for the next module.
Creating Extended Attributes in the database versus the DataWindow allows for reuse and
consistency of data display. You will be building some simple DataWindow objects in this
module because the two topics are related. More information about DataWindows comes
in the next module.

Task Outline:

Task 1: DataWindow Objects pre-Extended Attributes

Task Outline:

Task 1: DataWindow Objects pre-Extended Attributes

Task 2: Creating Extended Attributes in the Database

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Creating Extended Attributes in the Database

Lab 8 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 1

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

Detailed Instructions

Detailed Instructions

Task 1: DataWindow Objects pre-Extended Attributes

Task 1: DataWindow Objects pre-Extended Attributes

Lab 8 - 2

1.

To understand the impact of creating Extended Attributes in the database, you will
begin by creating a DataWindow object prior to creating the Extended Attributes.
You will be led through the DataWindow object creation process. You will learn
more about DataWindows beginning in Module 9.

1.

To understand the impact of creating Extended Attributes in the database, you will
begin by creating a DataWindow object prior to creating the Extended Attributes.
You will be led through the DataWindow object creation process. You will learn
more about DataWindows beginning in Module 9.

2.

Click on the DB Profile icon on the PowerBar.

2.

Click on the DB Profile icon on the PowerBar.

3.

Make sure you are connected to the SybHealth database and close the DB Profile
painter.

3.

Make sure you are connected to the SybHealth database and close the DB Profile
painter.

4.

Right-click over the SybHealth_target and select New from the context menu.

4.

Right-click over the SybHealth_target and select New from the context menu.

5.

On the New dialog, select the DataWindow tab.

5.

On the New dialog, select the DataWindow tab.

6.

Select Grid as the Presentation Style and click OK.

6.

Select Grid as the Presentation Style and click OK.

7.

Select Quick Select and click Next.

7.

Select Quick Select and click Next.

8.

Select the doctor table and click the Add All button, selecting all the columns.

8.

Select the doctor table and click the Add All button, selecting all the columns.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 8 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes
9.

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

Sort ascending based on the doctor last name:

9.

Sort ascending based on the doctor last name:

10. Click OK.

10. Click OK.

11. Click Next on the Color and Border Settings dialog.

11. Click Next on the Color and Border Settings dialog.

12. Click Finish.

12. Click Finish.

13. You should now see the Design/Preview views of the DataWindow painter.

13. You should now see the Design/Preview views of the DataWindow painter.

14. Look to the Design view of the DataWindow painter (top). The column headers need
to be changed from the column names to something more acceptable to the end user.

14. Look to the Design view of the DataWindow painter (top). The column headers need
to be changed from the column names to something more acceptable to the end user.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 3

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 3

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

Lab 8 - 4

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

15. Click on the dr_id text object in the header band and type ID in its place (do not
enter the quotes around the text). Repeat the process for dr_fname making the header
First Name and dr_lname making the header Last Name:

15. Click on the dr_id text object in the header band and type ID in its place (do not
enter the quotes around the text). Repeat the process for dr_fname making the header
First Name and dr_lname making the header Last Name:

16. If you do not use Extended Attributes, every time you create a DataWindow, you
must change the Header or Label names to something more acceptable.

16. If you do not use Extended Attributes, every time you create a DataWindow, you
must change the Header or Label names to something more acceptable.

17. Close the DataWindow painter without saving the DataWindow object.

17. Close the DataWindow painter without saving the DataWindow object.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 8 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

Task 2: Creating Extended Attributes in the Database

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

Task 2: Creating Extended Attributes in the Database

1.

Click on ToolsDatabase Painter on the PowerBuilder menu bar.

1.

Click on ToolsDatabase Painter on the PowerBuilder menu bar.

2.

In the Objects view, expand the SybHealth profile, expand Tables, expand the doctor
table, then expand the columns folder:

2.

In the Objects view, expand the SybHealth profile, expand Tables, expand the doctor
table, then expand the columns folder:

3.

Over the dr_id column, right-click and select Properties from the context menu.

3.

Over the dr_id column, right-click and select Properties from the context menu.

4.

Properties appear in the upper-right of the Database painter.

4.

Properties appear in the upper-right of the Database painter.

5.

Select the Headers tab.

5.

Select the Headers tab.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 5

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 5

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

Lab 8 - 6

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

6.

Change the Label property to ID:. Change the Heading property to ID:

6.

Change the Label property to ID:. Change the Heading property to ID:

7.

Save your changes.

7.

Save your changes.

8.

Repeat this process for the dr_fname and dr_lname columns, giving them First
Name and Last Name labels and headers respectively.

8.

Repeat this process for the dr_fname and dr_lname columns, giving them First
Name and Last Name labels and headers respectively.

9.

Close the Database painter.

9.

Close the Database painter.

10. Repeat Task 1, Steps 4 13, re-creating the doctors list DataWindow object. You
will see the impact of adding Extended Attributes. The headers have your pretty
names instead of using the column names. The Extended Attributes were
automatically copied into your DataWindow object.

10. Repeat Task 1, Steps 4 13, re-creating the doctors list DataWindow object. You
will see the impact of adding Extended Attributes. The headers have your pretty
names instead of using the column names. The Extended Attributes were
automatically copied into your DataWindow object.

11. In the DataWindow painters Preview view, right-click and select Retrieve from the
context menu. Drag the Last Name column (drag the header) in front of the First
Name column. Notice how this updates the Design view as well:

11. In the DataWindow painters Preview view, right-click and select Retrieve from the
context menu. Drag the Last Name column (drag the header) in front of the First
Name column. Notice how this updates the Design view as well:

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 8 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

12. Save the DataWindow object in the doctors.pbl as d_grid_doctors.

12. Save the DataWindow object in the doctors.pbl as d_grid_doctors.

13. Close the DataWindow painter.

13. Close the DataWindow painter.

14. Extended Attributes provide more functionality than making headers pretty. They
allow you to format the data for displaying and editing.

14. Extended Attributes provide more functionality than making headers pretty. They
allow you to format the data for displaying and editing.

15. Right-click over the SybHealth_target and select New from the context menu.

15. Right-click over the SybHealth_target and select New from the context menu.

16. On the New dialog, select the DataWindow tab.

16. On the New dialog, select the DataWindow tab.

17. Select Tabular as the Presentation Style and click OK.

17. Select Tabular as the Presentation Style and click OK.

18. Select Quick Select and click Next.

18. Select Quick Select and click Next.

19. Select the patient table and click the following columns: patient_id, first_name,
middle_name, last_name, date_of_birth, state_code and phone_no columns.

19. Select the patient table and click the following columns: patient_id, first_name,
middle_name, last_name, date_of_birth, state_code and phone_no columns.

20. Sort ascending based on the patiend_id:

20. Sort ascending based on the patiend_id:

21. Click OK.

21. Click OK.

22. On the Color and Border Settings dialog set the Text Border to Raised. Click Next.

22. On the Color and Border Settings dialog set the Text Border to Raised. Click Next.

23. Click Finish.

23. Click Finish.

24. You should now be in the Design/Preview view of the DataWindow painter.

24. You should now be in the Design/Preview view of the DataWindow painter.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 7

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 7

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

Lab 8 - 8

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

25. In the Preview view, right-click and Retrieve.

25. In the Preview view, right-click and Retrieve.

26. Scroll right and make note of the way the date of birth and phone columns data
displays:

26. Scroll right and make note of the way the date of birth and phone columns data
displays:

27. Close the DataWindow painter, not saving the changes.

27. Close the DataWindow painter, not saving the changes.

28. Re-open the Database Painter.

28. Re-open the Database Painter.

29. Locate and click on the Extended Attributes tab in the middle-upper portion of the
painter:

29. Locate and click on the Extended Attributes tab in the middle-upper portion of the
painter:

30. Expand the Display Formats node. PowerBuilder automatically provides some
default Display Formats, but you can create your own too.

30. Expand the Display Formats node. PowerBuilder automatically provides some
default Display Formats, but you can create your own too.

31. Over Display Formats, right-click and select New

31. Over Display Formats, right-click and select New

32. In the upper-right of the painter, give your Display Format the Style Name of
SybHealth Date, a Data Type of date, and a Format of mmm-dd-yyyy:

32. In the upper-right of the painter, give your Display Format the Style Name of
SybHealth Date, a Data Type of date, and a Format of mmm-dd-yyyy:

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 8 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

33. Save (Ctrl-S) your work.

33. Save (Ctrl-S) your work.

34. Creating the Extended Attribute is step one of the process. Step two is to associate the
attribute to columns. This attribute can be created one time but used on many
columns and on different tables.

34. Creating the Extended Attribute is step one of the process. Step two is to associate the
attribute to columns. This attribute can be created one time but used on many
columns and on different tables.

35. In the Objects view of the Database painter, expand SybHealth, tables, patient and
then columns. Right-click over the date_of_birth column and select Properties:

35. In the Objects view of the Database painter, expand SybHealth, tables, patient and
then columns. Right-click over the date_of_birth column and select Properties:

36. Go back to the Properties view of the painter. Click on the Display (for Display
Format) tab.

36. Go back to the Properties view of the painter. Click on the Display (for Display
Format) tab.

37. Using the Display Format drop down, select SybHealth Date from the list:

37. Using the Display Format drop down, select SybHealth Date from the list:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 9

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 9

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

Lab 8 - 10

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

38. Save your work.

38. Save your work.

39. Test by right-clicking over the patient table (in the Objects view) and select Edit
DataGrid:

39. Test by right-clicking over the patient table (in the Objects view) and select Edit
DataGrid:

40. You will see the data in the Results tab of the Database painter:

40. You will see the data in the Results tab of the Database painter:

41. Scroll right until you see your formatted date_of_birth column.

41. Scroll right until you see your formatted date_of_birth column.

42. Extended Attributes created in the database are automatically copied into every
DataWindow object that uses this column. You can remove or change the attributes
after they have been copied into the DataWindow if necessary.

42. Extended Attributes created in the database are automatically copied into every
DataWindow object that uses this column. You can remove or change the attributes
after they have been copied into the DataWindow if necessary.

43. Over Display Formats on the Extended Attributes tab of the Database painter, rightclick and select New

43. Over Display Formats on the Extended Attributes tab of the Database painter, rightclick and select New

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 8 - 10

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

44. Name this Display Format SybHealth Phone, Data type of String, Format of: @@@@@@-@@@@:

44. Name this Display Format SybHealth Phone, Data type of String, Format of: @@@@@@-@@@@:

45. Save your work.

45. Save your work.

46. In the Objects view, expand SybHealth, tables, patient and then columns.

46. In the Objects view, expand SybHealth, tables, patient and then columns.

47. Right-click over phone_no and select Properties.

47. Right-click over phone_no and select Properties.

48. Choose the SybHealth Phone Display Format on the Display tab and save your work.

48. Choose the SybHealth Phone Display Format on the Display tab and save your work.

49. Right-click over the patient table and select Edit DataTabular from the context
menu.

49. Right-click over the patient table and select Edit DataTabular from the context
menu.

50. Scroll right to the phone number column to verify your work.

50. Scroll right to the phone number column to verify your work.

51. Note: the Database painter is nothing an end user will see. Dont worry about
resizing columns in its Results view. When you create the DataWindow objects you
will align and size columns as needed.

51. Note: the Database painter is nothing an end user will see. Dont worry about
resizing columns in its Results view. When you create the DataWindow objects you
will align and size columns as needed.

52. Display Formats are for data display. Edit Styles are for data display and
manipulation.

52. Display Formats are for data display. Edit Styles are for data display and
manipulation.

53. On the Extended Attributes tab, right-click over Edit Styles and select New

53. On the Extended Attributes tab, right-click over Edit Styles and select New

54. Name the new Edit Style SybHealth Gender, with a Style Type of Radio Buttons.

54. Name the new Edit Style SybHealth Gender, with a Style Type of Radio Buttons.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 11

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 11

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

Lab 8 - 12

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

55. Set the remainder of the properties as you see below:

55. Set the remainder of the properties as you see below:

56. Save your work (Ctrl-S).

56. Save your work (Ctrl-S).

57. In the Tree view, expand SybHealth, Tables, patient, Columns.

57. In the Tree view, expand SybHealth, Tables, patient, Columns.

58. Right-click over the gender column and select Properties.

58. Right-click over the gender column and select Properties.

59. Click the Edit Style tab, select SybHealth Gender from the list box and save your
work:

59. Click the Edit Style tab, select SybHealth Gender from the list box and save your
work:

60. Edit your data using Grid style to test. Resize the gender column to see completely:

60. Edit your data using Grid style to test. Resize the gender column to see completely:

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 8 - 12

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

Module 8: Using the Database Painter and Working with Extended Attributes

61. Using the processes outlined above, assign the following Display Formats:

61. Using the processes outlined above, assign the following Display Formats:

Claims table: dr_charges and amount_paid columns:

2010 Sybase, Inc.

Claims table: dr_charges and amount_paid columns:

62. Save your work. Display the data to make sure your claims table has the following
dollar formats:

62. Save your work. Display the data to make sure your claims table has the following
dollar formats:

63. Close the Database painter.

63. Close the Database painter.

64. Right-click over the SybHealth_target. Select New

64. Right-click over the SybHealth_target. Select New

65. On the DataWindow tab, select Tabular and click OK.

65. On the DataWindow tab, select Tabular and click OK.

66. Select Quick Select and click Next.

66. Select Quick Select and click Next.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 13

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 13

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

Lab 8 - 14

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

67. Select the state table and Add All columns. Sort ascending by the state_code column:

67. Select the state table and Add All columns. Sort ascending by the state_code column:

68. Click OK and finish the wizard.

68. Click OK and finish the wizard.

69. In the Design view of the DataWindow painter, remove the headers and drag the
header band to the top of the view:

69. In the Design view of the DataWindow painter, remove the headers and drag the
header band to the top of the view:

70. Click on the Tab Order icon on the PainterBar, setting both columns to a value of 0.
Click again on the Tab Order icon.

70. Click on the Tab Order icon on the PainterBar, setting both columns to a value of 0.
Click again on the Tab Order icon.

71. Save this DataWindow as d_dddw_states in the sybhealth.pbl. The dddw indicates a
Drop Down DataWindow.

71. Save this DataWindow as d_dddw_states in the sybhealth.pbl. The dddw indicates a
Drop Down DataWindow.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 8 - 14

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

72. In the Preview view, right-click and select Retrieve. Your data should look as
follows:

72. In the Preview view, right-click and select Retrieve. Your data should look as
follows:

73. Close the DataWindow painter and re-open the Database painter.

73. Close the DataWindow painter and re-open the Database painter.

74. Create a new Extended Attribute, Edit Style named StateList.

74. Create a new Extended Attribute, Edit Style named StateList.

75. Set the Style Type to DropDownDW.

75. Set the Style Type to DropDownDW.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 15

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 15

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

76. Enable the Always Show Arrow, Vertical Scroll Bar and AutoRetrieve properties:

Lab 8 - 16

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

76. Enable the Always Show Arrow, Vertical Scroll Bar and AutoRetrieve properties:

Lab 8 - 16

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

77. Scroll further down the Properties view and set the remainder of the properties as
shown below:

77. Scroll further down the Properties view and set the remainder of the properties as
shown below:

78. Save your work.

78. Save your work.

79. Associate the StateList Edit Style to the state_code column of the patient table.

79. Associate the StateList Edit Style to the state_code column of the patient table.

80. When you view your data, it should look as follows:

80. When you view your data, it should look as follows:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 17

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 17

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

Lab 8 - 18

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

81. Create another new Tabular DataWindow from the claim_reasons table as follows:

81. Create another new Tabular DataWindow from the claim_reasons table as follows:

82. In the Design view of the DataWindow painter, remove the headers and drag the
header band to the top of the view:

82. In the Design view of the DataWindow painter, remove the headers and drag the
header band to the top of the view:

83. Click on the Tab Order icon on the PainterBar, setting both columns to a value of 0.
Click again on the Tab Order icon.

83. Click on the Tab Order icon on the PainterBar, setting both columns to a value of 0.
Click again on the Tab Order icon.

84. Save this DataWindow as d_dddw_claim_reasons in the claims.pbl.

84. Save this DataWindow as d_dddw_claim_reasons in the claims.pbl.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 8 - 18

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

Module 8: Using the Database Painter and Working with Extended Attributes

85. In the Preview view, right-click and select Retrieve. Your data should look as
follows:

2010 Sybase, Inc.

85. In the Preview view, right-click and select Retrieve. Your data should look as
follows:

86. Close the DataWindow painter and re-open the Database painter.

86. Close the DataWindow painter and re-open the Database painter.

87. Create a new Extended Attribute, Edit Style named ClaimReasons.

87. Create a new Extended Attribute, Edit Style named ClaimReasons.

88. Set the Style Type to DropDownDW.

88. Set the Style Type to DropDownDW.

89. Enable the Always Show Arrow, Vertical Scroll Bar and AutoRetrieve properties:

89. Enable the Always Show Arrow, Vertical Scroll Bar and AutoRetrieve properties:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 19

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 19

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

Lab 8 - 20

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

90. Scroll further down the Properties view and set the remainder of the properties as
shown below:

90. Scroll further down the Properties view and set the remainder of the properties as
shown below:

91. Save your work.

91. Save your work.

92. Associate the ClaimReasons Edit Style to the claim_code column in the claims table.

92. Associate the ClaimReasons Edit Style to the claim_code column in the claims table.

93. When you view your data, it should look as follows:

93. When you view your data, it should look as follows:

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 8 - 20

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

94. Using the above steps, create another new tabular DataWindow for the claims_status
table and its columns. Save the datawindow as d_dddw_claims_status in the
claims.pbl:

94. Using the above steps, create another new tabular DataWindow for the claims_status
table and its columns. Save the datawindow as d_dddw_claims_status in the
claims.pbl:

95. Create a ClaimStatus Edit Style, then associate that Edit Style to the claims table,
status_code column. Your data should display as follows:

95. Create a ClaimStatus Edit Style, then associate that Edit Style to the claims table,
status_code column. Your data should display as follows:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 21

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 21

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

Lab 8 - 22

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

96. Create one last tabular DataWindow to display from the insurance_coverage table.
When finished, it will look as follows:

96. Create one last tabular DataWindow to display from the insurance_coverage table.
When finished, it will look as follows:

97. Save the DataWindow as d_dddw_insurance_coverages in the patients.pbl.

97. Save the DataWindow as d_dddw_insurance_coverages in the patients.pbl.

98. Close the DataWindow painter.

98. Close the DataWindow painter.

99. In the Database painter, create one last Edit Style named InsuranceCoverages.
Associate InsuranceCoverages to the insurance_type column of the insurance_policy
table. Your data will view as follows:

99. In the Database painter, create one last Edit Style named InsuranceCoverages.
Associate InsuranceCoverages to the insurance_type column of the insurance_policy
table. Your data will view as follows:

100. Create a new Validation Rule:

100. Create a new Validation Rule:

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 8 - 22

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

2010 Sybase, Inc.

Module 8: Using the Database Painter and Working with Extended Attributes

101. Name the Validation Rule DoctorCharges. It will have a data type of number. Set the
message to Claims must be greater than or equal to $100.00.

101. Name the Validation Rule DoctorCharges. It will have a data type of number. Set the
message to Claims must be greater than or equal to $100.00.

102. Click the Definition tab and use the @col placeholder to write the appropriate rule:

102. Click the Definition tab and use the @col placeholder to write the appropriate rule:

103. Assign DoctorCharges to the claims table, dr_charges column:

103. Assign DoctorCharges to the claims table, dr_charges column:

104. Save your changes.

104. Save your changes.

105. Edit the claims table data in grid format.

105. Edit the claims table data in grid format.

106. Scroll down and you will see some doctor charges that are not greater or equal to
$100.00. This means the validation rule does not fire on data retrieval. Validation
rules only fire when a change is made to a column with an associated rule.

106. Scroll down and you will see some doctor charges that are not greater or equal to
$100.00. This means the validation rule does not fire on data retrieval. Validation
rules only fire when a change is made to a column with an associated rule.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 23

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 8 - 23

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

Lab 8 - 24

Module 8 Lab: Using the Database Painter and Working with Extended Attributes

107. On any row in the data display, change the dr_charges to 75.00 and press the tab key.
You will see your custom error message.

107. On any row in the data display, change the dr_charges to 75.00 and press the tab key.
You will see your custom error message.

108. Close the Database painter, answering No to the dialog asking you to Save changes
back to data source?

108. Close the Database painter, answering No to the dialog asking you to Save changes
back to data source?

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 8 - 24

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

Module 9: DataWindow Technology Overview and DataWindow Objects

Module 9: DataWindow Technology Overview and


DataWindow Objects

Module 9: DataWindow Technology Overview and


DataWindow Objects

Lab 9-1: Building Basic DataWindows

Lab 9-1: Building Basic DataWindows

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Use the DataWindow painter to build some basic DataWindow objects.

Use the DataWindow painter to build some basic DataWindow objects.

Description:

In this lab, you will build two DataWindow objects, one that is Tabular to display a Patient
list. This DataWindow will be used later in a Master-Detail interface. The second
DataWindow will be a Grid presentation style to be used for the Claims Search interface.

Description:

In this lab, you will build two DataWindow objects, one that is Tabular to display a Patient
list. This DataWindow will be used later in a Master-Detail interface. The second
DataWindow will be a Grid presentation style to be used for the Claims Search interface.

Task Outline:

Task 1: Creating the Patient List DataWindow Object

Task Outline:

Task 1: Creating the Patient List DataWindow Object

Task 2: Creating the Claims Search DataWindow Object

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Creating the Claims Search DataWindow Object

Lab 9 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 1

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Detailed Instructions

Detailed Instructions

Task 1: Creating the Patient List DataWindow Object

Task 1: Creating the Patient List DataWindow Object

1.

Create a new DataWindow object that has the following characteristics:


Style:
Data Source:
Table:
Columns:
Sort:
Where:
Inputs:
Text Border:

2.

Lab 9 - 2

1.

Tabular
SQL Select
Patient
patient_id, last_name, first_name, city, state_code and zip (in
order)
last_name ascending, first_name ascending
(None)
(None)
Raised

Create a new DataWindow object that has the following characteristics:


Style:
Data Source:
Table:
Columns:
Sort:
Where:
Inputs:
Text Border:

Once in Design view of the DataWindow painter, give proper names to the State and
Zip columns (zip header is lower case and shouldnt be).

2.

Tabular
SQL Select
Patient
patient_id, last_name, first_name, city, state_code and zip (in
order)
last_name ascending, first_name ascending
(None)
(None)
Raised

Once in Design view of the DataWindow painter, give proper names to the State and
Zip columns (zip header is lower case and shouldnt be).

3.

Change all text objects in the Header band to a ButtonFace color.

3.

Change all text objects in the Header band to a ButtonFace color.

4.

Click on the state_code column in the Detail band. Go to the Properties view where
you will click on the Edit tab (for Edit Style). The edit style, StateList, you created in
the last lab was automatically copied into this DataWindow.

4.

Click on the state_code column in the Detail band. Go to the Properties view where
you will click on the Edit tab (for Edit Style). The edit style, StateList, you created in
the last lab was automatically copied into this DataWindow.

5.

Disable the Always Show Arrow property. This will be a read-only DataWindow.

5.

Disable the Always Show Arrow property. This will be a read-only DataWindow.

6.

Resize the width of first_name, last_name and city so that the entire display is seen
without scrolling right (see next page for an example).

6.

Resize the width of first_name, last_name and city so that the entire display is seen
without scrolling right (see next page for an example).

7.

After clicking on the Tab Order icon, set all columns to a sequence of zero. Click the
Tab Order icon again.

7.

After clicking on the Tab Order icon, set all columns to a sequence of zero. Click the
Tab Order icon again.

8.

Save the DataWindow as d_patients_list in the patients.pbl.

8.

Save the DataWindow as d_patients_list in the patients.pbl.

9.

Right-click in the Preview view and select Retrieve.

9.

Right-click in the Preview view and select Retrieve.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 9 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

Module 9: DataWindow Technology Overview and DataWindow Objects

10. When your data looks as follows, save and close the Painter:

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

10. When your data looks as follows, save and close the Painter:

Lab 9 - 3

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 3

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Task 2: Creating the Claims Search DataWindow Object


1.

Create a new DataWindow object that has the following characteristics:


Style:
Data Source:
Table:
Columns:
Compute(s):
Sort:
Where:
Inputs:
Text Border:

2.

Task 2: Creating the Claims Search DataWindow Object


1.

Grid
SQL Select
Claims, Doctor, Patient
claim_id, date_of_claim, claim_code, status_code,
dr_charges and amount_paid
doctor.dr_lname + ', ' + doctor.dr_fname AS DoctorFullName
patient.last_name + ', ' + patient.first_name + +
left(patient.middle_name, 1) AS PatientFullName
date_of_claim ascending, amount_paid descending
(None)
(None)
Raised

Style:
Data Source:
Table:
Columns:
Compute(s):
Sort:
Where:
Inputs:
Text Border:

Before leaving SQL Mode of the DataWindow painter, use the Selection List (top of
the screen) and its scrollbar to move the columns into this order:

2.

claim_id, date_of_claim, PatientFullName (compute), claim_code, status_code,


DoctorFullName (compute), dr_charges and amount_paid.

Lab 9 - 4

Create a new DataWindow object that has the following characteristics:


Grid
SQL Select
Claims, Doctor, Patient
claim_id, date_of_claim, claim_code, status_code,
dr_charges and amount_paid
doctor.dr_lname + ', ' + doctor.dr_fname AS DoctorFullName
patient.last_name + ', ' + patient.first_name + +
left(patient.middle_name, 1) AS PatientFullName
date_of_claim ascending, amount_paid descending
(None)
(None)
Raised

Before leaving SQL Mode of the DataWindow painter, use the Selection List (top of
the screen) and its scrollbar to move the columns into this order:
claim_id, date_of_claim, PatientFullName (compute), claim_code, status_code,
DoctorFullName (compute), dr_charges and amount_paid.

3.

Give proper headings to the DataWindow: Claim ID, Claim Date, Patient Name,
Type, Status, Doctor Name, Charged and Paid.

3.

Give proper headings to the DataWindow: Claim ID, Claim Date, Patient Name,
Type, Status, Doctor Name, Charged and Paid.

4.

Resize the Patient Name and Doctor Name columns until you can see all of the data
without scrolling right (see example below).

4.

Resize the Patient Name and Doctor Name columns until you can see all of the data
without scrolling right (see example below).

5.

Change all text objects in the Header band to a ButtonFace color.

5.

Change all text objects in the Header band to a ButtonFace color.

6.

Click on the claim_code column in the Detail band. Go to the Properties view where
you will click on the Edit tab (for Edit Style). Disable the Always Show Arrow
property. Repeat this process for the claims_status column.

6.

Click on the claim_code column in the Detail band. Go to the Properties view where
you will click on the Edit tab (for Edit Style). Disable the Always Show Arrow
property. Repeat this process for the claims_status column.

7.

Set the Tab Order for all columns to zero.

7.

Set the Tab Order for all columns to zero.

8.

Right-justify the Claim Date, Patient Name and Doctor Name columns.

8.

Right-justify the Claim Date, Patient Name and Doctor Name columns.

9.

Save your DataWindow as d_claims_list in the claims.pbl.

9.

Save your DataWindow as d_claims_list in the claims.pbl.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 9 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

Module 9: DataWindow Technology Overview and DataWindow Objects

10. When your DataWindow looks as follows, save and close the painter:

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

10. When your DataWindow looks as follows, save and close the painter:

Lab 9 - 5

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 5

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Lab 9-2: Building DataWindows Requiring Input

Lab 9-2: Building DataWindows Requiring Input

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Use the DataWindow painter to build DataWindow objects that require input at
runtime.

Use the DataWindow painter to build DataWindow objects that require input at
runtime.

Description:

In this lab, you will build several DataWindow objects to which will require input at
runtime, i.e. Retrieval Arguments. You will begin by completing the Claims Search
DataWindow and then create several new DataWindow objects for the Patient Details, Edit
Policy, and Edit Claim windows.

Description:

In this lab, you will build several DataWindow objects to which will require input at
runtime, i.e. Retrieval Arguments. You will begin by completing the Claims Search
DataWindow and then create several new DataWindow objects for the Patient Details, Edit
Policy, and Edit Claim windows.

Task Outline:

Task 1: Completing the Claims Lookup DataWindow Object

Task Outline:

Task 1: Completing the Claims Lookup DataWindow Object

Lab 9 - 6

Task 2: Creating the Patient Details DataWindow Object

Task 2: Creating the Patient Details DataWindow Object

Task 3: Creating the New/Edit Policy DataWindow Object

Task 3: Creating the New/Edit Policy DataWindow Object

Task 4: Creating the New/Edit Claim DataWindow Object

Task 4: Creating the New/Edit Claim DataWindow Object

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 9 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

Module 9: DataWindow Technology Overview and DataWindow Objects

Detailed Instructions

Detailed Instructions

Task 1: Completing the Claims Lookup DataWindow Object

Task 1: Completing the Claims Lookup DataWindow Object

2010 Sybase, Inc.

1.

The following is a reminder of a window you created in Lab 7. It shows the possible
search criteria inputs:

1.

The following is a reminder of a window you created in Lab 7. It shows the possible
search criteria inputs:

2.

Re-open d_claims_list using the FileRecent Objects menu option.

2.

Re-open d_claims_list using the FileRecent Objects menu option.

3.

Once in the DataWindow painter, click on the Data Source icon on the PainterBar (or
click DesignData Source).

3.

Once in the DataWindow painter, click on the Data Source icon on the PainterBar (or
click DesignData Source).

4.

You can always go back into the SQL mode of the DataWindow painter should you
need to add or change anything about the DataWindows SELECT statement.

4.

You can always go back into the SQL mode of the DataWindow painter should you
need to add or change anything about the DataWindows SELECT statement.

5.

Once in SQL Mode, click on DesignRetrieval Arguments on the menu bar.

5.

Once in SQL Mode, click on DesignRetrieval Arguments on the menu bar.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 7

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 7

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Lab 9 - 8

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

6.

You will need three arguments for this DataWindow object:

6.

You will need three arguments for this DataWindow object:

7.

Click OK.

7.

Click OK.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 9 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects


8.

9.

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

Use the retrieval arguments in the WHERE clause as follows:

8.

Use the retrieval arguments in the WHERE clause as follows:

OR:

OR:

(Do not forget the colon in front of the retrieval argument name.)

(Do not forget the colon in front of the retrieval argument name.)

Click the Return icon on the PainterBar to return to Design/Preview views.

9.

Click the Return icon on the PainterBar to return to Design/Preview views.

10. In the Preview view, right-click and select Retrieve.

10. In the Preview view, right-click and select Retrieve.

11. In the Specify Retrieval Arguments dialog, you can leave a space or blank in the
arg_claim_id and arg_patient_id and a date of 3-21-1999. This will retrieve three
rows.

11. In the Specify Retrieval Arguments dialog, you can leave a space or blank in the
arg_claim_id and arg_patient_id and a date of 3-21-1999. This will retrieve three
rows.

12. Retrieve again with the same date and a claim id of 200801. This should yield 4
rows. The WHERE clause used the OR logical operator.

12. Retrieve again with the same date and a claim id of 200801. This should yield 4
rows. The WHERE clause used the OR logical operator.

13. Save the DataWindow object.

13. Save the DataWindow object.

14. Close the painter.

14. Close the painter.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 9

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 9

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Task 2: Creating the Patient Details DataWindow Object


1.

Create a new DataWindow object that has the following characteristics:


Style:
Data Source:
Table:
Columns:
Sort:
Where:
Inputs:
Background color:
Columns border:

Lab 9 - 10

Task 2: Creating the Patient Details DataWindow Object


1.

FreeForm
SQL Select
Patient
All columns
(None)
patient_id = :arg_pat_id
arg_pat_id of type Number
Button Face
Lowered

Create a new DataWindow object that has the following characteristics:


Style:
Data Source:
Table:
Columns:
Sort:
Where:
Inputs:
Background color:
Columns border:

FreeForm
SQL Select
Patient
All columns
(None)
patient_id = :arg_pat_id
arg_pat_id of type Number
Button Face
Lowered

2.

Once in Design view, change the patient_id border to No Border.

2.

Once in Design view, change the patient_id border to No Border.

3.

Change all other columns to a background color of white.

3.

Change all other columns to a background color of white.

4.

Make the DataWindow visually acceptable by:

4.

Make the DataWindow visually acceptable by:

a. Giving proper label names.

a. Giving proper label names.

b. Resizing the Gender entry column.

b. Resizing the Gender entry column.

c. Grouping patient details and address details into groupbox objects on the
DataWindow. You can right-click over a groupbox object and Send to Back if
necessary.

c. Grouping patient details and address details into groupbox objects on the
DataWindow. You can right-click over a groupbox object and Send to Back if
necessary.

d. Aligning and setting equivalent spacing between column objects use the
aligning and sizing tool on the PainterBar. You can also use the lasso select to
select multiple objects. Use the arrow keys to move objects without using the
mouse.

d. Aligning and setting equivalent spacing between column objects use the
aligning and sizing tool on the PainterBar. You can also use the lasso select to
select multiple objects. Use the arrow keys to move objects without using the
mouse.

e. Move the detail band up as appropriate when done moving objects around.

e. Move the detail band up as appropriate when done moving objects around.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 9 - 10

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

5.

A sample of what the finished product should look like follows:

5.

A sample of what the finished product should look like follows:

6.

In the Preview view, right-click and select Retrieve.

6.

In the Preview view, right-click and select Retrieve.

7.

When prompted, a valid Patient ID is 10001. Adjust your DataWindow design until
your display is as follows:

7.

When prompted, a valid Patient ID is 10001. Adjust your DataWindow design until
your display is as follows:

8.

In the Design view, click on the date_of_birth column.

8.

In the Design view, click on the date_of_birth column.

9.

In the Properties view use the arrows to scroll the tabs right until you see the Format
tab.

9.

In the Properties view use the arrows to scroll the tabs right until you see the Format
tab.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 11

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 11

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

10. The mmm-dd-yyyy Display Format you created in Lab 8 was copied into this
DataWindow.

10. The mmm-dd-yyyy Display Format you created in Lab 8 was copied into this
DataWindow.

11. Click on the Edit tab in Properties.

11. Click on the Edit tab in Properties.

12. There is no Edit Style associated with this column. Add an Edit Style while here in
the DataWindow painter.

12. There is no Edit Style associated with this column. Add an Edit Style while here in
the DataWindow painter.

13. Change the Style Type to EditMask.

13. Change the Style Type to EditMask.

14. Change the Mask to mm/dd/yyyy.

14. Change the Mask to mm/dd/yyyy.

15. Enable the Drop Down Calendar property (PowerBuilder 10.5 and greater).

15. Enable the Drop Down Calendar property (PowerBuilder 10.5 and greater).

16. Look at the Preview view, the date_of_birth column.

16. Look at the Preview view, the date_of_birth column.

17. When a single column has both a Display Format and an Edit Style, which one
prevails?

17. When a single column has both a Display Format and an Edit Style, which one
prevails?

_____________________________________________________________________

_____________________________________________________________________

18. Can you make the Display Format prevail? To answer, go back to the Properties
view, on the Format tab and enable this property:

18. Can you make the Display Format prevail? To answer, go back to the Properties
view, on the Format tab and enable this property:

_____________________________________________________________________

Lab 9 - 12

_____________________________________________________________________

19. Look at your Preview view to see the change.

19. Look at your Preview view to see the change.

20. Disable the Use Format property.

20. Disable the Use Format property.

21. In Preview view, click the drop down arrow of the state column. Scroll through all of
the states. You should see some of the state names cut off because of the width of the
drop down.

21. In Preview view, click the drop down arrow of the state column. Scroll through all of
the states. You should see some of the state names cut off because of the width of the
drop down.

22. In the Design view, click on the state_code column.

22. In the Design view, click on the state_code column.

23. In Properties, on the Edit tab, change Width Of Dropdown(%) to 450.

23. In Properties, on the Edit tab, change Width Of Dropdown(%) to 450.

24. Go back to the Preview view and click on the drop down arrow for State again. The
cutting off of data should be resolved.

24. Go back to the Preview view and click on the drop down arrow for State again. The
cutting off of data should be resolved.

25. Set the Tab Order of patient_id to a value of 0, all others remain as is.

25. Set the Tab Order of patient_id to a value of 0, all others remain as is.

26. Save the DWO (DataWindow Object) as d_patient_details in the patients.pbl.

26. Save the DWO (DataWindow Object) as d_patient_details in the patients.pbl.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 9 - 12

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

Task 3: Creating the New/Edit Policy DataWindow Object


1.

Module 9: DataWindow Technology Overview and DataWindow Objects

Task 3: Creating the New/Edit Policy DataWindow Object

Create a new DataWindow object that has the following characteristics:


Style:
Data Source:
Table:
Columns:
Sort:
Where:
Inputs:
Background color:
Columns border:

1.

FreeForm
SQL Select
Insurance_Policy
All columns
(None)
patient_id = :arg_pat_id
arg_pat_id of type Number
Button Face
Lowered

Style:
Data Source:
Table:
Columns:
Sort:
Where:
Inputs:
Background color:
Columns border:

FreeForm
SQL Select
Insurance_Policy
All columns
(None)
patient_id = :arg_pat_id
arg_pat_id of type Number
Button Face
Lowered

2.

Arrange the Design view of your DataWindow as follows:

2.

Arrange the Design view of your DataWindow as follows:

3.

Change the start_date and end_date columns to use an EditMask Edit Style
(Properties view). Enable the use of the Drop Down Calendar.

3.

Change the start_date and end_date columns to use an EditMask Edit Style
(Properties view). Enable the use of the Drop Down Calendar.

4.

Click on the status column in the Design view.

4.

Click on the status column in the Design view.

5.

Add an Edit Style of type DropDownListBox.

5.

Add an Edit Style of type DropDownListBox.

6.

Enable the Always Show Arrow property.

6.

Enable the Always Show Arrow property.

7.

In the Code Table, display Active for a value of A, Inactive for a value of I.

7.

In the Code Table, display Active for a value of A, Inactive for a value of I.

8.

Test your work in the Preview view. Click on your date columns to make sure you
have a calendar. Click on the status column to see your drop down choices.

8.

Test your work in the Preview view. Click on your date columns to make sure you
have a calendar. Click on the status column to see your drop down choices.

9.

Click on the insurance_type column. That drop down, when active, is too wide and
displays too many rows.

9.

Click on the insurance_type column. That drop down, when active, is too wide and
displays too many rows.

10. Click on the insurance_type column in Design view. On the Edit tab in Properties,
change the Width of Drop Down(%) to 250 and the Lines in DropDown to 2.

2010 Sybase, Inc.

Create a new DataWindow object that has the following characteristics:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 13

10. Click on the insurance_type column in Design view. On the Edit tab in Properties,
change the Width of Drop Down(%) to 250 and the Lines in DropDown to 2.

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 13

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

11. In Preview, click on the coverage drop down to see your changes.

11. In Preview, click on the coverage drop down to see your changes.

12. Save your DataWindow object as d_policy_edit in the patients.pbl.

12. Save your DataWindow object as d_policy_edit in the patients.pbl.

Task 4: Creating the New/Edit Claim DataWindow Object

Task 4: Creating the New/Edit Claim DataWindow Object

1. Create a new DataWindow object that has the following characteristics:


Style:
Data Source:
Table:
Columns:
Sort:
Where:
Inputs:
Background color:
Columns border:

Lab 9 - 14

1. Create a new DataWindow object that has the following characteristics:

FreeForm
SQL Select
Claims
All columns
(None)
claim_id = :arg_claim_id
arg_claim_id of type Number
Button Face
Lowered

Style:
Data Source:
Table:
Columns:
Sort:
Where:
Inputs:
Background color:
Columns border:

FreeForm
SQL Select
Claims
All columns
(None)
claim_id = :arg_claim_id
arg_claim_id of type Number
Button Face
Lowered

2. Arrange the Design view of your DataWindow as follows:

2. Arrange the Design view of your DataWindow as follows:

3. In the Preview view, right-click and Retrieve with a claim id of 200801.

3. In the Preview view, right-click and Retrieve with a claim id of 200801.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 9 - 14

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

4. After experimenting with the interface (Preview), you can reduce the Width of the
Type and Status columns.

4. After experimenting with the interface (Preview), you can reduce the Width of the
Type and Status columns.

5. Give the Claim Date column a drop down calendar.

5. Give the Claim Date column a drop down calendar.

6. Assign the following Edit Mask to the dr_charges and amount_paid columns:

6. Assign the following Edit Mask to the dr_charges and amount_paid columns:

7. Since the Patient and Doctor numbers dont help a user very much, you will create
some DropDownDataWindows for those two columns. When adding a new claim, the
user can select from the Patient and Doctor from the drop down that will display their
name while saving the ids into the claims table columns.

7. Since the Patient and Doctor numbers dont help a user very much, you will create
some DropDownDataWindows for those two columns. When adding a new claim, the
user can select from the Patient and Doctor from the drop down that will display their
name while saving the ids into the claims table columns.

8. Before creating the DDDWs, save your DataWindow as d_claims_edit in the


claims.pbl. Leave the painter open while performing the next steps.

8. Before creating the DDDWs, save your DataWindow as d_claims_edit in the


claims.pbl. Leave the painter open while performing the next steps.

9. Create a new tabular DataWindow against the doctors table, selecting only the dr_id
column and adding a compute as follows:

9. Create a new tabular DataWindow against the doctors table, selecting only the dr_id
column and adding a compute as follows:

10. Sort based on the computed column, ascending.

10. Sort based on the computed column, ascending.

11. Return to Design view.

11. Return to Design view.

12. Remove the header objects.

12. Remove the header objects.

13. Set Tab Order to 0 for all columns.

13. Set Tab Order to 0 for all columns.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 15

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 15

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Lab 9 - 16

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

14. Your DataWindow should look as follows:

14. Your DataWindow should look as follows:

15. Save as d_dddw_doc_list in the doctors.pbl.

15. Save as d_dddw_doc_list in the doctors.pbl.

16. Close the DataWindow painter.

16. Close the DataWindow painter.

17. Back on d_claims_edit, in Design view, click on the dr_id column and then select the
Edit tab in the Properties view.

17. Back on d_claims_edit, in Design view, click on the dr_id column and then select the
Edit tab in the Properties view.

18. Set StyleType to DropDownDW.

18. Set StyleType to DropDownDW.

19. Enable Always Show Arrow and Vertical Scroll Bar.

19. Enable Always Show Arrow and Vertical Scroll Bar.

20. Set Width of DropDown(%) to 350.

20. Set Width of DropDown(%) to 350.

21. Scroll down and set the DataWindow property to d_dddw_doc_list.

21. Scroll down and set the DataWindow property to d_dddw_doc_list.

22. Scroll down more and set the Display Column (what is displayed when the drop down
is not active) to use docfullname.

22. Scroll down more and set the Display Column (what is displayed when the drop down
is not active) to use docfullname.

23. Set the Data Column (what will be written back to the claims table) to use dr_id.

23. Set the Data Column (what will be written back to the claims table) to use dr_id.

24. Re-retrieve in the Preview view.

24. Re-retrieve in the Preview view.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 9 - 16

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

25. Test your Doctor drop down. You may need to widen the display as shown below:

25. Test your Doctor drop down. You may need to widen the display as shown below:

26. Time permitting; repeat the above steps to create a drop down for Patient. The final
Claim Edit DataWindow should look as follows:

26. Time permitting; repeat the above steps to create a drop down for Patient. The final
Claim Edit DataWindow should look as follows:

27. Set the Tab Order of the claim_id column to 0.

27. Set the Tab Order of the claim_id column to 0.

28. Save your work and close the DataWindow painter.

28. Save your work and close the DataWindow painter.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 17

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 17

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Lab 9-3: Building Report DataWindows

Lab 9-3: Building Report DataWindows

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Use some of the more advanced features of the DataWindow painter.

Use some of the more advanced features of the DataWindow painter.

Description:

In this lab, you will build one report DataWindow object, and copy in some pre-defined
reports for later use by the application.

Description:

In this lab, you will build one report DataWindow object, and copy in some pre-defined
reports for later use by the application.

Task Outline:

Task 1: Creating the Claims Summary Report

Task Outline:

Task 1: Creating the Claims Summary Report

Task 2: Copying Pre-defined Reports

Lab 9 - 18

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Copying Pre-defined Reports

2010 Sybase, Inc.

Lab 9 - 18

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

Module 9: DataWindow Technology Overview and DataWindow Objects

Detailed Instructions

Detailed Instructions

Task 1: Creating the Claims Summary Report

Task 1: Creating the Claims Summary Report

1. Create a new tabular DataWindow object.

1. Create a new tabular DataWindow object.

2. Select the claims and patient tables and click Open.

2. Select the claims and patient tables and click Open.

3. From the claims table, select the following columns:

3. From the claims table, select the following columns:

a. Claim_id

a. Claim_id

b. Dr_charges

b. Dr_charges

c. Amount_paid

c. Amount_paid

d. Status_code

d. Status_code

e. Claim_code

e. Claim_code

4. From the patient table select the following columns:

2010 Sybase, Inc.

4. From the patient table select the following columns:

a. Patient_id

a. Patient_id

b. First_name

b. First_name

c. Last_name

c. Last_name

d. Date_of_birth

d. Date_of_birth

e. Gender

e. Gender

f.

f.

Phone_no

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 19

2010 Sybase, Inc.

Phone_no

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 19

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Lab 9 - 20

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

5. Click on the Join symbol to view the details of the join. Change to use an outer join
displaying patients that may or may not have submitted claims:

5. Click on the Join symbol to view the details of the join. Change to use an outer join
displaying patients that may or may not have submitted claims:

6. In a multi-table DataWindow, always check your joins.

6. In a multi-table DataWindow, always check your joins.

7. Click OK to close the Join dialog.

7. Click OK to close the Join dialog.

8. Click the Return icon on the PainterBar.

8. Click the Return icon on the PainterBar.

9. Accept the defaults for the remaining prompts and enter the Design/Preview view.

9. Accept the defaults for the remaining prompts and enter the Design/Preview view.

10. Right-click in the Preview view to retrieve your data.

10. Right-click in the Preview view to retrieve your data.

11. Save the DataWindow object as d_rpt_all_claims_summary in the SybHealth.pbl.

11. Save the DataWindow object as d_rpt_all_claims_summary in the SybHealth.pbl.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 9 - 20

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

12. Next, you will spend some time formatting this report so that it looks as follows:

12. Next, you will spend some time formatting this report so that it looks as follows:

13. Still in the DataWindow painter, select RowsSort from the menu.

13. Still in the DataWindow painter, select RowsSort from the menu.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 21

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 21

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Lab 9 - 22

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

14. Sort on the patient_patient_id column by dragging that column to the Columns list.
This is a client-side sort versus using the Order By (server-side) sort:

14. Sort on the patient_patient_id column by dragging that column to the Columns list.
This is a client-side sort versus using the Order By (server-side) sort:

15. Click OK.

15. Click OK.

16. Select RowsCreate Group from the menu.

16. Select RowsCreate Group from the menu.

17. Drag patient_patient_id from Source Data to Columns:

17. Drag patient_patient_id from Source Data to Columns:

18. Click OK.

18. Click OK.

19. Notice the addition of two new bands for this DataWindow object, a header and a
trailer for the group.

19. Notice the addition of two new bands for this DataWindow object, a header and a
trailer for the group.

20. Click and drag the Header group patient_patient_id band down to make space for other
objects to be placed in this band.

20. Click and drag the Header group patient_patient_id band down to make space for other
objects to be placed in this band.

21. Add text object(s) to the Header group patient_patient_id by clicking Insert Control
Text on the menu. You will need 5 text controls in this band: ID:, Patient:, Date of
Birth:, Gender:, and Phone:. Arrange these in a left to right fashion, leaving room
between each text object for data that will be added in a following step.

21. Add text object(s) to the Header group patient_patient_id by clicking Insert Control
Text on the menu. You will need 5 text controls in this band: ID:, Patient:, Date of
Birth:, Gender:, and Phone:. Arrange these in a left to right fashion, leaving room
between each text object for data that will be added in a following step.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 9 - 22

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

Module 9: DataWindow Technology Overview and DataWindow Objects

22. Make each of these objects Bold and sized to 10 points.

22. Make each of these objects Bold and sized to 10 points.

23. Drag the following columns from the Detail band to the Header group:
patient_patient_id band: patient_patient_id, patient_date_of_birth, patient_gender and
patient_phone_no.

23. Drag the following columns from the Detail band to the Header group:
patient_patient_id band: patient_patient_id, patient_date_of_birth, patient_gender and
patient_phone_no.

24. Align these columns to the right of their respective labels.

24. Align these columns to the right of their respective labels.

25. Select InsertControlComputed Field to add an object in the Header group


patient_patient_id, to the right of the Patient: label.

25. Select InsertControlComputed Field to add an object in the Header group


patient_patient_id, to the right of the Patient: label.

26. In the Modify Expression dialog, enter the expression:

26. In the Modify Expression dialog, enter the expression:

patient_first_name + " " + patient_last_name

2010 Sybase, Inc.

patient_first_name + " " + patient_last_name

27. Click OK.

27. Click OK.

28. Increase the width of the computed field to display the entire name.

28. Increase the width of the computed field to display the entire name.

29. Select the Gender column. Increase the width of that column. In the Edit tab of the
Properties pane, set the StyleType to Edit.

29. Select the Gender column. Increase the width of that column. In the Edit tab of the
Properties pane, set the StyleType to Edit.

30. Use the aligning and sizing tools of the painter to clean up the Header group
patient_patient_id band. Your DataWindow should look as follows:

30. Use the aligning and sizing tools of the painter to clean up the Header group
patient_patient_id band. Your DataWindow should look as follows:

31. Drag the following objects from the Header band to the Header group:
patient_patient_id band: Claims_Claim ID, Claims_Dr_Charges, amount paid,
Claims Status Code and Claims Claim Code. Place these in a left to right fashion
under the patient_id column.

31. Drag the following objects from the Header band to the Header group:
patient_patient_id band: Claims_Claim ID, Claims_Dr_Charges, amount paid,
Claims Status Code and Claims Claim Code. Place these in a left to right fashion
under the patient_id column.

32. Individually, rename the text objects as follows: Claim ID, Charged, Paid, Status and
Type.

32. Individually, rename the text objects as follows: Claim ID, Charged, Paid, Status and
Type.

33. Make each of these objects display in a bold font.

33. Make each of these objects display in a bold font.

34. Add a line object beneath these objects. Set the Pen Width to 2.

34. Add a line object beneath these objects. Set the Pen Width to 2.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 23

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 23

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

35. Remove all remaining objects from the Header band. Your DataWindow should now
look as follows:

35. Remove all remaining objects from the Header band. Your DataWindow should now
look as follows:

36. Add a text object in the Header band that reads Claim Summary for all Patients.

36. Add a text object in the Header band that reads Claim Summary for all Patients.

37. Set the font to 16 point bold and center the text object.

37. Set the font to 16 point bold and center the text object.

38. Add one computed field in the Header band:

38. Add one computed field in the Header band:

a. In the Modify Expression dialog, enter the expression:

a. In the Modify Expression dialog, enter the expression:

String(today(),"mmmm dd, yyyy")

Lab 9 - 24

String(today(),"mmmm dd, yyyy")

b. Place this computed field under the text object in the Header band.

b. Place this computed field under the text object in the Header band.

c. Set the font size to 12.

c. Set the font size to 12.

39. Align the columns in the Detail band under their respective headers in the Header
group patient_petient_id band.

39. Align the columns in the Detail band under their respective headers in the Header
group patient_petient_id band.

40. Remove any unused columns from the Detail band.

40. Remove any unused columns from the Detail band.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 9 - 24

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

Module 9: DataWindow Technology Overview and DataWindow Objects

41. Verify that the DataWindow layout looks similar to the following figure:

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

41. Verify that the DataWindow layout looks similar to the following figure:

Lab 9 - 25

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 25

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

42. Add text objects to the Trailer group patient_patient_id band:

42. Add text objects to the Trailer group patient_patient_id band:

a. Expand the Trailer group patient_patient_id band to make space for other
objects to be placed in this band.

a. Expand the Trailer group patient_patient_id band to make space for other
objects to be placed in this band.

b. Add a text object by selecting Insert Control Text.

b. Add a text object by selecting Insert Control Text.

c. Click in the Trailer group patient_patient_id. A text object will be placed.


Replace the default text with Total Amount Paid:. Enable the Bold property.

c. Click in the Trailer group patient_patient_id. A text object will be placed.


Replace the default text with Total Amount Paid:. Enable the Bold property.

d. Repeat steps b and c above to add text objects for Total Charges:, Average
Amount Paid: and Number of Claims:

d. Repeat steps b and c above to add text objects for Total Charges:, Average
Amount Paid: and Number of Claims:

e. Align these objects in a top-down fashion.

e. Align these objects in a top-down fashion.

43. Add a computed field by selecting InsertControlComputed Field. Place this object
next to the Number of Claims text object in the Trailer group patient_patient_id band.

Lab 9 - 26

43. Add a computed field by selecting InsertControlComputed Field. Place this object
next to the Number of Claims text object in the Trailer group patient_patient_id band.

44. Set the expression to count (claims_claim_id for group 1).

44. Set the expression to count (claims_claim_id for group 1).

45. Increase the width of the computed field and click OK.

45. Increase the width of the computed field and click OK.

46. Add another computed field. Place this object next to the Total Amount Paid text
object in the Trailer group patient_patient_id band.

46. Add another computed field. Place this object next to the Total Amount Paid text
object in the Trailer group patient_patient_id band.

47. Set the expression to sum(claims_amount_paid for group 1).

47. Set the expression to sum(claims_amount_paid for group 1).

48. Click OK.

48. Click OK.

49. Increase the width of the computed field.

49. Increase the width of the computed field.

50. Similarly add two more computed fields in the Trailer group patient_patient_id band:

50. Similarly add two more computed fields in the Trailer group patient_patient_id band:

a. A computed field for Total Charges. Enter the expression:


sum(claims_dr_charges for group 1)

a. A computed field for Total Charges. Enter the expression:


sum(claims_dr_charges for group 1)

b. A computed field for Average Amount Per Claim. Enter the expression:
avg(claims_amount_paid for group 1)

b. A computed field for Average Amount Per Claim. Enter the expression:
avg(claims_amount_paid for group 1)

c. If the Total Amount Paid, Total Charges, or Average Amount Paid are not
displaying as dollar amounts: Set the computed fields format to Currency by
selecting the $ icon on the PainterBar while selecting the fields. Right-justify
the fields and resize as necessary.

c. If the Total Amount Paid, Total Charges, or Average Amount Paid are not
displaying as dollar amounts: Set the computed fields format to Currency by
selecting the $ icon on the PainterBar while selecting the fields. Right-justify
the fields and resize as necessary.

51. Place another line object at the top of the Trailer group band.

51. Place another line object at the top of the Trailer group band.

52. Add a computed field for the page count to the footer band.

52. Add a computed field for the page count to the footer band.

53. Click on the Header group patient_patient_id band in the Design view.

53. Click on the Header group patient_patient_id band in the Design view.

54. In Properties, enable the New Page on Group Break property.

54. In Properties, enable the New Page on Group Break property.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 9 - 26

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects


55. Your final DataWindow design should look like the following:

55. Your final DataWindow design should look like the following:

56. Click the Retrieve button on the PainterBar toolbar to preview with data.

56. Click the Retrieve button on the PainterBar toolbar to preview with data.

57. Save the DataWindow and close the Painter.

57. Save the DataWindow and close the Painter.

Task 2: Copying Pre-Defined Reports

2010 Sybase, Inc.

Module 9: DataWindow Technology Overview and DataWindow Objects

Task 2: Copying Pre-Defined Reports

1. In your \Student folder are three DataWindow source files (*.srd files) that represent
some additional reports for the SybHealth application.

1. In your \Student folder are three DataWindow source files (*.srd files) that represent
some additional reports for the SybHealth application.

2. Using the System Tree, right-click over the sybhealth.pbl and select the Import option,
importing each *.srd file. The import dialog allows you to multi-select objects for
importing.

2. Using the System Tree, right-click over the sybhealth.pbl and select the Import option,
importing each *.srd file. The import dialog allows you to multi-select objects for
importing.

3. Open d_rpt_patient.

3. Open d_rpt_patient.

4. Look in the detail band. There are two report objects, d_rpt_insurance_policy and
d_rpt_claims that are part of the patient detail record. This is referred to in
PowerBuilder as Nested DataWindows. Nested DataWindows are one of the topics
taught in FastTrack to PowerBuilder, Part II.

4. Look in the detail band. There are two report objects, d_rpt_insurance_policy and
d_rpt_claims that are part of the patient detail record. This is referred to in
PowerBuilder as Nested DataWindows. Nested DataWindows are one of the topics
taught in FastTrack to PowerBuilder, Part II.

5. These pre-defined reports will be used later in the application.

5. These pre-defined reports will be used later in the application.

6. Close any open painters.

6. Close any open painters.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 27

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 9 - 27

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

Lab 9 - 28

Fast Track to PowerBuilder, Part I Version 1.0

Module 9 Lab: DataWindow Technology -- Overview and DataWindow Objects

2010 Sybase, Inc.

Lab 9 - 28

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 10: Using DataWindow Controls

Module 10: Using DataWindow Controls

Module 10: Using DataWindow Controls

Module 10: Using DataWindow Controls

Lab 10-1: Coding a Basic Database Connection

Lab 10-1: Coding a Basic Database Connection

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Code basic database connection logic

Code basic database connection logic

Description:

In this lab, you will be coding the Login window so that it connects the application to the
SybHealth database. You will also code database disconnect logic in the Application
objects Close event. This code is to be viewed as quick and dirty and will be replaced
later in the course with re-usable code/objects.

Description:

In this lab, you will be coding the Login window so that it connects the application to the
SybHealth database. You will also code database disconnect logic in the Application
objects Close event. This code is to be viewed as quick and dirty and will be replaced
later in the course with re-usable code/objects.

Task Outline:

Task 1: Coding Simple Database Connection Logic

Task Outline:

Task 1: Coding Simple Database Connection Logic

Task 2: Coding Simple Database Disconnect Logic

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Coding Simple Database Disconnect Logic

Lab 10 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 1

Module 10 Lab: Using DataWindow Controls

Module 10 Lab: Using DataWindow Controls

Detailed Instructions

Detailed Instructions

Task 1: Coding Simple Database Connection Logic

Task 1: Coding Simple Database Connection Logic

1.

Open w_login in your SybHealth.pbl.

1.

Open w_login in your SybHealth.pbl.

2.

Navigate to a script view, on cb_oks clicked event. You put code here earlier.

2.

Navigate to a script view, on cb_oks clicked event. You put code here earlier.

3.

Add some new blank lines at the top of the existing code.

3.

Add some new blank lines at the top of the existing code.

4.

Refer to Module 10 in your Student Guide for assistance coding the following steps.

4.

Refer to Module 10 in your Student Guide for assistance coding the following steps.

5.

Using Dot Notation, set the following properties of the default transaction object
named SQLCA:

5.

Using Dot Notation, set the following properties of the default transaction object
named SQLCA:

a. Set the DBMS property equal to the value in the is_dbms instance variable.

a. Set the DBMS property equal to the value in the is_dbms instance variable.

b. Set the DBParm property to contain the ConnectString with the User ID and
Password.

b. Set the DBParm property to contain the ConnectString with the User ID and
Password.

6.

Script the connect statement.

6.

Script the connect statement.

7.

Test for success or failure of the connect statement. If connect failed, display a
message showing the text of what happened and set focus back to the password
singlelineedit control. If the connect was successful, write back to the INI file
(existing statements) and close the login window.

7.

Test for success or failure of the connect statement. If connect failed, display a
message showing the text of what happened and set focus back to the password
singlelineedit control. If the connect was successful, write back to the INI file
(existing statements) and close the login window.

8.

Write a message to the frame windows status bar re: connection success.

8.

Write a message to the frame windows status bar re: connection success.

9.

For extra credit, determine a way to give them three attempts to log in, after which
you HALT CLOSE the application.

9.

For extra credit, determine a way to give them three attempts to log in, after which
you HALT CLOSE the application.

10. cb_oks sample code can be found on the next page.

Lab 10 - 2

Fast Track to PowerBuilder, Part I Version 1.0

10. cb_oks sample code can be found on the next page.

2010 Sybase, Inc.

Lab 10 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 10: Using DataWindow Controls

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 3

Module 10: Using DataWindow Controls

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 3

Module 10 Lab: Using DataWindow Controls

Module 10 Lab: Using DataWindow Controls

11. The SybHealth_target is already set to open w_frame (the MDI Frame window) at
startup. See the code in the Application object (a_sybhealth) Open event.

11. The SybHealth_target is already set to open w_frame (the MDI Frame window) at
startup. See the code in the Application object (a_sybhealth) Open event.

12. Open w_frame in the Window painter.

12. Open w_frame in the Window painter.

13. In the Open event of w_frame, write a script to open your w_login window, passing
the frame (this) as the second argument to the open function call:

13. In the Open event of w_frame, write a script to open your w_login window, passing
the frame (this) as the second argument to the open function call:

Open(w_login, this)

Open(w_login, this)

14. Read in WinHelp what this second argument to the Open PowerScript function does.

14. Read in WinHelp what this second argument to the Open PowerScript function does.

15. Run your application by clicking on the Running Man on the PowerBar.

15. Run your application by clicking on the Running Man on the PowerBar.

16. Given the code, you would think the Frame window would appear, and then the login
window opens on top of the frame. Was that what you saw?

16. Given the code, you would think the Frame window would appear, and then the login
window opens on top of the frame. Was that what you saw?

_____________________________________________________________________

_____________________________________________________________________

17. Cancel/close the login window. The Frame window will appear. Close this window
and go back into the PowerBuilder IDE.

17. Cancel/close the login window. The Frame window will appear. Close this window
and go back into the PowerBuilder IDE.

18. On w_frame, create a new un-mapped event named ue_postopen. This event returns
nothing and has no arguments.

18. On w_frame, create a new un-mapped event named ue_postopen. This event returns
nothing and has no arguments.

19. Cut the code from the Open event (step 13 above) and paste it in your new
ue_postopen( ) event.

19. Cut the code from the Open event (step 13 above) and paste it in your new
ue_postopen( ) event.

20. Navigate back to w_frames Open event, and enter the following code:

20. Navigate back to w_frames Open event, and enter the following code:

this.event post ue_postopen( )

this.event post ue_postopen( )

21. Review POST versus TRIGGER syntax. By posting, we let the Open event of
w_frame complete, which will then display w_frame, while, in the background,
opening the login window on top of the frame.

21. Review POST versus TRIGGER syntax. By posting, we let the Open event of
w_frame complete, which will then display w_frame, while, in the background,
opening the login window on top of the frame.

22. Click the Running Man to test your work. The password for the application is
sybinsure. Going forward, you will be running the application many times to test
functionality. If you want to make your testing simpler, open w_login and hard
code sybinsure into the sle_pwd.text property. Also enable the cb_ok button because
we currently have code in to enable it only on key_up of the sle_pwd control.

22. Click the Running Man to test your work. The password for the application is
sybinsure. Going forward, you will be running the application many times to test
functionality. If you want to make your testing simpler, open w_login and hard
code sybinsure into the sle_pwd.text property. Also enable the cb_ok button because
we currently have code in to enable it only on key_up of the sle_pwd control.

Task 2: Coding Simple Database Disconnect Logic

Lab 10 - 4

Task 2: Coding Simple Database Disconnect Logic

1.

Open the a_sybhealth Application object.

1.

Open the a_sybhealth Application object.

2.

Navigate to the Close event. This is the very last code to run in any PowerBuilder
application.

2.

Navigate to the Close event. This is the very last code to run in any PowerBuilder
application.

3.

Script the following:

3.

Script the following:

a. Test for a valid connection using SQLCAs DBHandle( ) function.

a. Test for a valid connection using SQLCAs DBHandle( ) function.

b. If you have a valid connection, disconnect from the database.

b. If you have a valid connection, disconnect from the database.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 10 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 10: Using DataWindow Controls

2010 Sybase, Inc.

Module 10: Using DataWindow Controls

c. Error trap the disconnect statement in the same way we did in the connect
logic. This is also an embedded SQL statement.

c. Error trap the disconnect statement in the same way we did in the connect
logic. This is also an embedded SQL statement.

d. Sample code follows:

d. Sample code follows:

4.

Test your work and when done, exit the running application.

4.

Test your work and when done, exit the running application.

5.

Close any open Painters.

5.

Close any open Painters.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 5

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 5

Module 10 Lab: Using DataWindow Controls

Module 10 Lab: Using DataWindow Controls

Lab 10-2: Completing Application Sheets

Lab 10-2: Completing Application Sheets

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Display data in some of the SybHealth sheets.

Display data in some of the SybHealth sheets.

Description:

In this lab, you will be coding data retrieval for some of the SybHealth application sheets.
You will complete the Doctor List window, the Claims Search window and the Patient
Search window (to be used on the Claims Search interface).

Description:

In this lab, you will be coding data retrieval for some of the SybHealth application sheets.
You will complete the Doctor List window, the Claims Search window and the Patient
Search window (to be used on the Claims Search interface).

Task Outline:

Task 1: Retrieving the Doctor List

Task Outline:

Task 1: Retrieving the Doctor List

Lab 10 - 6

Task 2: Retrieving the Patient Search Data

Task 2: Retrieving the Patient Search Data

Task 3: Completing the Claims Search Interface

Task 3: Completing the Claims Search Interface

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 10 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 10: Using DataWindow Controls

Module 10: Using DataWindow Controls

Detailed Instructions

Detailed Instructions

Task 1: Retrieving the Doctor List

Task 1: Retrieving the Doctor List

1.

Open w_doctor_list in the Window painter.

1.

Open w_doctor_list in the Window painter.

2.

Make sure you are on the Layout view of the Window painter and then click on the
DataWindow control.

2.

Make sure you are on the Layout view of the Window painter and then click on the
DataWindow control.

3.

Make note below of the name of the DataWindow Control (DWC):

3.

Make note below of the name of the DataWindow Control (DWC):

_____________________________________________________________________

_____________________________________________________________________

4.

Using the ellipsis button of the DataObject property, associate d_grid_doctors with
the DataWindow control.

4.

Using the ellipsis button of the DataObject property, associate d_grid_doctors with
the DataWindow control.

5.

Headers will appear in the layout, but no data.

5.

Headers will appear in the layout, but no data.

6.

Save and close w_doctor_list.

6.

Save and close w_doctor_list.

7.

The SybHealth application will talk to only one database, as will many of your
applications. In that case, the code to associate the DataWindow control with the
Transaction object (SQLCA) is constant. In order to make the coding and
maintenance easier, open u_dw in the User Object painter.

7.

The SybHealth application will talk to only one database, as will many of your
applications. In that case, the code to associate the DataWindow control with the
Transaction object (SQLCA) is constant. In order to make the coding and
maintenance easier, open u_dw in the User Object painter.

8.

Navigate to the Constructor event.

8.

Navigate to the Constructor event.

9.

Call the SetTransObject( ) function, associating the DataWindow control (THIS) with
the SQLCA Transaction object. Always code generic!

9.

Call the SetTransObject( ) function, associating the DataWindow control (THIS) with
the SQLCA Transaction object. Always code generic!

this.SetTransObject(SQLCA)

2010 Sybase, Inc.

this.SetTransObject(SQLCA)

10. SetTransObject( ) must be called before each DataWindows first Retrieve( ) or


Update( ) (or InsertRow( ) if the DataWindow has DropDownDataWindows that
AutoRetrieve).

10. SetTransObject( ) must be called before each DataWindows first Retrieve( ) or


Update( ) (or InsertRow( ) if the DataWindow has DropDownDataWindows that
AutoRetrieve).

11. Close and save u_dw.

11. Close and save u_dw.

12. Re-open w_doctor_list.

12. Re-open w_doctor_list.

13. In the windows Open event code the following:

13. In the windows Open event code the following:

a. Declare a long variable named ll_rows to hold the DataWindows row


retrieved count.

a. Declare a long variable named ll_rows to hold the DataWindows row


retrieved count.

b. Call the DWCs Retrieve( ) function, catching the return in the ll_rows
variable.

b. Call the DWCs Retrieve( ) function, catching the return in the ll_rows
variable.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 7

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 7

Module 10 Lab: Using DataWindow Controls

Module 10 Lab: Using DataWindow Controls

c. In a CHOOSE CASE, evaluate the value of ll_rows. Possible cases are -1:
Error, 0: No rows returned and > 0 is one to many rows returned. Display
appropriate error messages in the case statements and close the window if and
when appropriate. If rows are returned, programmatically set focus to the
DWC.

Lab 10 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

c. In a CHOOSE CASE, evaluate the value of ll_rows. Possible cases are -1:
Error, 0: No rows returned and > 0 is one to many rows returned. Display
appropriate error messages in the case statements and close the window if and
when appropriate. If rows are returned, programmatically set focus to the
DWC.

Lab 10 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 10: Using DataWindow Controls

14. Sample code is provided below:

14. Sample code is provided below:

15. Save your work and test by clicking the Running Man icon.

15. Save your work and test by clicking the Running Man icon.

16. Once logged in and in the MDI Frame, click on FileOpenDoctors List. The data
should be there.

16. Once logged in and in the MDI Frame, click on FileOpenDoctors List. The data
should be there.

17. One of the features of the Grid presentation style DataWindow is the user can, at
runtime, resize columns and drag them into the desired order. These changes are only
temporary. Experiment with these features.

17. One of the features of the Grid presentation style DataWindow is the user can, at
runtime, resize columns and drag them into the desired order. These changes are only
temporary. Experiment with these features.

18. Exit the application and close any open painters.

18. Exit the application and close any open painters.

Task 2: Retrieving the Patient Search Data

2010 Sybase, Inc.

Module 10: Using DataWindow Controls

Task 2: Retrieving the Patient Search Data

1.

Open w_patient_search in the Window painter.

1.

Open w_patient_search in the Window painter.

2.

Click on the DataWindow control (Layout view).

2.

Click on the DataWindow control (Layout view).

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 9

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 9

Module 10 Lab: Using DataWindow Controls


3.

Module 10 Lab: Using DataWindow Controls

Make note below of the name of the DataWindow Control (DWC):

3.

_____________________________________________________________________

_____________________________________________________________________

4.

Using the ellipsis button of the DataObject property, associate d_dddw_pat_list with
the DataWindow control.

4.

Using the ellipsis button of the DataObject property, associate d_dddw_pat_list with
the DataWindow control.

5.

No headers will appear in the layout because there are none in the DataWindow
object.

5.

No headers will appear in the layout because there are none in the DataWindow
object.

6.

Resize the windows width to 1500 and dw_datas width to 1450.

6.

Resize the windows width to 1500 and dw_datas width to 1450.

7.

SetTransObject( ) was called in u_dws constructor (u_dw was used on all windows
in our application). It doesnt need to be coded here.

7.

SetTransObject( ) was called in u_dws constructor (u_dw was used on all windows
in our application). It doesnt need to be coded here.

8.

In the windows Open event code the retrieve exactly as you did for w_doctor_list in
Task 1.

8.

In the windows Open event code the retrieve exactly as you did for w_doctor_list in
Task 1.

9.

Close and save your work.

9.

Close and save your work.

10. Open w_claims_search.

10. Open w_claims_search.

11. Script the ellipsis button () named cb_patid_search.

11. Script the ellipsis button () named cb_patid_search.

12. In the buttons clicked event, open the w_patient_search window (use Open( ) and not
OpenSheet( ) as this is a Response type window).

12. In the buttons clicked event, open the w_patient_search window (use Open( ) and not
OpenSheet( ) as this is a Response type window).

13. Save your work and test by clicking the Running Man icon.

13. Save your work and test by clicking the Running Man icon.

14. Log in. On the MDI Frame, click on FileOpenClaims Search.

14. Log in. On the MDI Frame, click on FileOpenClaims Search.

15. Click on the Ellipsis button on the Claims Search window. You should see your
patient data. You can click on a row, but there is no visual cue that the row was
selected. You will script row highlight logic later in this lab.

15. Click on the Ellipsis button on the Claims Search window. You should see your
patient data. You can click on a row, but there is no visual cue that the row was
selected. You will script row highlight logic later in this lab.

16. You will also be adding code later to get the ID of the patient selected and pass it back
to the Claims Lookup window. Exit the running application.

16. You will also be adding code later to get the ID of the patient selected and pass it back
to the Claims Lookup window. Exit the running application.

17. Close any open painters.

17. Close any open painters.

Task 3: Completing the Claims Search Interface

Task 3: Completing the Claims Search Interface

1.

Open w_claims_search in the Window painter.

1.

Open w_claims_search in the Window painter.

2.

Click on the DataWindow control (Layout view).

2.

Click on the DataWindow control (Layout view).

3.

Make note below of the name of the DataWindow Control (DWC):

3.

Make note below of the name of the DataWindow Control (DWC):

_____________________________________________________________________

Lab 10 - 10

Make note below of the name of the DataWindow Control (DWC):

_____________________________________________________________________

4.

Using the ellipsis button of the DataObject property, associate d_claims_list with the
DataWindow control.

4.

Using the ellipsis button of the DataObject property, associate d_claims_list with the
DataWindow control.

5.

Headers will appear in the layout.

5.

Headers will appear in the layout.

6.

For this interface, the Retrieve will be coded when the user clicks the Search button.
Navigate to a script view for cb_search.

6.

For this interface, the Retrieve will be coded when the user clicks the Search button.
Navigate to a script view for cb_search.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 10 - 10

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 10: Using DataWindow Controls


7.

In cb_searchs Clicked event code the following:

7.

In cb_searchs Clicked event code the following:

a. Declare three long variables to hold claim id, patient id and a row count.

a. Declare three long variables to hold claim id, patient id and a row count.

b. Declare a date variable to hold date of claim.

b. Declare a date variable to hold date of claim.

c. Assign to the claim id and patient id variables using Dot Notation, reading
from the associated singlelineedit controls. Cast the data to the appropriate
type before assigning it to the variable.

c. Assign to the claim id and patient id variables using Dot Notation, reading
from the associated singlelineedit controls. Cast the data to the appropriate
type before assigning it to the variable.

d. The claim date uses an EditMask control. You will get that value differently.
Call the EditMasks (em_claim_date) GetData( ) function, passing in the date
variable by reference. See WinHelp on GetData( ) of an EditMask for an
example of its use.

d. The claim date uses an EditMask control. You will get that value differently.
Call the EditMasks (em_claim_date) GetData( ) function, passing in the date
variable by reference. See WinHelp on GetData( ) of an EditMask for an
example of its use.

e. You must determine which order to pass these variables to the DataWindow.
To determine order, click on the Layout tab of the Window painter. Rightclick over the DWC and select Modify DataWindow When the
DataWindow painter opens, click DesignData Source Then click
DesignRetrieval Arguments. Write the order of the arguments below:

e. You must determine which order to pass these variables to the DataWindow.
To determine order, click on the Layout tab of the Window painter. Rightclick over the DWC and select Modify DataWindow When the
DataWindow painter opens, click DesignData Source Then click
DesignRetrieval Arguments. Write the order of the arguments below:

f.

2010 Sybase, Inc.

Module 10: Using DataWindow Controls

_______________________________________________________________

_______________________________________________________________

_______________________________________________________________

_______________________________________________________________

_______________________________________________________________

_______________________________________________________________

Close the Retrieval Arguments dialog, click the Return icon on the PainterBar,
and then close the DataWindow painter.

f.

Close the Retrieval Arguments dialog, click the Return icon on the PainterBar,
and then close the DataWindow painter.

g. Navigate back to cb_searchs Clicked event.

g. Navigate back to cb_searchs Clicked event.

h. Call dw_datas Retrieve( ) passing in the three variables in the correct order
you learned above, catching the return of the Retrieve( ) in the row count
variable. Evaluate with a CHOOSE CASE as you have done before.

h. Call dw_datas Retrieve( ) passing in the three variables in the correct order
you learned above, catching the return of the Retrieve( ) in the row count
variable. Evaluate with a CHOOSE CASE as you have done before.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 11

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 11

Module 10 Lab: Using DataWindow Controls

Module 10 Lab: Using DataWindow Controls

8.

The complete cb_search Clicked code can be seen below:

8.

The complete cb_search Clicked code can be seen below:

9.

Close and save your work.

9.

Close and save your work.

10. Test by clicking the Running Man icon.

10. Test by clicking the Running Man icon.

11. Log in. On the MDI Frame, click on FileOpenClaims Search.

11. Log in. On the MDI Frame, click on FileOpenClaims Search.

12. Valid search criteria include:

12. Valid search criteria include:

a. Claim ID: 200801

a. Claim ID: 200801

b. Patient ID: 10001

b. Patient ID: 10001

c. Claim Date: 10/15/2000

c. Claim Date: 10/15/2000

13. Once tested, exit the running application and close any open painters.

Lab 10 - 12

Fast Track to PowerBuilder, Part I Version 1.0

13. Once tested, exit the running application and close any open painters.

2010 Sybase, Inc.

Lab 10 - 12

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 10: Using DataWindow Controls

Module 10: Using DataWindow Controls

Lab 10-3: Enabling Basic DataWindow Functionality

Lab 10-3: Enabling Basic DataWindow Functionality

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Code to highlight selected rows in a DataWindow.

Code to highlight selected rows in a DataWindow.

Print from your DataWindows.

Print from your DataWindows.

Export data from your DataWindows.

Export data from your DataWindows.

Description:

In this lab, you will be coding some basic DataWindow functionality such as row
highlighting (both single and multi-select), in a re-usable fashion. You will also be
allowing the user to print and export data from selected DataWindows.

Description:

In this lab, you will be coding some basic DataWindow functionality such as row
highlighting (both single and multi-select), in a re-usable fashion. You will also be
allowing the user to print and export data from selected DataWindows.

Task Outline:

Task 1: Scripting Row Highlight Logic

Task Outline:

Task 1: Scripting Row Highlight Logic

2010 Sybase, Inc.

Task 2: Printing from DataWindows

Task 2: Printing from DataWindows

Task 3: Exporting Data from DataWindows

Task 3: Exporting Data from DataWindows

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 13

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 13

Module 10 Lab: Using DataWindow Controls

Module 10 Lab: Using DataWindow Controls

Detailed Instructions

Detailed Instructions

Task 1: Scripting Row Highlight Logic

Task 1: Scripting Row Highlight Logic

Lab 10 - 14

1.

Scripting row highlighting is a very common task, one which belongs in our ancestor
DataWindow control.

1.

Scripting row highlighting is a very common task, one which belongs in our ancestor
DataWindow control.

2.

Open u_dw.

2.

Open u_dw.

3.

Review the instance variables, both Boolean, named ib_single_select and


ib_multi_select. These properties were created in an earlier lab.

3.

Review the instance variables, both Boolean, named ib_single_select and


ib_multi_select. These properties were created in an earlier lab.

4.

Users may either click on a row to change focus, or they may use the arrow keys.
Given that, navigate to u_dws RowFocusChanged event. Be careful. There is also a
RowFocusChanging event you will not be coding.

4.

Users may either click on a row to change focus, or they may use the arrow keys.
Given that, navigate to u_dws RowFocusChanged event. Be careful. There is also a
RowFocusChanging event you will not be coding.

5.

Script RowFocusChanged as follows:

5.

Script RowFocusChanged as follows:

a. If ib_single_select is true then code single-row selection.

a. If ib_single_select is true then code single-row selection.

b. If ib_multi_select is true, then code multiple-row selection.

b. If ib_multi_select is true, then code multiple-row selection.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 10 - 14

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 10: Using DataWindow Controls

2010 Sybase, Inc.

Module 10: Using DataWindow Controls

6.

A solution for step 5 is shown below:

6.

A solution for step 5 is shown below:

7.

Close and save u_dw.

7.

Close and save u_dw.

8.

Re-open w_patient_search.

8.

Re-open w_patient_search.

9.

On the Layout view, click on the DWC.

9.

On the Layout view, click on the DWC.

10. In the Properties view, scroll to the bottom and enable ib_single_select.

10. In the Properties view, scroll to the bottom and enable ib_single_select.

11. Close and save w_patient_search.

11. Close and save w_patient_search.

12. Re-open w_claims_search.

12. Re-open w_claims_search.

13. On the Layout view, click on the DWC.

13. On the Layout view, click on the DWC.

14. In the Properties view, enable ib_single_select.

14. In the Properties view, enable ib_single_select.

15. Close and save w_claims_search.

15. Close and save w_claims_search.

16. Enable ib_single_select for w_doctor_list.

16. Enable ib_single_select for w_doctor_list.

17. Run the application to test your work. When a row is selected, it is now highlighted
with a blue bar. Note that RowFocusChanged automatically fired on the Retreive( )
as well.

17. Run the application to test your work. When a row is selected, it is now highlighted
with a blue bar. Note that RowFocusChanged automatically fired on the Retreive( )
as well.

18. Click FileOpenDoctor List. When you click a column in the grid it is editable.
Click FileOpenClaims Search. When you click on a column, you cannot edit the
column, but the column turns black which conflicts with the blue status bar. You will
now fix these issues.

18. Click FileOpenDoctor List. When you click a column in the grid it is editable.
Click FileOpenClaims Search. When you click on a column, you cannot edit the
column, but the column turns black which conflicts with the blue status bar. You will
now fix these issues.

19. Open d_grid_doctors.

19. Open d_grid_doctors.

20. Set the Tab Order of all columns to 0.

20. Set the Tab Order of all columns to 0.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 15

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 15

Module 10 Lab: Using DataWindow Controls

Module 10 Lab: Using DataWindow Controls

21. On the DataWindows General Properties view, disable Mouse Selection.

21. On the DataWindows General Properties view, disable Mouse Selection.

22. Close and save d_grid_doctors.

22. Close and save d_grid_doctors.

23. Open d_claims_list.

23. Open d_claims_list.

24. On the DataWindows General Properties view, disable Mouse Selection.

24. On the DataWindows General Properties view, disable Mouse Selection.

25. Re-run the application, evaluating these changes.

25. Re-run the application, evaluating these changes.

26. Exit the application and any close any open painters.

26. Exit the application and any close any open painters.

Task 2: Printing from DataWindows

Task 2: Printing from DataWindows

1.

Open w_data_sheet (windows_abstract.pbl).

1.

Open w_data_sheet (windows_abstract.pbl).

2.

Stub events were added to this window in earlier labs. One event was ue_print.

2.

Stub events were added to this window in earlier labs. One event was ue_print.

3.

Script ue_print as follows:

3.

Script ue_print as follows:

dw_data.print( )

dw_data.print( )

4.

Close and save.

4.

Close and save.

5.

Since both w_doctors_list and w_claims_search are inherited from w_data_sheet, you
have just taken care of printing for both windows.

5.

Since both w_doctors_list and w_claims_search are inherited from w_data_sheet, you
have just taken care of printing for both windows.

6.

Run the application and when the above windows are open, click on the Print icon on
the toolbar. It was coded earlier to invoke the ue_print event.

6.

Run the application and when the above windows are open, click on the Print icon on
the toolbar. It was coded earlier to invoke the ue_print event.

7.

There is no printer in the classroom, but you should see the print dialog and if you
print, will receive an error that the printer has a problem. Disregard these errors.

7.

There is no printer in the classroom, but you should see the print dialog and if you
print, will receive an error that the printer has a problem. Disregard these errors.

8.

Open w_patient_master_detail.

8.

Open w_patient_master_detail.

9.

Navigate to the ue_print( ) event on the window.

9.

Navigate to the ue_print( ) event on the window.

10. In ue_print( ):

Lab 10 - 16

10. In ue_print( ):

a. Right-click and disable the Extend Ancestor Script option on the context
menu. You will be overriding the ancestor code you just put into the
w_data_sheet because Master-Detail displays require a different approach.

a. Right-click and disable the Extend Ancestor Script option on the context
menu. You will be overriding the ancestor code you just put into the
w_data_sheet because Master-Detail displays require a different approach.

b. Declare a long variable named ll_prt.

b. Declare a long variable named ll_prt.

c. Assign to ll_prt by calling the PrintOpen( ) function. Pass in one argument to


PrintOpen( ), Patient Master Detail. Use WinHelp to determine what this
argument does. If using PowerBuilder 11, this function allows you to pass in
two arguments.

c. Assign to ll_prt by calling the PrintOpen( ) function. Pass in one argument to


PrintOpen( ), Patient Master Detail. Use WinHelp to determine what this
argument does. If using PowerBuilder 11, this function allows you to pass in
two arguments.

d. Call the PrintDataWindow( ) function passing ll_prt and dw_master as the two
arguments.

d. Call the PrintDataWindow( ) function passing ll_prt and dw_master as the two
arguments.

e. Call the PrintDataWindow( ) function, this time passing ll_prt and dw_detail
as the two arguments.

e. Call the PrintDataWindow( ) function, this time passing ll_prt and dw_detail
as the two arguments.

f.

f.

Call the PrintClose( ) function passing ll_prt as the argument.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 10 - 16

Call the PrintClose( ) function passing ll_prt as the argument.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 10: Using DataWindow Controls

Module 10: Using DataWindow Controls

11. Sample code follows:

11. Sample code follows:

12. Save and close w_patient_master_detail.

12. Save and close w_patient_master_detail.

13. Run the application to test the printing of the Master-Detail window. The window is
incomplete at this point, but you can still test printing. You should see the Print
dialog appear.

13. Run the application to test the printing of the Master-Detail window. The window is
incomplete at this point, but you can still test printing. You should see the Print
dialog appear.

14. Exit the application.

14. Exit the application.

Task 3: Exporting Data from DataWindows

Task 3: Exporting Data from DataWindows

1.

Re-open w_data_sheet.

1.

Re-open w_data_sheet.

2.

Add a new unmapped event to the window. Name this event ue_export. It will return
nothing and have no arguments.

2.

Add a new unmapped event to the window. Name this event ue_export. It will return
nothing and have no arguments.

3.

Code the event to call the DataWindows SaveAs( ) function. Call dw_datas
SaveAs( ) passing it no arguments. With no arguments, SaveAs( ) displays a
Windows File-Save dialog. The user can select the type of data to export and the
directory.

3.

Code the event to call the DataWindows SaveAs( ) function. Call dw_datas
SaveAs( ) passing it no arguments. With no arguments, SaveAs( ) displays a
Windows File-Save dialog. The user can select the type of data to export and the
directory.

4.

Save and close w_data_sheet.

4.

Save and close w_data_sheet.

5.

Re-open the menu m_sheet.

5.

Re-open the menu m_sheet.

6.

Script the ToolsExport Data menu items Clicked event to call ue_export:

6.

Script the ToolsExport Data menu items Clicked event to call ue_export:

w_data_sheet
lw_data_sheet
lw_data_sheet = ParentWindow
lw_data_sheet.event ue_export( )

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

w_data_sheet
lw_data_sheet
lw_data_sheet = ParentWindow
lw_data_sheet.event ue_export( )

Lab 10 - 17

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 10 - 17

Module 10 Lab: Using DataWindow Controls

Lab 10 - 18

Module 10 Lab: Using DataWindow Controls

7.

Run the application.

7.

Run the application.

8.

Click FileOpenClaim Search.

8.

Click FileOpenClaim Search.

9.

Enter a patient ID of 10001.

9.

Enter a patient ID of 10001.

10. Click on the Export icon. Save the files in your Student folder. Repeat this step many
times, exporting the following: CSV, Text with Headers, XML, PDF, Excel8 with
Headers, SQL, HTML, Powersoft Report. Those are common export types.

10. Click on the Export icon. Save the files in your Student folder. Repeat this step many
times, exporting the following: CSV, Text with Headers, XML, PDF, Excel8 with
Headers, SQL, HTML, Powersoft Report. Those are common export types.

11. Spend a few minutes looking at your exported data files via Windows Explorer.

11. Spend a few minutes looking at your exported data files via Windows Explorer.

12. Exit the running application and close any opened painters.

12. Exit the running application and close any opened painters.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 10 - 18

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 11: Inserting and Deleting Data

Module 11: Inserting and Deleting Data

Module 11: Inserting and Deleting Data

Module 11: Inserting and Deleting Data

Lab 11-1: Adding Insert/Delete Functionality to SybHealth

Lab 11-1: Adding Insert/Delete Functionality to SybHealth

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Add new rows (data) in a DataWindow

Add new rows (data) in a DataWindow

Delete rows in your DataWindows

Delete rows in your DataWindows

Description:

In this lab, you will be completing the FileNew functionality, coding the application so
that the user can enter new Claims, Patients or Policies. Only Claims and Doctors can be
deleted in the SybHealth application at the completion of this lab. Patient deletion will be
coded later. Inserting and deleting in a DataWindow does not impact the underlying
database. Only the DataWindow buffers are impacted. You will not be able to fully test
this functionality until the next lab.

Description:

In this lab, you will be completing the FileNew functionality, coding the application so
that the user can enter new Claims, Patients or Policies. Only Claims and Doctors can be
deleted in the SybHealth application at the completion of this lab. Patient deletion will be
coded later. Inserting and deleting in a DataWindow does not impact the underlying
database. Only the DataWindow buffers are impacted. You will not be able to fully test
this functionality until the next lab.

Task Outline:

Task 1: Coding Insert Functionality

Task Outline:

Task 1: Coding Insert Functionality

Task 2: Coding Delete Functionality

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Coding Delete Functionality

Lab 11 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 11 - 1

Module 11 Lab: Inserting and Deleting Data

Module 11 Lab: Inserting and Deleting Data

Detailed Instructions

Detailed Instructions

Task 1: Coding Insert Functionality

Task 1: Coding Insert Functionality

Lab 11 - 2

1.

From this point, scripting exercises will not always include the solution code. Enough
information is being given to complete a scripting task. If, however, you cannot
perform the task, remember that solutions are provided for each lab. You can always
add a target for the solution of a given module to your workspace and look there for
the code. Be sure you do not confuse the solution target with the student target.

1.

From this point, scripting exercises will not always include the solution code. Enough
information is being given to complete a scripting task. If, however, you cannot
perform the task, remember that solutions are provided for each lab. You can always
add a target for the solution of a given module to your workspace and look there for
the code. Be sure you do not confuse the solution target with the student target.

2.

Open w_data_response in the Window painter.

2.

Open w_data_response in the Window painter.

3.

In the Script view, add a new un-mapped event named ue_insert that returns a long
and has one integer argument named ai_ins_location.

3.

In the Script view, add a new un-mapped event named ue_insert that returns a long
and has one integer argument named ai_ins_location.

4.

Script the event as follows:

4.

Script the event as follows:

a. Declare a local long variable named ll_newrow.

a. Declare a local long variable named ll_newrow.

b. Call dw_datas InsertRow( ) function passing in the argument, ai_ins_location


as input to InsertRow( ). Assign the return value of the InsertRow( ) function
to the ll_newrow variable.

b. Call dw_datas InsertRow( ) function passing in the argument, ai_ins_location


as input to InsertRow( ). Assign the return value of the InsertRow( ) function
to the ll_newrow variable.

c. Return the ll_newrow variable.

c. Return the ll_newrow variable.

5.

Scripting the insert in w_data_response will allow us to code the InsertRow( ) one
time versus three times (for Claims, Patients and Policies).

5.

Scripting the insert in w_data_response will allow us to code the InsertRow( ) one
time versus three times (for Claims, Patients and Policies).

6.

Close and save w_data_response.

6.

Close and save w_data_response.

7.

Open w_claim_new in the Window painter.

7.

Open w_claim_new in the Window painter.

8.

Click on the DataWindow control on the Layout view and then set the DataObject
property to use d_claims_edit.

8.

Click on the DataWindow control on the Layout view and then set the DataObject
property to use d_claims_edit.

9.

Change the DataWindow controls width to 2455 and height to 800.

9.

Change the DataWindow controls width to 2455 and height to 800.

10. Disable the Border property of the DataWindow control.

10. Disable the Border property of the DataWindow control.

11. Change the windows width property to 2500 and height to 840.

11. Change the windows width property to 2500 and height to 840.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 11 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 11: Inserting and Deleting Data

Module 11: Inserting and Deleting Data

12. The window should look as follows:

12. The window should look as follows:

13. Navigate to the windows ue_insert( ) event. Events extend by default AND run top
down, so the InsertRow( ) code you put in the ancestor will execute first.

13. Navigate to the windows ue_insert( ) event. Events extend by default AND run top
down, so the InsertRow( ) code you put in the ancestor will execute first.

14. Extend the ue_insert event as follows:

14. Extend the ue_insert event as follows:

a. Declare three local long variables ll_newrow, ll_ret and ll_new_id.

a. Declare three local long variables ll_newrow, ll_ret and ll_new_id.

b. Assign AncestorReturnValue to ll_newrow. Use WinHelp to look up


AncestorReturnValue to learn more about this internally generated variable.

b. Assign AncestorReturnValue to ll_newrow. Use WinHelp to look up


AncestorReturnValue to learn more about this internally generated variable.

c. Write an embedded SQL SELECT statement selecting the keyvalue column


into the ll_new_id variable (precede variables in embedded SQL with a colon)
from the autokey table where the tablename column = claims. Put the
USING SQLCA; clause at the end of your embedded SQL SELECT statement.

c. Write an embedded SQL SELECT statement selecting the keyvalue column


into the ll_new_id variable (precede variables in embedded SQL with a colon)
from the autokey table where the tablename column = claims. Put the
USING SQLCA; clause at the end of your embedded SQL SELECT statement.

d. Increment the ll_new_id by a value of one.

d. Increment the ll_new_id by a value of one.

e. Write an embedded SQL UPDATE statement, updating the keyvalue column


with the incremented value of ll_new_id. End your embedded SQL with a
using clause, in this case USING SQLCA;.

e. Write an embedded SQL UPDATE statement, updating the keyvalue column


with the incremented value of ll_new_id. End your embedded SQL with a
using clause, in this case USING SQLCA;.

f.

f.

Embedded SQL should always be followed with a check of the transaction


objects SQLCODE. If SQLCODE = 0 then commit using sqlca;, otherwise
rollback using sqlca;.

g. Write the new id to the claim_id column of the DataWindow. To do this, call
dw_datas SetItem( ) function, passing it ll_newrow, claim_id and ll_new_id
as the three required arguments.

g. Write the new id to the claim_id column of the DataWindow. To do this, call
dw_datas SetItem( ) function, passing it ll_newrow, claim_id and ll_new_id
as the three required arguments.

h. Programmatically set focus to dw_data.

h. Programmatically set focus to dw_data.

15. Sample code can be seen on the next page:

2010 Sybase, Inc.

Embedded SQL should always be followed with a check of the transaction


objects SQLCODE. If SQLCODE = 0 then commit using sqlca;, otherwise
rollback using sqlca;.

Fast Track to PowerBuilder, Part I Version 1.0

15. Sample code can be seen on the next page:

Lab 11 - 3

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 11 - 3

Module 11 Lab: Inserting and Deleting Data

Lab 11 - 4

Fast Track to PowerBuilder, Part I Version 1.0

Module 11 Lab: Inserting and Deleting Data

2010 Sybase, Inc.

Lab 11 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 11: Inserting and Deleting Data

2010 Sybase, Inc.

Module 11: Inserting and Deleting Data

16. Code the Open event of w_claim_new to invoke the ue_insert( ) event, passing a
value of 1 to the argument.

16. Code the Open event of w_claim_new to invoke the ue_insert( ) event, passing a
value of 1 to the argument.

17. Save w_claim_new and test your application. You can complete the new claim
window, but until the next lab, you will not be saving anything. Test that your claim
window appears with a blank row and the new claim id is set.

17. Save w_claim_new and test your application. You can complete the new claim
window, but until the next lab, you will not be saving anything. Test that your claim
window appears with a blank row and the new claim id is set.

18. Open w_patient_new.

18. Open w_patient_new.

19. Set dw_datas DataObject to a value of d_patient_details.

19. Set dw_datas DataObject to a value of d_patient_details.

20. Set dw_datas width to 2090 and height to 1350.

20. Set dw_datas width to 2090 and height to 1350.

21. Disable the DataWindows Border property.

21. Disable the DataWindows Border property.

22. Set w_patient_news width to 2135 and they height to 1390.

22. Set w_patient_news width to 2135 and they height to 1390.

23. Your window should look as follows:

23. Your window should look as follows:

24. Copy the code from the ue_insert( ) of w_claim_new and paste into w_patient_news
ue_insert( ) event. Change the tablename in the embedded SQL statements from
claims to patient. Be sure to also change the column name in the SetItem( )
function call to patient_id. Navigate to the windows Open event and write script to
call ue_insert( ) passing a 1 to his argument.

24. Copy the code from the ue_insert( ) of w_claim_new and paste into w_patient_news
ue_insert( ) event. Change the tablename in the embedded SQL statements from
claims to patient. Be sure to also change the column name in the SetItem( )
function call to patient_id. Navigate to the windows Open event and write script to
call ue_insert( ) passing a 1 to his argument.

25. Ideally, the scripts containing the embedded SELECT, the embedded UPDATE and
the error checking and commit/rollback could all be functions in the ancestor where
the variables (tablename, transaction object, etc.) could be function arguments. Then
you would not have the same code to maintain in multiple places.

25. Ideally, the scripts containing the embedded SELECT, the embedded UPDATE and
the error checking and commit/rollback could all be functions in the ancestor where
the variables (tablename, transaction object, etc.) could be function arguments. Then
you would not have the same code to maintain in multiple places.

26. Run the application to test your work.

26. Run the application to test your work.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 11 - 5

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 11 - 5

Module 11 Lab: Inserting and Deleting Data

Lab 11 - 6

Module 11 Lab: Inserting and Deleting Data

27. w_policy_edit will be slightly different due to the nature of the data schema. There is
no policy_id column in the insurance_policy table. The primary key for that table is
the patient_id column. You will not need to calculate a new primary key value.
Instead, you will replace the patient_id column with a drop down DataWindow
allowing the user select the patient for a given policy. The drop down DataWindow
should only display patients that dont already have a policy.

27. w_policy_edit will be slightly different due to the nature of the data schema. There is
no policy_id column in the insurance_policy table. The primary key for that table is
the patient_id column. You will not need to calculate a new primary key value.
Instead, you will replace the patient_id column with a drop down DataWindow
allowing the user select the patient for a given policy. The drop down DataWindow
should only display patients that dont already have a policy.

28. Open d_dddw_pat_list in the DataWindow painter.

28. Open d_dddw_pat_list in the DataWindow painter.

29. Immediately click FileSave As giving the DataWindow object a name of


d_dddw_pat_list_no_policies (save in the patients.pbl).

29. Immediately click FileSave As giving the DataWindow object a name of


d_dddw_pat_list_no_policies (save in the patients.pbl).

30. Click DesignData Source on the menu.

30. Click DesignData Source on the menu.

31. Click on the Where tab at the bottom of the screen (this area is called the SQL
Toolbox).

31. Click on the Where tab at the bottom of the screen (this area is called the SQL
Toolbox).

32. Under Column, select patient.patient_id.

32. Under Column, select patient.patient_id.

33. Select the not in Operator.

33. Select the not in Operator.

34. Right-click under the Value column and click on Select from the context menu.

34. Right-click under the Value column and click on Select from the context menu.

35. It will look like the DataWindow painter re-opened. You are ready to graphically
depict a nested SELECT statement. Select the insurance_policy table and click Open.

35. It will look like the DataWindow painter re-opened. You are ready to graphically
depict a nested SELECT statement. Select the insurance_policy table and click Open.

36. When the table displays, click the patient_id column.

36. When the table displays, click the patient_id column.

37. Click the Return icon on the PainterBar.

37. Click the Return icon on the PainterBar.

38. You will see your nested SELECT pasted under the Value column of the WHERE
clause:

38. You will see your nested SELECT pasted under the Value column of the WHERE
clause:

39. Click Return on the PainterBar.

39. Click Return on the PainterBar.

40. Make sure you get data by retrieving in the Preview view.

40. Make sure you get data by retrieving in the Preview view.

41. Save the DataWindow object and close the painter.

41. Save the DataWindow object and close the painter.

42. Open d_policy_edit.

42. Open d_policy_edit.

43. Select the patient_id column.

43. Select the patient_id column.

44. In the Properties view, scroll right until you can select the Edit tab.

44. In the Properties view, scroll right until you can select the Edit tab.

45. Verify or set the Style Type as DropDownDW.

45. Verify or set the Style Type as DropDownDW.

46. Enable Always Show Arrow and Vertical Scroll Bar properties.

46. Enable Always Show Arrow and Vertical Scroll Bar properties.

47. Scroll down in the Properties view.

47. Scroll down in the Properties view.

48. Set the DataWindow property to d_dddw_pat_list_no_policies.

48. Set the DataWindow property to d_dddw_pat_list_no_policies.

49. Scroll down again.

49. Scroll down again.

50. Set the Display Column to patfullname.

50. Set the Display Column to patfullname.

51. Set the Data Column to patient_id.

51. Set the Data Column to patient_id.

52. Change the Width of Drop Down(%) to 350.

52. Change the Width of Drop Down(%) to 350.

53. In the Design view, click on the patient_id column.

53. In the Design view, click on the patient_id column.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 11 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 11: Inserting and Deleting Data

2010 Sybase, Inc.

Module 11: Inserting and Deleting Data

54. Set the width of the patient_id column to 875 (on the Position tab in Properties).

54. Set the width of the patient_id column to 875 (on the Position tab in Properties).

55. The DataWindow preview should look as follows:

55. The DataWindow preview should look as follows:

56. Save and close the DataWindow painter.

56. Save and close the DataWindow painter.

57. Open w_policy_new in the Window painter.

57. Open w_policy_new in the Window painter.

58. On the Layout tab, select the DataWindow control.

58. On the Layout tab, select the DataWindow control.

59. Assign d_policy_edit as the DataObject property value.

59. Assign d_policy_edit as the DataObject property value.

60. Set the DataWindow controls width to 2085 and height to 400.

60. Set the DataWindow controls width to 2085 and height to 400.

61. Disable the DataWindows Border property.

61. Disable the DataWindows Border property.

62. Set the windows width to 2150 and height to 460.

62. Set the windows width to 2150 and height to 460.

63. The window will look as follows:

63. The window will look as follows:

64. Save the window.

64. Save the window.

65. There are no primary key calculations necessary for this window. Navigate to the
windows Open event and script the invocation of the ue_insert(). Pass a value of 1 to
the event.

65. There are no primary key calculations necessary for this window. Navigate to the
windows Open event and script the invocation of the ue_insert(). Pass a value of 1 to
the event.

66. Save the window.

66. Save the window.

67. Run the application to test your work.

67. Run the application to test your work.

68. When tested, exit the application and close any open painters.

68. When tested, exit the application and close any open painters.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 11 - 7

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 11 - 7

Module 11 Lab: Inserting and Deleting Data

Module 11 Lab: Inserting and Deleting Data

Task 2: Coding Delete Functionality

Task 2: Coding Delete Functionality

Lab 11 - 8

1.

Open w_data_sheet.

1.

Open w_data_sheet.

2.

Navigate to the ue_delete( ) event of the window.

2.

Navigate to the ue_delete( ) event of the window.

3.

Declare two local integer variables, li_ret and li_del.

3.

Declare two local integer variables, li_ret and li_del.

4.

In a message box, confirm that the user wants to delete the current row. Give them a
choice of yes or no where the no button has focus. Assign the return of the message
box to the li_ret variable.

4.

In a message box, confirm that the user wants to delete the current row. Give them a
choice of yes or no where the no button has focus. Assign the return of the message
box to the li_ret variable.

5.

If li_ret = 1 then call the DataWindow controls DeleteRow( ) function passing a


value representative of the current row. Look up DeleteRow( ) in WinHelp if you
have trouble remembering the correct value. Assign the return value of the
DeleteRow( ) function to the li_del variable.

5.

If li_ret = 1 then call the DataWindow controls DeleteRow( ) function passing a


value representative of the current row. Look up DeleteRow( ) in WinHelp if you
have trouble remembering the correct value. Assign the return value of the
DeleteRow( ) function to the li_del variable.

6.

If li_ret = 2 then assign -1 to the li_del variable.

6.

If li_ret = 2 then assign -1 to the li_del variable.

7.

Return li_del.

7.

Return li_del.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 11 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 11: Inserting and Deleting Data

Module 11: Inserting and Deleting Data

8.

Sample code is shown below:

8.

Sample code is shown below:

9.

The menus were coded earlier to call the ue_delete( ) event, so you are ready to run
the application.

9.

The menus were coded earlier to call the ue_delete( ) event, so you are ready to run
the application.

10. Open both Doctor List and Claims Search windows to test the functionality. On
Claims Search, enter a patient ID of 10001 and you will have many claims you might
delete.

10. Open both Doctor List and Claims Search windows to test the functionality. On
Claims Search, enter a patient ID of 10001 and you will have many claims you might
delete.

11. You may notice after deleting a row that the DataWindow is not automatically giving
focus back to row 1. Exit the application.

11. You may notice after deleting a row that the DataWindow is not automatically giving
focus back to row 1. Exit the application.

12. Re-open w_data_sheet and navigate to the ue_delete( ) event.

12. Re-open w_data_sheet and navigate to the ue_delete( ) event.

13. Before the return statement add the following:

13. Before the return statement add the following:

dw_data.event rowfocuschanged(1)

2010 Sybase, Inc.

dw_data.event rowfocuschanged(1)

14. Close and save w_data_sheet.

14. Close and save w_data_sheet.

15. Run the application to test the impact. Remember, if you delete a claim or doctor,
then close and re-open the window, that claim or doctor will have returned to the
display. At this stage, you are only moving rows from the Primary buffer to the
Delete buffer. At the end of the next lab, you will be updating the database with these
changes (inserts and deletes).

15. Run the application to test the impact. Remember, if you delete a claim or doctor,
then close and re-open the window, that claim or doctor will have returned to the
display. At this stage, you are only moving rows from the Primary buffer to the
Delete buffer. At the end of the next lab, you will be updating the database with these
changes (inserts and deletes).

16. When satisfied, exit the running application and close any open painters.

16. When satisfied, exit the running application and close any open painters.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 11 - 9

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 11 - 9

Module 11 Lab: Inserting and Deleting Data

Lab 11 - 10

Fast Track to PowerBuilder, Part I Version 1.0

Module 11 Lab: Inserting and Deleting Data

2010 Sybase, Inc.

Lab 11 - 10

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 12: Saving Data to the Database (Basics)

Module 12: Saving Data to the Database (Basics)

Module 12: Saving Data to the Database (Basics)

Module 12: Saving Data to the Database (Basics)

Lab 12-1: Saving Data to the Database

Lab 12-1: Saving Data to the Database

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Update the database with changes from your DataWindows

Update the database with changes from your DataWindows

Description:

In this lab, you will be writing data update functionality for your application. The purpose
of this lab is to show you how easy that process is, and to give you typical PowerBuilder
code for updating via DataWindows. You will only be updating from the Claims Search
window at this point, where you will select a claim and delete the claim then save your
changes. Other application windows will have their data updated in later labs.

Description:

In this lab, you will be writing data update functionality for your application. The purpose
of this lab is to show you how easy that process is, and to give you typical PowerBuilder
code for updating via DataWindows. You will only be updating from the Claims Search
window at this point, where you will select a claim and delete the claim then save your
changes. Other application windows will have their data updated in later labs.

Procedure

1.

Open w_data_sheet in the Window painter.

Procedure

1.

Open w_data_sheet in the Window painter.

2.

Some descendants of w_data_sheet, like w_doctor_list and w_reports will not be


updatable. Add a property (an Instance Variable) of type Boolean to the window.
Name the variable ib_updatable.

2.

Some descendants of w_data_sheet, like w_doctor_list and w_reports will not be


updatable. Add a property (an Instance Variable) of type Boolean to the window.
Name the variable ib_updatable.

3.

Navigate to the windows ue_save( ) event.

3.

Navigate to the windows ue_save( ) event.

4.

IF ib_updatable is true, then execute the following statements:

4.

IF ib_updatable is true, then execute the following statements:

a. Declare an integer variable named li_ret.

a. Declare an integer variable named li_ret.

b. Call the DataWindow controls Update( ) function, assigning the return to the
li_ret variable.

b. Call the DataWindow controls Update( ) function, assigning the return to the
li_ret variable.

c. If li_ret = 1 then issue a commit embedded SQL statement.

c. If li_ret = 1 then issue a commit embedded SQL statement.

i. Check the return from the transaction object following the commit. If
SQLCODE <> 0 then display an appropriate message box.

i. Check the return from the transaction object following the commit. If
SQLCODE <> 0 then display an appropriate message box.

d. If li_ret = -1 then issue a rollback embedded SQL statement.

d. If li_ret = -1 then issue a rollback embedded SQL statement.

i. You are rolling back because the Update( ) failed. Issue a message to
the user telling them the update failed. Always put messages after
commits and/or rollbacks.

i. You are rolling back because the Update( ) failed. Issue a message to
the user telling them the update failed. Always put messages after
commits and/or rollbacks.

ii. Check the return from the transaction object following the rollback. If
SQLCODE <> 0 then display an appropriate message box.

ii. Check the return from the transaction object following the rollback. If
SQLCODE <> 0 then display an appropriate message box.

e. Add a statement at the end that invokes the DataWindow controls


RowFocusChanged( ) event passing a value of 1 to the event.

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

e. Add a statement at the end that invokes the DataWindow controls


RowFocusChanged( ) event passing a value of 1 to the event.

Lab 12 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 12 - 1

Module 12 Lab: Saving Data to the Database (Basics)

Lab 12 - 2

Module 12 Lab: Saving Data to the Database (Basics)

5.

Sample code follows:

5.

Sample code follows:

6.

Close and save w_data_sheet.

6.

Close and save w_data_sheet.

7.

ue_save( ) is an unmapped event and must be called. For now, it will only be called
from the Client Search window when they click on the Delete icon (or
ToolsDelete).

7.

ue_save( ) is an unmapped event and must be called. For now, it will only be called
from the Client Search window when they click on the Delete icon (or
ToolsDelete).

8.

Open w_claims_search in the Window painter.

8.

Open w_claims_search in the Window painter.

9.

Enable the ib_updatable property (Properties view, scroll to the bottom).

9.

Enable the ib_updatable property (Properties view, scroll to the bottom).

10. Navigate to the ue_delete( ) event.

10. Navigate to the ue_delete( ) event.

11. Declare a long variable named ll_ancestor_ret.

11. Declare a long variable named ll_ancestor_ret.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 12 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 12: Saving Data to the Database (Basics)

2010 Sybase, Inc.

Module 12: Saving Data to the Database (Basics)

12. Assign AncestorReturnValue to ll_ancestor_ret. You already coded w_data_sheets


ue_delete( ) to perform the DeleteRow( ). The ancestor will return a 1 if successful
and a -1 if not.

12. Assign AncestorReturnValue to ll_ancestor_ret. You already coded w_data_sheets


ue_delete( ) to perform the DeleteRow( ). The ancestor will return a 1 if successful
and a -1 if not.

13. If ll_ancestor_ret = 1 then invoke the ue_save( ) event.

13. If ll_ancestor_ret = 1 then invoke the ue_save( ) event.

14. Return the value of ll_ancestor_ret.

14. Return the value of ll_ancestor_ret.

15. Sample code follows:

15. Sample code follows:

16. Go to the properties view of w_claims_search. Scroll to the bottom of the General tab
and enable the ib_updatable property.

16. Go to the properties view of w_claims_search. Scroll to the bottom of the General tab
and enable the ib_updatable property.

17. Save w_claims_search.

17. Save w_claims_search.

18. Navigate to the Windows Open event.

18. Navigate to the Windows Open event.

19. Place the following code that will hide unnecessary toolbar icons in the Open:

19. Place the following code that will hide unnecessary toolbar icons in the Open:

20. Use the above sample to programmatically disable unnecessary icons in w_reports
Open event. Understand that disabling the toolbar icons does not disable the menu
items.

20. Use the above sample to programmatically disable unnecessary icons in w_reports
Open event. Understand that disabling the toolbar icons does not disable the menu
items.

21. Run the application.

21. Run the application.

22. Test by finding a claim, selecting it, and then clicking the Delete icon on the toolbar.

22. Test by finding a claim, selecting it, and then clicking the Delete icon on the toolbar.

23. When prompted the first time, click No on the Delete Confirmation message.
Nothing should happen.

23. When prompted the first time, click No on the Delete Confirmation message.
Nothing should happen.

24. Delete again, this time clicking yes on the confirmation dialog.

24. Delete again, this time clicking yes on the confirmation dialog.

25. You will receive a message that the DataWindow does not have UPDATE
capabilities. This is expected. You will correct this situation in a later lab.

25. You will receive a message that the DataWindow does not have UPDATE
capabilities. This is expected. You will correct this situation in a later lab.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 12 - 3

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 12 - 3

Module 12 Lab: Saving Data to the Database (Basics)

Lab 12 - 4

Fast Track to PowerBuilder, Part I Version 1.0

Module 12 Lab: Saving Data to the Database (Basics)

2010 Sybase, Inc.

Lab 12 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 13: NVOs: Non Visual (User) Objects

Module 13: NVOs: Non Visual (User) Objects

Module 13: NVOs: Non Visual (User) Objects

Module 13: NVOs: Non Visual (User) Objects

Lab 13-1: Creating and Using Standard Class User Objects

Lab 13-1: Creating and Using Standard Class User Objects

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Create a reusable Error object.

Create a reusable Error object.

Create a reusable Transaction object.

Create a reusable Transaction object.

Overload methods

Overload methods

Description:

In this lab, you will be partitioning code that has been embedded in the Application object
as an object-function (of_report_error). Since the Application object is target specific (and
not inheritable), to reuse this function you would have to re-create it in every application.
This lab has you take a more object-oriented approach to re-using the Error object
functionality. You will also be creating your own Transaction object. Earlier, you wrote
code in the Login window to connect to the database. Now, you will make it a series of
object functions in your own Transaction object.

Description:

In this lab, you will be partitioning code that has been embedded in the Application object
as an object-function (of_report_error). Since the Application object is target specific (and
not inheritable), to reuse this function you would have to re-create it in every application.
This lab has you take a more object-oriented approach to re-using the Error object
functionality. You will also be creating your own Transaction object. Earlier, you wrote
code in the Login window to connect to the database. Now, you will make it a series of
object functions in your own Transaction object.

Task Outline:

Task 1: Creating an Error Object

Task Outline:

Task 1: Creating an Error Object

Task 2: Creating a Transaction Object

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Creating a Transaction Object

Lab 13 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 1

Module 13 Lab: NVOs: Non-Visual (User) Objects

Module 13 Lab: NVOs: Non-Visual (User) Objects

Detailed Instructions

Detailed Instructions

Task 1: Creating an Error Object

Task 1: Creating an Error Object

Lab 13 - 2

1.

In the System Tree, right-click over the sybhealth_target and select Properties.

1.

In the System Tree, right-click over the sybhealth_target and select Properties.

2.

On the Library List, click the New button, adding a new system_management.pbl in
your \Framework folder.

2.

On the Library List, click the New button, adding a new system_management.pbl in
your \Framework folder.

3.

Close the Library List dialog.

3.

Close the Library List dialog.

4.

In the System Tree, right-click over the sybhealth_target and select New

4.

In the System Tree, right-click over the sybhealth_target and select New

5.

On the PB Object tab, select Standard Class.

5.

On the PB Object tab, select Standard Class.

6.

When prompted to select a standard class, select Error.

6.

When prompted to select a standard class, select Error.

7.

Click OK.

7.

Click OK.

8.

Note the properties of this object. These are all populated when runtime errors occur.
They can provide you with detailed information about the error.

8.

Note the properties of this object. These are all populated when runtime errors occur.
They can provide you with detailed information about the error.

9.

Click FileSave As saving this object as n_err in the system_management.pbl.

9.

Click FileSave As saving this object as n_err in the system_management.pbl.

10. Click InsertFunction to create a new object-level function. The function will return
(None) and have no arguments. Name the function of_report_error.

10. Click InsertFunction to create a new object-level function. The function will return
(None) and have no arguments. Name the function of_report_error.

11. Open the a_sybhealth Application object.

11. Open the a_sybhealth Application object.

12. Navigate to the of_report_error function you wrote earlier.

12. Navigate to the of_report_error function you wrote earlier.

13. Copy the code to the Windows clipboard (Ctrl-C).

13. Copy the code to the Windows clipboard (Ctrl-C).

14. Switch back to n_err and paste the code into your new function.

14. Switch back to n_err and paste the code into your new function.

15. Save n_err.

15. Save n_err.

16. Click on the Declare Instance Variables tab (bottom of painter).

16. Click on the Declare Instance Variables tab (bottom of painter).

17. Declare all of the following Instance Variables as Private.

17. Declare all of the following Instance Variables as Private.

a. Declare a boolean named ib_message_out and set its value to true.

a. Declare a boolean named ib_message_out and set its value to true.

b. Declare a boolean named ib_file_out and set its value to true.

b. Declare a boolean named ib_file_out and set its value to true.

c. Declare a string named is_err_text.

c. Declare a string named is_err_text.

d. Declare a CONSTANT string is_file_name and assign to it the value of


sybhealth_error.log.

d. Declare a CONSTANT string is_file_name and assign to it the value of


sybhealth_error.log.

18. Save.

18. Save.

19. Click InsertFunction to add another object function, of_log_to_file( ). This


function returns (None) and has no arguments.

19. Click InsertFunction to add another object function, of_log_to_file( ). This


function returns (None) and has no arguments.

20. Navigate back to the of_report_error( ) function.

20. Navigate back to the of_report_error( ) function.

21. Delete the string variables since we now have Instance Variables.

21. Delete the string variables since we now have Instance Variables.

22. Replace any references to ls_err with is_err_text. Use EditReplace. Do not use the
Replace All button unless you are sure this will not cause errors.

22. Replace any references to ls_err with is_err_text. Use EditReplace. Do not use the
Replace All button unless you are sure this will not cause errors.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 13 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 13: NVOs: Non Visual (User) Objects

2010 Sybase, Inc.

Module 13: NVOs: Non Visual (User) Objects

23. Save, fixing any compiler errors.

23. Save, fixing any compiler errors.

24. Cut the lines of code that write to the log file.

24. Cut the lines of code that write to the log file.

25. Paste them into the of_log_to_file( ) function. Add an int li_file_handle declaration to
the top of this function.

25. Paste them into the of_log_to_file( ) function. Add an int li_file_handle declaration to
the top of this function.

26. Locate the line where FileOpen( ) is being called.

26. Locate the line where FileOpen( ) is being called.

27. Remove the hard-coded file name (the first argument to FileOpen( )) and replace it
with your constant variable, is_file_name:

27. Remove the hard-coded file name (the first argument to FileOpen( )) and replace it
with your constant variable, is_file_name:

28. Save.

28. Save.

29. Back to of_report_error( ).

29. Back to of_report_error( ).

30. Delete the int variable declaration.

30. Delete the int variable declaration.

31. At the end of the code that populates the is_err_text variable, add an if statement
checking the value of ib_file_out. If true, call the of_log_to_file( ) function.

31. At the end of the code that populates the is_err_text variable, add an if statement
checking the value of ib_file_out. If true, call the of_log_to_file( ) function.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 3

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 3

Module 13 Lab: NVOs: Non-Visual (User) Objects

Lab 13 - 4

Module 13 Lab: NVOs: Non-Visual (User) Objects

32. Also add an if statement checking the value of ib_message_out. If true, then invoke
the existing messagebox function call:

32. Also add an if statement checking the value of ib_message_out. If true, then invoke
the existing messagebox function call:

33. Save and close the User Object painter.

33. Save and close the User Object painter.

34. You should be back on the a_sybhealth Application object.

34. You should be back on the a_sybhealth Application object.

35. Click on the Function List tab (bottom of the screen).

35. Click on the Function List tab (bottom of the screen).

36. Right-click over the of_report_error( ) function and select Delete.

36. Right-click over the of_report_error( ) function and select Delete.

37. Click on the Additional Properties button in the Properties view.

37. Click on the Additional Properties button in the Properties view.

38. Select the Variable Types tab.

38. Select the Variable Types tab.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 13 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 13: NVOs: Non Visual (User) Objects

Module 13: NVOs: Non Visual (User) Objects

39. Replace the native Error object with your n_err:

39. Replace the native Error object with your n_err:

40. Click OK.

40. Click OK.

41. Navigate to the SystemError event.

41. Navigate to the SystemError event.

42. Change the code that was calling the embedded object function to a call of errors
of_report_error:

42. Change the code that was calling the embedded object function to a call of errors
of_report_error:

error.of_report_error( )

2010 Sybase, Inc.

error.of_report_error( )

43. Save. If you receive a compiler error on saving, comment out the above line, save,
then uncomment and save again. Some times PowerBuilder does not immediately see
a change you make to the Variable Types properties.

43. Save. If you receive a compiler error on saving, comment out the above line, save,
then uncomment and save again. Some times PowerBuilder does not immediately see
a change you make to the Variable Types properties.

44. You have just completed your first partitioning task. You now have a PBL/objects
(system_management.pbl) that will be reusable by all PowerBuilder applications you
create going forward.

44. You have just completed your first partitioning task. You now have a PBL/objects
(system_management.pbl) that will be reusable by all PowerBuilder applications you
create going forward.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 5

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 5

Module 13 Lab: NVOs: Non-Visual (User) Objects

Module 13 Lab: NVOs: Non-Visual (User) Objects

Task 2: Creating a Transaction Object

Task 2: Creating a Transaction Object

1.

Open w_login. Review the code you put into cb_oks Clicked event.

1.

Open w_login. Review the code you put into cb_oks Clicked event.

2.

There are distinct operations in that code: initializing the Transaction objects
(SQLCA) properties, connecting and error checking of the embedded SQL and
displaying a message on error. There is also disconnect code elsewhere. And, youve
written code to commit and rollback which also required error checking. All of this is
code that does not change and will be used many places within your applications. We
will make these operations functions in our own Transaction object.

2.

There are distinct operations in that code: initializing the Transaction objects
(SQLCA) properties, connecting and error checking of the embedded SQL and
displaying a message on error. There is also disconnect code elsewhere. And, youve
written code to commit and rollback which also required error checking. All of this is
code that does not change and will be used many places within your applications. We
will make these operations functions in our own Transaction object.

3.

Close w_login.

3.

Close w_login.

4.

In the System Tree, right-click over the SybHealth_target and select New

4.

In the System Tree, right-click over the SybHealth_target and select New

5.

On the PB Object tab, select Standard Class.

5.

On the PB Object tab, select Standard Class.

6.

When prompted to select a standard class, select Transaction.

6.

When prompted to select a standard class, select Transaction.

7.

Click OK.

7.

Click OK.

8.

Note the properties of this object.

8.

Note the properties of this object.

9.

Click FileSave As saving this object as n_tr in the system_management.pbl.

9.

Click FileSave As saving this object as n_tr in the system_management.pbl.

10. Declare two new properties (Instance Variables):

Lab 13 - 6

a. Private

Boolean

ib_init

b. Public

Boolean

ib_conn

10. Declare two new properties (Instance Variables):


a. Private

Boolean

ib_init

b. Public

Boolean

ib_conn

11. Click InsertFunction to create a new object-level function. The function will return
(None) and have five string arguments (as_user, as_pwd, as_servername, as_dbname,
as_dbms). Name the function of_init.

11. Click InsertFunction to create a new object-level function. The function will return
(None) and have five string arguments (as_user, as_pwd, as_servername, as_dbname,
as_dbms). Name the function of_init.

12. Code of_init to set the corresponding properties of the transaction object and then set
the ib_init variable to true. Sample code follows:

12. Code of_init to set the corresponding properties of the transaction object and then set
the ib_init variable to true. Sample code follows:

13. Save.

13. Save.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 13 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 13: NVOs: Non Visual (User) Objects

Module 13: NVOs: Non Visual (User) Objects

14. Using the middle drop down of the Function view, create a new function, also named
of_init. This function returns (None). It has four string arguments, as_user, as_pwd,
as_dbms and as_dsn.

14. Using the middle drop down of the Function view, create a new function, also named
of_init. This function returns (None). It has four string arguments, as_user, as_pwd,
as_dbms and as_dsn.

15. What is it called when you have two functions with the same name but a different a)
type, b) order, or c) number of arguments?

15. What is it called when you have two functions with the same name but a different a)
type, b) order, or c) number of arguments?

_____________________________________________________________________

2010 Sybase, Inc.

_____________________________________________________________________

16. Code the overloaded version of of_init as follows:

16. Code the overloaded version of of_init as follows:

17. In the classroom, we will use ODBC to get to the SQL Anywhere database, so the
above of_init will be used instead of the one for native connections.

17. In the classroom, we will use ODBC to get to the SQL Anywhere database, so the
above of_init will be used instead of the one for native connections.

18. Save.

18. Save.

19. Insert a new function. Name this function of_check_and_report. It returns an integer
and has one string argument named as_context.

19. Insert a new function. Name this function of_check_and_report. It returns an integer
and has one string argument named as_context.

20. The function code will check this objects sqlcode for <> 0. If <> 0 then display a
message for the user containing the error number (sqldbcode) and the error text
(sqlerrtext). Display the context arguments value in the title of the message box.
Return the value of the sqlcode property:

20. The function code will check this objects sqlcode for <> 0. If <> 0 then display a
message for the user containing the error number (sqldbcode) and the error text
(sqlerrtext). Display the context arguments value in the title of the message box.
Return the value of the sqlcode property:

21. You have coded the above in a few places already in the application. No more. You
will be able to call this function from anywhere in the application going forward.

21. You have coded the above in a few places already in the application. No more. You
will be able to call this function from anywhere in the application going forward.

22. Insert a new function. Name this function of_connect. It returns (None) and has no
arguments.

22. Insert a new function. Name this function of_connect. It returns (None) and has no
arguments.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 7

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 7

Module 13 Lab: NVOs: Non-Visual (User) Objects

Lab 13 - 8

Module 13 Lab: NVOs: Non-Visual (User) Objects

23. Code this function with an embedded SQL statement to connect, as you did in
w_login (cb_ok, Clicked). Always code generically. Only connect if the ib_init
variable is set to true. After the connect statement, call the of_check_and_report( )
function. If that function returns a 0 (good connection) then set ib_conn = true:

23. Code this function with an embedded SQL statement to connect, as you did in
w_login (cb_ok, Clicked). Always code generically. Only connect if the ib_init
variable is set to true. After the connect statement, call the of_check_and_report( )
function. If that function returns a 0 (good connection) then set ib_conn = true:

24. Save.

24. Save.

25. Insert a new function. Name this function of_disconnect. It returns an integer and
has no arguments.

25. Insert a new function. Name this function of_disconnect. It returns an integer and
has no arguments.

26. Code this function with an embedded SQL statement to disconnect, as you did in
a_sybhealth Application object (Close event). Always code generically. Only
disconnect if the ib_conn variable is set to true. After the disconnect statement, call
the of_check_and_report( ) function. If that function returns a 0 (good disconnection)
then set ib_conn = false:

26. Code this function with an embedded SQL statement to disconnect, as you did in
a_sybhealth Application object (Close event). Always code generically. Only
disconnect if the ib_conn variable is set to true. After the disconnect statement, call
the of_check_and_report( ) function. If that function returns a 0 (good disconnection)
then set ib_conn = false:

27. Save.

27. Save.

28. Insert a new function named of_commit that returns (None) and has no arguments.

28. Insert a new function named of_commit that returns (None) and has no arguments.

29. Code this function with the embedded SQL statement to commit and then call the
of_check_and_report( ) function.

29. Code this function with the embedded SQL statement to commit and then call the
of_check_and_report( ) function.

30. Repeat the above two steps making the appropriate changes for an of_rollback
function:

30. Repeat the above two steps making the appropriate changes for an of_rollback
function:

31. Save and close the User Object painter.

31. Save and close the User Object painter.

32. Re-open a_sybhealth.

32. Re-open a_sybhealth.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 13 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 13: NVOs: Non Visual (User) Objects

2010 Sybase, Inc.

Module 13: NVOs: Non Visual (User) Objects

33. On the Properties view, click the Additional Properties button and then select the
Variable Types tab.

33. On the Properties view, click the Additional Properties button and then select the
Variable Types tab.

34. Replace the native PowerBuilder transaction with your new n_tr:

34. Replace the native PowerBuilder transaction with your new n_tr:

35. Click OK.

35. Click OK.

36. Close and save the application object.

36. Close and save the application object.

37. Open w_login.

37. Open w_login.

38. Navigate to cb_oks Clicked event.

38. Navigate to cb_oks Clicked event.

39. Comment out the lines where you were setting sqlcas properties. Replace them with
a call to your of_init( ) function, passing the necessary inputs.

39. Comment out the lines where you were setting sqlcas properties. Replace them with
a call to your of_init( ) function, passing the necessary inputs.

40. Comment out the embedded SQL statement connecting and replace it with a call to
your of_connect( ) function.

40. Comment out the embedded SQL statement connecting and replace it with a call to
your of_connect( ) function.

41. If sqlcas ib_conn is not true, then set focus back to sle_pwd. Otherwise, keep your
lines writing to the ini file, etc:

41. If sqlcas ib_conn is not true, then set focus back to sle_pwd. Otherwise, keep your
lines writing to the ini file, etc:

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 9

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 9

Module 13 Lab: NVOs: Non-Visual (User) Objects

Lab 13 - 10

Fast Track to PowerBuilder, Part I Version 1.0

Module 13 Lab: NVOs: Non-Visual (User) Objects

2010 Sybase, Inc.

Lab 13 - 10

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 13: NVOs: Non Visual (User) Objects

2010 Sybase, Inc.

Module 13: NVOs: Non Visual (User) Objects

42. Close w_login and save your changes.

42. Close w_login and save your changes.

43. Open a_sybhealth.

43. Open a_sybhealth.

44. Navigate to the Close event.

44. Navigate to the Close event.

45. Replace all of the code in this event.

45. Replace all of the code in this event.

46. If ib_conn is true, the call your of_disconnect( ) function:

46. If ib_conn is true, the call your of_disconnect( ) function:

47. Close and save the Application object.

47. Close and save the Application object.

48. Open w_claim_new.

48. Open w_claim_new.

49. Navigate to the ue_insert( ) event.

49. Navigate to the ue_insert( ) event.

50. Instead of checking sqlcode yourself, you can call of_check_and_report( ) and if it
returns a 0 then call of_commit( ) otherwise call of_rollback( ):

50. Instead of checking sqlcode yourself, you can call of_check_and_report( ) and if it
returns a 0 then call of_commit( ) otherwise call of_rollback( ):

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 11

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 11

Module 13 Lab: NVOs: Non-Visual (User) Objects

Lab 13 - 12

Fast Track to PowerBuilder, Part I Version 1.0

Module 13 Lab: NVOs: Non-Visual (User) Objects

2010 Sybase, Inc.

Lab 13 - 12

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 13: NVOs: Non Visual (User) Objects

2010 Sybase, Inc.

Module 13: NVOs: Non Visual (User) Objects

51. Close and save w_claim_new.

51. Close and save w_claim_new.

52. Test your application to make sure changes made did not introduce new bugs, i.e. be
sure you can still connect and get a new claim ID.

52. Test your application to make sure changes made did not introduce new bugs, i.e. be
sure you can still connect and get a new claim ID.

53. Exit the running application and close any open painters.

53. Exit the running application and close any open painters.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 13

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 13

Module 13 Lab: NVOs: Non-Visual (User) Objects

Module 13 Lab: NVOs: Non-Visual (User) Objects

Lab 13-2: Creating and Using Custom Class User Objects

Lab 13-2: Creating and Using Custom Class User Objects

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Create a Custom Class User Object

Create a Custom Class User Object

Partition Business Logic separate from the User Interface

Partition Business Logic separate from the User Interface

Override methods

Override methods

Instantiate and destroy NVOs

Instantiate and destroy NVOs

Description:

In this lab, you will be partitioning code you initially embedded in the Claims Calculator
window. When you created that window, it was used to demonstrate the various types of
methods you could create. You calculated a claim payment amount with an unmapped
user event, a global function and we left it calculating via an embedded object-level
function. This is mixing Business Logic in with the User Interface partition, which makes
reuse and maintenance more complicated.

Description:

In this lab, you will be partitioning code you initially embedded in the Claims Calculator
window. When you created that window, it was used to demonstrate the various types of
methods you could create. You calculated a claim payment amount with an unmapped
user event, a global function and we left it calculating via an embedded object-level
function. This is mixing Business Logic in with the User Interface partition, which makes
reuse and maintenance more complicated.

Procedure

1.

Open w_claim_calculator.

Procedure

1.

Open w_claim_calculator.

2.

Review the code in the of_calculate( ) function. Notice that the calculation depends
on the type of insurance coverage being Basic or Premium.

2.

Review the code in the of_calculate( ) function. Notice that the calculation depends
on the type of insurance coverage being Basic or Premium.

3.

In the System Tree, right-click over the SybHealth_target and select New

3.

In the System Tree, right-click over the SybHealth_target and select New

4.

On the PB Object tab, select Custom Class.

4.

On the PB Object tab, select Custom Class.

5.

Click FileSave As saving this object as n_ancestor_coverage in the claims.pbl.

5.

Click FileSave As saving this object as n_ancestor_coverage in the claims.pbl.

6.

Insert a new function into this object named of_calculate that returns a double and has
two arguments, a double, adbl_claim_amt and a string, as_claim_type.

6.

Insert a new function into this object named of_calculate that returns a double and has
two arguments, a double, adbl_claim_amt and a string, as_claim_type.

Lab 13 - 14

7.

This is an ancestor object/function. Script the function to return -1.

7.

This is an ancestor object/function. Script the function to return -1.

8.

Close and save n_anc_coverage.

8.

Close and save n_anc_coverage.

9.

Using the System Tree, inherit from n_anc_coverage, creating a new object named
n_basic_coverage. Save this object in the claims.pbl.

9.

Using the System Tree, inherit from n_anc_coverage, creating a new object named
n_basic_coverage. Save this object in the claims.pbl.

10. Switch back to w_claim_calculator.

10. Switch back to w_claim_calculator.

11. Copy the code in the of_calculate( ) function to the clipboard.

11. Copy the code in the of_calculate( ) function to the clipboard.

12. Switch to n_basic_coverage.

12. Switch to n_basic_coverage.

13. If not already there, navigate to the of_calculate( ) function.

13. If not already there, navigate to the of_calculate( ) function.

14. Paste your code in the of_calculate( ) function.

14. Paste your code in the of_calculate( ) function.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 13 - 14

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 13: NVOs: Non Visual (User) Objects

Module 13: NVOs: Non Visual (User) Objects

15. Adjust the pasted script for calculating Basic coverage only:

15. Adjust the pasted script for calculating Basic coverage only:

16. What did you just do to the function, since it was created in n_anc_coverage and you
put new code in the descendant? The technical term for this is?

16. What did you just do to the function, since it was created in n_anc_coverage and you
put new code in the descendant? The technical term for this is?

_____________________________________________________________________

2010 Sybase, Inc.

_____________________________________________________________________

17. Save and close n_basic_coverage.

17. Save and close n_basic_coverage.

18. Inherit again from n_anc_coverage. Save this new object as n_premium_coverage in
the claims.pbl.

18. Inherit again from n_anc_coverage. Save this new object as n_premium_coverage in
the claims.pbl.

19. Again, copy the function code from w_claim_calculator of_calculate( ) function and
paste it into that for n_premium_coverages of_calculate( ).

19. Again, copy the function code from w_claim_calculator of_calculate( ) function and
paste it into that for n_premium_coverages of_calculate( ).

20. Adjust the code to calculate for premium policy holders:

20. Adjust the code to calculate for premium policy holders:

21. Save and close n_premium_coverage.

21. Save and close n_premium_coverage.

22. Navigate to cb_tests Clicked event (on w_claim_calculator).

22. Navigate to cb_tests Clicked event (on w_claim_calculator).

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 15

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 15

Module 13 Lab: NVOs: Non-Visual (User) Objects

Module 13 Lab: NVOs: Non-Visual (User) Objects

23. At the top of the script, declare a variable with the type of n_ancestor_coverage.
Name the variable lnv_coverage.

23. At the top of the script, declare a variable with the type of n_ancestor_coverage.
Name the variable lnv_coverage.

24. With an IF statement, determine the value of the is_cover_type instance variable. If
the type is P, assign to lnv_coverage by creating an instance of
n_premium_coverage. Otherwise, create an instance of n_basic_coverage.

24. With an IF statement, determine the value of the is_cover_type instance variable. If
the type is P, assign to lnv_coverage by creating an instance of
n_premium_coverage. Otherwise, create an instance of n_basic_coverage.

25. Locate the line where you called the of_calculate( ) function and make the appropriate
change so that you will be calling the NVOs function.

25. Locate the line where you called the of_calculate( ) function and make the appropriate
change so that you will be calling the NVOs function.

26. After you write the functions return back to the EditMask control, destroy the NVO.

26. After you write the functions return back to the EditMask control, destroy the NVO.

27. Sample code follows:

27. Sample code follows:

28. Was the destroy statement required? To answer this question, look up
GarbageCollection in WinHelp.

28. Was the destroy statement required? To answer this question, look up
GarbageCollection in WinHelp.

_____________________________________________________________________

Lab 13 - 16

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

_____________________________________________________________________

Lab 13 - 16

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 13: NVOs: Non Visual (User) Objects

Module 13: NVOs: Non Visual (User) Objects

29. Can GarbageCollection be turned off?

29. Can GarbageCollection be turned off?

____________________________________________________________________

2010 Sybase, Inc.

____________________________________________________________________

30. Close and save w_claim_calculator.

30. Close and save w_claim_calculator.

31. Run the application to test your work. There is a menu item under Tools to open the
Claim Calculator. To see the Tools menu item, you must have a sheet opened in the
MDI Frame window.

31. Run the application to test your work. There is a menu item under Tools to open the
Claim Calculator. To see the Tools menu item, you must have a sheet opened in the
MDI Frame window.

32. Exit the running application.

32. Exit the running application.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 17

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 13 - 17

Module 13 Lab: NVOs: Non-Visual (User) Objects

Lab 13 - 18

Fast Track to PowerBuilder, Part I Version 1.0

Module 13 Lab: NVOs: Non-Visual (User) Objects

2010 Sybase, Inc.

Lab 13 - 18

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 14: Object Communication: Message Object

Module 14: Object Communication: Message Object

Module 14: Object Communication: Message Object

Module 14: Object Communication: Message Object

Lab 14-1: Communication Between Windows

Lab 14-1: Communication Between Windows

Objectives:

Objectives:

Description:

After completing this lab, you should be able to:


Create a NVO for storing data to be passed between windows.

Create a NVO for storing data to be passed between windows.

Put data into, and get data from the Message object.

Put data into, and get data from the Message object.

Return data when a window closes.

Return data when a window closes.

In this lab, you will be adding functionality to the application where the user can doubleclick a claim on the search window, opening that claim for editing. You will be using the
same window you created for a new claim, so modifications will be required there. When
the user double-clicks on a claim, you will need to get information from the DataWindow,
put that data into an NVO, and then open the w_claim_new window, passing the NVO as
input. The w_claim_new will then have to get the NVO from the Message object and use
the contents for its processing. You will also complete the Reports interface. You will add
new menu items for the Reports and call the reports window passing information about
which report to display. This process also uses the Message object.

Description:

The Patient Search functionality on the Claims Search window will also be completed.
You will be getting the patient id from the selected row on w_patient_search and return
that, via the Message object, to a singlelineedit control.
Task Outline:

2010 Sybase, Inc.

After completing this lab, you should be able to:

The Patient Search functionality on the Claims Search window will also be completed.
You will be getting the patient id from the selected row on w_patient_search and return
that, via the Message object, to a singlelineedit control.
Task Outline:

Task 1: Creating an NVO for Holding Data

In this lab, you will be adding functionality to the application where the user can doubleclick a claim on the search window, opening that claim for editing. You will be using the
same window you created for a new claim, so modifications will be required there. When
the user double-clicks on a claim, you will need to get information from the DataWindow,
put that data into an NVO, and then open the w_claim_new window, passing the NVO as
input. The w_claim_new will then have to get the NVO from the Message object and use
the contents for its processing. You will also complete the Reports interface. You will add
new menu items for the Reports and call the reports window passing information about
which report to display. This process also uses the Message object.

Task 1: Creating an NVO for Holding Data

Task 2: Getting Information into the NVO

Task 2: Getting Information into the NVO

Task 3: Passing the NVO to the Message Object

Task 3: Passing the NVO to the Message Object

Task 4: Retrieving Data from the Message Object

Task 4: Retrieving Data from the Message Object

Task 5: Returning Data when a Window Closes

Task 5: Returning Data when a Window Closes

Task 6: Completing the Report Interface

Task 6: Completing the Report Interface

Fast Track to PowerBuilder, Part I Version 1.0

Lab 14 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 14 - 1

Module 14 Lab: Object Communication - Message Object

Module 14 Lab: Object Communication - Message Object

Detailed Instructions

Detailed Instructions

Task 1: Creating an NVO for Holding Data

Task 1: Creating an NVO for Holding Data

1.

In the System Tree, right-click over the SybHealth_target and select New

1.

In the System Tree, right-click over the SybHealth_target and select New

2.

On the PB Object tab, select Custom Class.

2.

On the PB Object tab, select Custom Class.

3.

Click OK.

3.

Click OK.

4.

Click FileSave As saving this object as n_claim_info in the claims.pbl.

4.

Click FileSave As saving this object as n_claim_info in the claims.pbl.

5.

Declare two public instance variables:

5.

Declare two public instance variables:

6.

a. Long

il_claim_id

a. Long

il_claim_id

b. String

is_patient_name

b. String

is_patient_name

Creating an NVO containing only instance variables would be similar to creating what
other kind of PowerBuilder entity?

6.

_____________________________________________________________________
7.

1.

Lab 14 - 2

_____________________________________________________________________

Save and close the User Object painter.

7.

Task 2: Getting Information into the NVO

Creating an NVO containing only instance variables would be similar to creating what
other kind of PowerBuilder entity?

Save and close the User Object painter.

Task 2: Getting Information into the NVO

Open w_claims_search.

1.

Open w_claims_search.

2.

Navigate to the DataWindow controls DoubleClicked event.

2.

Navigate to the DataWindow controls DoubleClicked event.

3.

When the user double clicks over a claim, you want to get the claim_id and patient
name and store it in the instance variables of the NVO you just created.

3.

When the user double clicks over a claim, you want to get the claim_id and patient
name and store it in the instance variables of the NVO you just created.

4.

Expand d_claims_list in the System Tree. Then expand the Controls folder. This
shows you the objects that you placed on that DataWindow object. The A icon
indicates Text objects (as does the _t suffix). The other icon indicates a Column
object.

4.

Expand d_claims_list in the System Tree. Then expand the Controls folder. This
shows you the objects that you placed on that DataWindow object. The A icon
indicates Text objects (as does the _t suffix). The other icon indicates a Column
object.

5.

Note the arguments of the DataWindows DoubleClicked event.

5.

Note the arguments of the DataWindows DoubleClicked event.

6.

Script that event as follows:

6.

Script that event as follows:

a. Declare a variable of type n_claim_info, named lnv_claim.

a. Declare a variable of type n_claim_info, named lnv_claim.

b. Instantiate n_claim_info assigning its address to the lnv_claim variable.

b. Instantiate n_claim_info assigning its address to the lnv_claim variable.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 14 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 14: Object Communication: Message Object

Module 14: Object Communication: Message Object

c. Set the value of the two instance variables as follows:

c. Set the value of the two instance variables as follows:

7.

You will learn more about reading and writing data in DataWindows in the next
module.

7.

You will learn more about reading and writing data in DataWindows in the next
module.

8.

Save.

8.

Save.

Task 3: Passing the NVO to the Message Object

Task 3: Passing the NVO to the Message Object

1.

Still in the DoubleClicked event, after you have put the information into the NVO,
you need to place the NVO into the Message object. You do that by calling one of the
withParm functions.

1.

Still in the DoubleClicked event, after you have put the information into the NVO,
you need to place the NVO into the Message object. You do that by calling one of the
withParm functions.

2.

Since w_claim_new is a Response-type window, you will call the OpenWithParm( )


function, passing w_claim_new as the first argument and the reference to the NVO as
the second:

2.

Since w_claim_new is a Response-type window, you will call the OpenWithParm( )


function, passing w_claim_new as the first argument and the reference to the NVO as
the second:

OpenWithParm(w_claim_new, lnv_claim)
3.

2010 Sybase, Inc.

OpenWithParm(w_claim_new, lnv_claim)

Save and close w_claims_search.

Fast Track to PowerBuilder, Part I Version 1.0

3.

Lab 14 - 3

2010 Sybase, Inc.

Save and close w_claims_search.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 14 - 3

Module 14 Lab: Object Communication - Message Object

Module 14 Lab: Object Communication - Message Object

Task 4: Retrieving Data from the Message Object

Lab 14 - 4

Task 4: Retrieving Data from the Message Object

1.

Open w_claim_new.

1.

Open w_claim_new.

2.

Navigate to the windows Open event.

2.

Navigate to the windows Open event.

3.

Place some blank lines ahead of the line of code there calling the ue_insert( ) event.

3.

Place some blank lines ahead of the line of code there calling the ue_insert( ) event.

4.

Declare a variable of type n_claim_info, naming this variable lnv_claim. If someone


puts something into the Message object (as w_claim_search did), the receiver of the
data must declare the same type that was put in.

4.

Declare a variable of type n_claim_info, naming this variable lnv_claim. If someone


puts something into the Message object (as w_claim_search did), the receiver of the
data must declare the same type that was put in.

5.

Instead of the receiver instantiating n_claim_info, populate that variable by getting the
data from the Message objects PowerObjectParm property. Write that statement
now.

5.

Instead of the receiver instantiating n_claim_info, populate that variable by getting the
data from the Message objects PowerObjectParm property. Write that statement
now.

6.

Call the PowerScript function IsValid( ) function passing it the lnv_claim variable. If
the reference is not valid then that means the user wants to insert. Call the ue_insert( )
event. Otherwise, instruct the DataWindow to Retrieve( ) passing the NVOs
il_claim_id as an argument.

6.

Call the PowerScript function IsValid( ) function passing it the lnv_claim variable. If
the reference is not valid then that means the user wants to insert. Call the ue_insert( )
event. Otherwise, instruct the DataWindow to Retrieve( ) passing the NVOs
il_claim_id as an argument.

7.

Using Dot Notation, set the Title property of the w_claim_new window to read:
Editing claim for: followed by the patient name that was stored in the NVO.

7.

Using Dot Notation, set the Title property of the w_claim_new window to read:
Editing claim for: followed by the patient name that was stored in the NVO.

8.

Save and test. You have not implemented the update functionality for w_claim_new
yet, so making changes will not be saved to the database. When testing, double-click
a header in the claims search DataWindow. The application will issue an error
message and terminate.

8.

Save and test. You have not implemented the update functionality for w_claim_new
yet, so making changes will not be saved to the database. When testing, double-click
a header in the claims search DataWindow. The application will issue an error
message and terminate.

9.

Exit the running application and close any open painters.

9.

Exit the running application and close any open painters.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 14 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 14: Object Communication: Message Object


10. Re-open w_claims_search and navigate to the DataWindows DoubleClicked event.

10. Re-open w_claims_search and navigate to the DataWindows DoubleClicked event.

11. Fix the code so that double-clicking on a header is properly handled. HINT: Rows
start at 1 in PowerBuilder DataWindows. The header would not be considered to be a
row.

11. Fix the code so that double-clicking on a header is properly handled. HINT: Rows
start at 1 in PowerBuilder DataWindows. The header would not be considered to be a
row.

12. Save and test your fix.

12. Save and test your fix.

Task 5: Returning Data when a Window Closes

2010 Sybase, Inc.

Module 14: Object Communication: Message Object

Task 5: Returning Data when a Window Closes

1.

Open w_patient_search.

1.

Open w_patient_search.

2.

Navigate to the DataWindows DoubleClicked event.

2.

Navigate to the DataWindows DoubleClicked event.

3.

When the user DoubleClicks a row in the Patient Search window, you are going to get
the patient ID, put it into the Message object and when the Claim Search window reactivates, it will get that data out and place it into the Patient ID singlelineedit control.

3.

When the user DoubleClicks a row in the Patient Search window, you are going to get
the patient ID, put it into the Message object and when the Claim Search window reactivates, it will get that data out and place it into the Patient ID singlelineedit control.

4.

In the DoubleClicked, declare a long variable named ll_pat_id.

4.

In the DoubleClicked, declare a long variable named ll_pat_id.

5.

Assign to ll_pat_id by calling the DataWindows GetItemNumber( ) function. Pass


row (the DoubleClicked argument) as the first argument and patient_id as the
second argument to GetItemNumber( ).

5.

Assign to ll_pat_id by calling the DataWindows GetItemNumber( ) function. Pass


row (the DoubleClicked argument) as the first argument and patient_id as the
second argument to GetItemNumber( ).

6.

Close this Response-type window with the CloseWithReturn( ) function. Pass parent
as the first argument (representing the window) and ll_pat_id as the second argument.
CloseWithReturn( ) also puts data into the Message object:

6.

Close this Response-type window with the CloseWithReturn( ) function. Pass parent
as the first argument (representing the window) and ll_pat_id as the second argument.
CloseWithReturn( ) also puts data into the Message object:

7.

Save.

7.

Save.

8.

Open w_claims_search.

8.

Open w_claims_search.

9.

Navigate to the windows Activate event.

9.

Navigate to the windows Activate event.

10. Declare a long variable named ll_pat_id.

10. Declare a long variable named ll_pat_id.

11. Assign to ll_pat_id the value in the Message objects DoubleParm property.

11. Assign to ll_pat_id the value in the Message objects DoubleParm property.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 14 - 5

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 14 - 5

Module 14 Lab: Object Communication - Message Object

Module 14 Lab: Object Communication - Message Object

12. Test IF the ll_pat_id > 0 then write that value to the sle_pat_id singlelineedit control.
Cast the data before writing to the singlelineedit control:

12. Test IF the ll_pat_id > 0 then write that value to the sle_pat_id singlelineedit control.
Cast the data before writing to the singlelineedit control:

13. Save and test your work. On Claim Search sheet, click the ellipsis button, select a
patient by double-clicking and make sure the ID is pasted back into the singlelineedit
control.

13. Save and test your work. On Claim Search sheet, click the ellipsis button, select a
patient by double-clicking and make sure the ID is pasted back into the singlelineedit
control.

14. Exit the running application and close any open painters.

14. Exit the running application and close any open painters.

Task 6: Completing the Report Interface


1.

Lab 14 - 6

Task 6: Completing the Report Interface

Using the System Tree, list the names of the report DataWindow objects in the
sybhealth.pbl below:

1.

Using the System Tree, list the names of the report DataWindow objects in the
sybhealth.pbl below:

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

2.

Open d_rpt_patient.

2.

Open d_rpt_patient.

3.

You will note that d_rpt_patient contains two nested DataWindow objects,
d_rpt_insurance_policy and d_rpt_claims. So you really only have two reports for the
application. Nested DataWindows are covered in FastTrack to PowerBuilder, Part II.

3.

You will note that d_rpt_patient contains two nested DataWindow objects,
d_rpt_insurance_policy and d_rpt_claims. So you really only have two reports for the
application. Nested DataWindows are covered in FastTrack to PowerBuilder, Part II.

4.

Close d_rpt_patient.

4.

Close d_rpt_patient.

5.

Open m_master.

5.

Open m_master.

6.

Script FileOpenReports. Remove the code that is currently there. The top level
of a menu cascade should never have code in its Clicked event.

6.

Script FileOpenReports. Remove the code that is currently there. The top level
of a menu cascade should never have code in its Clicked event.

7.

Add two new menu items under FileOpenReports. Name the items &Claims
Summary and &Patient && Claims (use the double ampersand when you want to
display an ampersand in a menu item).

7.

Add two new menu items under FileOpenReports. Name the items &Claims
Summary and &Patient && Claims (use the double ampersand when you want to
display an ampersand in a menu item).

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 14 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 14: Object Communication: Message Object


8.

Module 14: Object Communication: Message Object

Script the Claims Summary menu item to open the w_reports sheet passing 1 as the
parm to the Message object. You will want to allow the user to open multiple
instances of w_reports as well:

8.

w_reports
lw_reports
OpenSheetWithParm(lw_reports, 1, w_frame, 0, layered!)
9.

2010 Sybase, Inc.

Script the Claims Summary menu item to open the w_reports sheet passing 1 as the
parm to the Message object. You will want to allow the user to open multiple
instances of w_reports as well:
w_reports
lw_reports
OpenSheetWithParm(lw_reports, 1, w_frame, 0, layered!)

Script the Patient Claims menu item to open w_reports, passing 2 as the parm.

9.

Script the Patient Claims menu item to open w_reports, passing 2 as the parm.

10. Save and close m_master.

10. Save and close m_master.

11. From the System Tree, right-click over the SybHealth_target and select Full Build.
This is an operation you should be performing periodically throughout development.
Check for a successful Build in the Output pane.

11. From the System Tree, right-click over the SybHealth_target and select Full Build.
This is an operation you should be performing periodically throughout development.
Check for a successful Build in the Output pane.

12. Open w_reports.

12. Open w_reports.

13. Navigate to the Open event.

13. Navigate to the Open event.

14. Add some blank lines ahead of the existing code.

14. Add some blank lines ahead of the existing code.

15. Add the following statements in the Open event:

15. Add the following statements in the Open event:

a. Declare an integer variable named li_rpt.

a. Declare an integer variable named li_rpt.

b. Assign to li_rpt by getting the value of Message.DoubleParm.

b. Assign to li_rpt by getting the value of Message.DoubleParm.

c. If li_rpt = 1 then set dw_datas DataObject property to a value of


d_rpt_all_claims_summary and then set the windows Title property to
Claims Summary Report.

c. If li_rpt = 1 then set dw_datas DataObject property to a value of


d_rpt_all_claims_summary and then set the windows Title property to
Claims Summary Report.

d. If li_rpt <> 1 then set dw_datas DataObject property to a value of


d_rpt_patient and then set the windows Title property to Patient Claims
Report.

d. If li_rpt <> 1 then set dw_datas DataObject property to a value of


d_rpt_patient and then set the windows Title property to Patient Claims
Report.

e. Call dw_datas SetTransObject( ) function passing SQLCA as the input. You


put that code in u_dw earlier, but there is a rule in PowerBuilder that says if
you dynamically set the DataObject property, you must follow that with a call
to SetTransObject( ).

e. Call dw_datas SetTransObject( ) function passing SQLCA as the input. You


put that code in u_dw earlier, but there is a rule in PowerBuilder that says if
you dynamically set the DataObject property, you must follow that with a call
to SetTransObject( ).

f.

f.

After the if statement retrieve the data in dw_data.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 14 - 7

2010 Sybase, Inc.

After the if statement retrieve the data in dw_data.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 14 - 7

Module 14 Lab: Object Communication - Message Object

Lab 14 - 8

Module 14 Lab: Object Communication - Message Object

16. Sample code follows:

16. Sample code follows:

17. Save w_reports.

17. Save w_reports.

18. Run the application and click FileOpenReportsPatient & Claims.

18. Run the application and click FileOpenReportsPatient & Claims.

19. Notice it takes time after you click Patient & Claims before the window appears,
because of the amount of data being retrieved.

19. Notice it takes time after you click Patient & Claims before the window appears,
because of the amount of data being retrieved.

20. Exit the application.

20. Exit the application.

21. On w_reports, add a new unmapped event named ue_postopen. This event returns
(None) and has no arguments.

21. On w_reports, add a new unmapped event named ue_postopen. This event returns
(None) and has no arguments.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 14 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 14: Object Communication: Message Object

2010 Sybase, Inc.

Module 14: Object Communication: Message Object

22. Move the code from the Open event to the new ue_postopen.

22. Move the code from the Open event to the new ue_postopen.

23. In the Open event make a call that POSTS the ue_postopen( ) event. Also call the
SetPointer( ) function passing HourGlass! as the argument. Also, call w_frames
SetMicroHelp( ) function passing the string Retrieving data, please wait:

23. In the Open event make a call that POSTS the ue_postopen( ) event. Also call the
SetPointer( ) function passing HourGlass! as the argument. Also, call w_frames
SetMicroHelp( ) function passing the string Retrieving data, please wait:

24. In the ue_postopen( ) event, set the pointer back to Arrow! and set the microhelp back
to Ready at the end of the code.

24. In the ue_postopen( ) event, set the pointer back to Arrow! and set the microhelp back
to Ready at the end of the code.

25. Save w_reports.

25. Save w_reports.

26. Run the application to test your work. First open the Claims Summary report. When
you open the Patient & Claims report, at least now the user sees the window, and the
hourglass pointer indicating that something is happening versus the way it was earlier.
Also watch the status bar of the MDI frame window.

26. Run the application to test your work. First open the Claims Summary report. When
you open the Patient & Claims report, at least now the user sees the window, and the
hourglass pointer indicating that something is happening versus the way it was earlier.
Also watch the status bar of the MDI frame window.

27. Exit the application and close any open painters.

27. Exit the application and close any open painters.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 14 - 9

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 14 - 9

Module 14 Lab: Object Communication - Message Object

Lab 14 - 10

Fast Track to PowerBuilder, Part I Version 1.0

Module 14 Lab: Object Communication - Message Object

2010 Sybase, Inc.

Lab 14 - 10

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 15: Intermediate DataWindow Topics

Module 15: Intermediate DataWindow Topics

Module 15: Intermediate DataWindow Topics

Module 15: Intermediate DataWindow Topics

Lab 15-1: Implementing a Master-Detail Interface

Lab 15-1: Implementing a Master-Detail Interface

Objectives:

Objectives:

After completing this lab, you should be able to:

Description:

Procedure

2010 Sybase, Inc.

In this lab, you will finish the Patient Master-Detail interface. This will require you to
perform two retrieves. The only thing that is somewhat new is the getting of the key from
the row in the master and passing that key to the detail DataWindow control for it to use in
the Retrieve( ).

1.

Open w_patient_master_detail.

2.

After completing this lab, you should be able to:

Create a Master-Detail interface with DataWindows.


Description:

Procedure

Create a Master-Detail interface with DataWindows.

In this lab, you will finish the Patient Master-Detail interface. This will require you to
perform two retrieves. The only thing that is somewhat new is the getting of the key from
the row in the master and passing that key to the detail DataWindow control for it to use in
the Retrieve( ).

1.

Open w_patient_master_detail.

Assign d_patient_list to dw_masters DataObject property and enable your


ib_single_select property and disable the Border property.

2.

Assign d_patient_list to dw_masters DataObject property and enable your


ib_single_select property and disable the Border property.

3.

Assign d_patient_details to dw_details DataObject property and disable the Border


property.

3.

Assign d_patient_details to dw_details DataObject property and disable the Border


property.

4.

You will probably need to adjust the Height of the window and the dw_detail
DataWindow control in order to see all columns without scrolling.

4.

You will probably need to adjust the Height of the window and the dw_detail
DataWindow control in order to see all columns without scrolling.

5.

In the Open event of the window, code the retrieve for the dw_master DWC.

5.

In the Open event of the window, code the retrieve for the dw_master DWC.

6.

dw_detail will only retrieve when the user selects a different row in the master
DataWindow. Some users will click rows; some will use the arrow keys.

6.

dw_detail will only retrieve when the user selects a different row in the master
DataWindow. Some users will click rows; some will use the arrow keys.

7.

Navigate to dw_masters RowFocusChanged event. It was coded in an ancestor, so it


will be at the top of your event list.

7.

Navigate to dw_masters RowFocusChanged event. It was coded in an ancestor, so it


will be at the top of your event list.

8.

Write code to get the patient_id from the current row and store it into a long variable
named ll_pat_id. Use a DataWindow data expression instead of the GetItem
functions. Then pass that variable to dw_details retrieve( ):

8.

Write code to get the patient_id from the current row and store it into a long variable
named ll_pat_id. Use a DataWindow data expression instead of the GetItem
functions. Then pass that variable to dw_details retrieve( ):

9.

Close w_patient_master_detail, saving your changes.

9.

Close w_patient_master_detail, saving your changes.

10. Open w_data_sheet and do a quick review of the ue_save( ) event.

10. Open w_data_sheet and do a quick review of the ue_save( ) event.

11. Close w_data_sheet.

11. Close w_data_sheet.


Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 1

Module 15 Lab: Intermediate DataWindow Topics

Lab 15 - 2

Module 15 Lab: Intermediate DataWindow Topics

12. Re-open w_patient_master_detail.

12. Re-open w_patient_master_detail.

13. Make note that w_patient_master_detail was not inherited from w_data_sheet, so the
code you add below is not extending what you looked at in step 10.

13. Make note that w_patient_master_detail was not inherited from w_data_sheet, so the
code you add below is not extending what you looked at in step 10.

14. Navigate to the windows ue_save event. Now that we have our own Transaction
object with ready-made functions, the update code will be easier than what you put
into w_data_sheets ue_save.

14. Navigate to the windows ue_save event. Now that we have our own Transaction
object with ready-made functions, the update code will be easier than what you put
into w_data_sheets ue_save.

15. You will only be updating the detail DataWindow. Code w_patient_master_details
ue_save as follows:

15. You will only be updating the detail DataWindow. Code w_patient_master_details
ue_save as follows:

a. Declare an integer variable named li_ret

a. Declare an integer variable named li_ret

b. Assign to li_ret by calling dw_details Update( ) function.

b. Assign to li_ret by calling dw_details Update( ) function.

c. If li_ret = 1 then call sqlcas of_commit( ) function.

c. If li_ret = 1 then call sqlcas of_commit( ) function.

d. If li_ret = -1 then call sqlcas of_rollback( ) function and display a message for
the end user that the update failed.

d. If li_ret = -1 then call sqlcas of_rollback( ) function and display a message for
the end user that the update failed.

e. If you make changes to the detail DataWindow, you will want to re-retrieve
dw_master to refresh its display.

e. If you make changes to the detail DataWindow, you will want to re-retrieve
dw_master to refresh its display.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 15 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 15: Intermediate DataWindow Topics

2010 Sybase, Inc.

Module 15: Intermediate DataWindow Topics

16. Sample code follows:

16. Sample code follows:

17. Navigate to the Open event of the window and script to disable the Export menu item
and toolbar icon.

17. Navigate to the Open event of the window and script to disable the Export menu item
and toolbar icon.

18. Save.

18. Save.

19. Test your work.

19. Test your work.

20. The way the application is currently coded, the user must make a change in the Detail
DataWindow and click on the Save icon (or FileSave). What if the user made a
change in the Detail and then used the mouse or arrow keys to change focus to
another row (in the master). Your changes would be lost.

20. The way the application is currently coded, the user must make a change in the Detail
DataWindow and click on the Save icon (or FileSave). What if the user made a
change in the Detail and then used the mouse or arrow keys to change focus to
another row (in the master). Your changes would be lost.

21. Correct the above situation by adding the following code to the LoseFocus event of
dw_detail:

21. Correct the above situation by adding the following code to the LoseFocus event of
dw_detail:

a. Call dw_details AcceptText( ) function. If it returns -1 then set focus back to


dw_detail.

a. Call dw_details AcceptText( ) function. If it returns -1 then set focus back to


dw_detail.

b. Call dw_details ModifiedCount( ) and DeletedCount( ) functions. If the sum


those two functions return is greater than zero, display a message box telling
the user they have unsaved changes and asking them if they want to save.

b. Call dw_details ModifiedCount( ) and DeletedCount( ) functions. If the sum


those two functions return is greater than zero, display a message box telling
the user they have unsaved changes and asking them if they want to save.

c. If the user wants to save the changes, invoke the windows ue_save( ) event.
Otherwise, return from the event.

c. If the user wants to save the changes, invoke the windows ue_save( ) event.
Otherwise, return from the event.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 3

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 3

Module 15 Lab: Intermediate DataWindow Topics

Lab 15 - 4

Module 15 Lab: Intermediate DataWindow Topics

22. Sample code follows:

22. Sample code follows:

23. Save your work and test the application.

23. Save your work and test the application.

24. Exit the application and close any open painters.

24. Exit the application and close any open painters.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 15 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 15: Intermediate DataWindow Topics

Module 15: Intermediate DataWindow Topics

Lab 15-2: Implementing Client-Side Sort and Filter


Capabilities

Lab 15-2: Implementing Client-Side Sort and Filter


Capabilities

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Write code allowing the user to specify DataWindow sort criteria

Write code allowing the user to specify DataWindow sort criteria

Write code allowing the user to specify DataWindow filtering criteria

Write code allowing the user to specify DataWindow filtering criteria

Description:

In this lab, you will add client-side sort and filter capabilities to the Patient Master-Detail
window.

Description:

In this lab, you will add client-side sort and filter capabilities to the Patient Master-Detail
window.

Task Outline:

Task 1: Adding Client-Side Sorting

Task Outline:

Task 1: Adding Client-Side Sorting

Task 2: Adding Client-Side Filtering

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Adding Client-Side Filtering

Lab 15 - 5

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 5

Module 15 Lab: Intermediate DataWindow Topics

Module 15 Lab: Intermediate DataWindow Topics

Detailed Instructions

Detailed Instructions

Task 1: Adding Client-Side Sorting

Task 1: Adding Client-Side Sorting

Lab 15 - 6

1.

Open w_patient_master_detail.

1.

Open w_patient_master_detail.

2.

Add a new user event named ue_sort that returns (None) and takes no arguments.

2.

Add a new user event named ue_sort that returns (None) and takes no arguments.

3.

Write the following in the ue_sort( ) event:

3.

Write the following in the ue_sort( ) event:

a. Declare a string variable named ls_criteria.

a. Declare a string variable named ls_criteria.

b. Call the PowerScript function SetNull( ) passing the string variable as the
argument.

b. Call the PowerScript function SetNull( ) passing the string variable as the
argument.

c. Call dw_masters SetSort( ) function, passing it the string variable as input.

c. Call dw_masters SetSort( ) function, passing it the string variable as input.

d. Call dw_masters Sort( ) function. This executes the sort.

d. Call dw_masters Sort( ) function. This executes the sort.

4.

Sample code follows:

4.

Sample code follows:

5.

Save.

5.

Save.

6.

Open m_sheet in the Menu painter.

6.

Open m_sheet in the Menu painter.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 15 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 15: Intermediate DataWindow Topics

2010 Sybase, Inc.

Module 15: Intermediate DataWindow Topics

7.

On the Tools menu item, add three new submenu items under Claim Calculator: a
separator, &Sort, and &Filter. Assign Sort! to the MenuImage and ToolBarItemName
properties and Sort to the ToolBarItemText property. Assign Where! to the
MenuImage and ToolBarItemName properties and Filter to the ToolBarItemText
property. The drop down should now look like this:

7.

On the Tools menu item, add three new submenu items under Claim Calculator: a
separator, &Sort, and &Filter. Assign Sort! to the MenuImage and ToolBarItemName
properties and Sort to the ToolBarItemText property. Assign Where! to the
MenuImage and ToolBarItemName properties and Filter to the ToolBarItemText
property. The drop down should now look like this:

8.

Script Sort and Filter to invoke ue_sort( ) and ue_filter( ) respectively. Use
PARENTWINDOW and DYNAMIC method calls here as we have yet to create the
ue_filter( ) event (and did not create those events in an ancestor).

8.

Script Sort and Filter to invoke ue_sort( ) and ue_filter( ) respectively. Use
PARENTWINDOW and DYNAMIC method calls here as we have yet to create the
ue_filter( ) event (and did not create those events in an ancestor).

9.

Close and save the menu.

9.

Close and save the menu.

10. Run your application to test sort on the Patient Details window. Click on the Sort
icon on the toolbar. A dialog appears allowing you to drag columns to specifying the
sort order.

10. Run your application to test sort on the Patient Details window. Click on the Sort
icon on the toolbar. A dialog appears allowing you to drag columns to specifying the
sort order.

11. Specify a sort on state or city and click OK.

11. Specify a sort on state or city and click OK.

12. The data will sort. The new row one is not highlighted. The original row 1 still has
focus. Scroll down and you will see that original row one still has the blue highlight
bar.

12. The data will sort. The new row one is not highlighted. The original row 1 still has
focus. Scroll down and you will see that original row one still has the blue highlight
bar.

13. Press F1 to open WinHelp and look up the DataWindow Sort( ) function. Read the
Usage notes to determine how to correct the above issue.

13. Press F1 to open WinHelp and look up the DataWindow Sort( ) function. Read the
Usage notes to determine how to correct the above issue.

14. Exit the running application and get back to the ue_sort( ) event of
w_patient_master_detail.

14. Exit the running application and get back to the ue_sort( ) event of
w_patient_master_detail.

15. At the bottom of the script, add two lines to:

15. At the bottom of the script, add two lines to:

a. Invoke dw_masters RowFocusChanged( ) event passing 1 as the argument.

a. Invoke dw_masters RowFocusChanged( ) event passing 1 as the argument.

b. Set focus to dw_master.

b. Set focus to dw_master.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 7

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 7

Module 15 Lab: Intermediate DataWindow Topics

Module 15 Lab: Intermediate DataWindow Topics

16. Sample (updated) code follows:

16. Sample (updated) code follows:

17. Save and test your work.

17. Save and test your work.

18. Exit the application and close any open painters.

18. Exit the application and close any open painters.

19. The SetSort( ) function takes a string where you specify the sort criteria, like
patient_id A. That same logic can be applied for header click-sorting.

19. The SetSort( ) function takes a string where you specify the sort criteria, like
patient_id A. That same logic can be applied for header click-sorting.

20. In the System Tree, expand d_patient_list (the DataWindow object used in
dw_master). Expand the Controls folder. In an earlier lab, you learned how to use
the System Tree to help you code. The DWOs object names are all listed under the
Controls folder. Text (header) objects are named after the column but add the _t
suffix. SetSort( ) needs a column name, the header has that with the addition of _t.

20. In the System Tree, expand d_patient_list (the DataWindow object used in
dw_master). Expand the Controls folder. In an earlier lab, you learned how to use
the System Tree to help you code. The DWOs object names are all listed under the
Controls folder. Text (header) objects are named after the column but add the _t
suffix. SetSort( ) needs a column name, the header has that with the addition of _t.

21. Add generic click-sort capabilities to your DataWindows.

21. Add generic click-sort capabilities to your DataWindows.

22. Open u_dw.

22. Open u_dw.

23. Add the following new properties (Instance variables):

Lab 15 - 8

a. Boolean

ib_click_sort

b. Char

ic_last_sort_order

23. Add the following new properties (Instance variables):


a. Boolean

ib_click_sort

b. Char

ic_last_sort_order

24. Save.

24. Save.

25. Navigate to u_dws Clicked event and script it as follows:

25. Navigate to u_dws Clicked event and script it as follows:

a. Check for ib_click_sort to be true AND row (an event argument) to be = 0


(meaning the user clicked in the header band and not a row).

a. Check for ib_click_sort to be true AND row (an event argument) to be = 0


(meaning the user clicked in the header band and not a row).

b. Check that the user clicked on a text object (_t). Other objects can live in the
header band beside text objects. Do this by interrogating if the right-most two
characters of the objects name is _t. Use the Right( ) PowerScript function.
The objects name is referenced as dwo.name, where dwo is another event
argument. Every object you place in a DataWindow object is given a name.

b. Check that the user clicked on a text object (_t). Other objects can live in the
header band beside text objects. Do this by interrogating if the right-most two
characters of the objects name is _t. Use the Right( ) PowerScript function.
The objects name is referenced as dwo.name, where dwo is another event
argument. Every object you place in a DataWindow object is given a name.

c. Declare a string variable ls_name.

c. Declare a string variable ls_name.

d. Assign dwo.name to ls_name.

d. Assign dwo.name to ls_name.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 15 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 15: Intermediate DataWindow Topics

Module 15: Intermediate DataWindow Topics

e. Strip off the last two characters (the _t). Use the Left( ) and Len( )
PowerScript functions. This is just one option. You may want to look up
String functions in WinHelp.

e. Strip off the last two characters (the _t). Use the Left( ) and Len( )
PowerScript functions. This is just one option. You may want to look up
String functions in WinHelp.

f.

f.

Interrogate the ic_last_sort_order property. If A change to D, else change


to A.

g. Append a space (use the Space( ) PowerScript function) and ic_last_sort_order


to ls_name.

g. Append a space (use the Space( ) PowerScript function) and ic_last_sort_order


to ls_name.

h. Pass ls_name to the DataWindows SetSort( ) function.

h. Pass ls_name to the DataWindows SetSort( ) function.

i.

Call the DataWindows Sort( ) function.

i.

Call the DataWindows Sort( ) function.

j.

Call the DataWindows RowFocusChanged( ) event passing a value of 1.

j.

Call the DataWindows RowFocusChanged( ) event passing a value of 1.

26. Save your work.

2010 Sybase, Inc.

Interrogate the ic_last_sort_order property. If A change to D, else change


to A.

26. Save your work.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 9

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 9

Module 15 Lab: Intermediate DataWindow Topics

Lab 15 - 10

Module 15 Lab: Intermediate DataWindow Topics

27. Sample code for the above follows:

27. Sample code for the above follows:

28. Close u_dw.

28. Close u_dw.

29. Re-open w_patient_master_detail.

29. Re-open w_patient_master_detail.

30. On the Layout tab, click on dw_master.

30. On the Layout tab, click on dw_master.

31. Scroll down to the bottom of the Properties view and enable the ib_click_sort
property.

31. Scroll down to the bottom of the Properties view and enable the ib_click_sort
property.

32. Save.

32. Save.

33. Run the application. Open the Patient Details window and click a header in the
master DataWindow.

33. Run the application. Open the Patient Details window and click a header in the
master DataWindow.

34. Exit the application.

34. Exit the application.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 15 - 10

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 15: Intermediate DataWindow Topics

Task 2: Adding Client-Side Filtering

Module 15: Intermediate DataWindow Topics

Task 2: Adding Client-Side Filtering

1.

Open w_patient_master_detail.

1.

Open w_patient_master_detail.

2.

Add a new user event to the window named ue_filter that returns (None) and has no
arguments.

2.

Add a new user event to the window named ue_filter that returns (None) and has no
arguments.

3.

Copy what you coded in ue_sort( ) to ue_filter( ).

3.

Copy what you coded in ue_sort( ) to ue_filter( ).

4.

Change the call to SetSort( ) with a call to SetFilter( ).

4.

Change the call to SetSort( ) with a call to SetFilter( ).

5.

Change the call to Sort( ) with a call to Filter( ).

5.

Change the call to Sort( ) with a call to Filter( ).

6.

Save and test your work.

6.

Save and test your work.

7.

Experiment with the use of the Built-in Filter dialog.

7.

Experiment with the use of the Built-in Filter dialog.

8.

Where do rows go that do not match your criteria?

8.

Where do rows go that do not match your criteria?

_____________________________________________________________________
9.

_____________________________________________________________________

Exit the application.

9.

10. THINK ABOUT IT: SetFilter( ) also takes a string argument, one which you could
build easily by giving the user a window with drop downs and listboxes, etc from
which you take their input and build a string. You might think the built-in Filter
dialog is too complicated for your end-users. Build one of your own:

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 11

Exit the application.

10. THINK ABOUT IT: SetFilter( ) also takes a string argument, one which you could
build easily by giving the user a window with drop downs and listboxes, etc from
which you take their input and build a string. You might think the built-in Filter
dialog is too complicated for your end-users. Build one of your own:

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 11

Module 15 Lab: Intermediate DataWindow Topics

Module 15 Lab: Intermediate DataWindow Topics

Lab 15-3: Implementing Data Validation

Lab 15-3: Implementing Data Validation

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Write code validating data entry in a DataWindow.

Write code validating data entry in a DataWindow.

Write custom error messages for DataWindow errors.

Write custom error messages for DataWindow errors.

Description:

In this lab, you will write code in the ItemChanged of the DataWindow on w_patient_new,
checking to see that the user has entered a Zip + 4 (a business rule). You will then add a
custom data entry error message in the ItemError event. Finally, you will write a custom
error message in the DBError event of your u_dw DataWindow control.

Description:

In this lab, you will write code in the ItemChanged of the DataWindow on w_patient_new,
checking to see that the user has entered a Zip + 4 (a business rule). You will then add a
custom data entry error message in the ItemError event. Finally, you will write a custom
error message in the DBError event of your u_dw DataWindow control.

Task Outline:

Task 1: Coding ItemChanged

Task Outline:

Task 1: Coding ItemChanged

Lab 15 - 12

Task 2: Coding ItemError

Task 2: Coding ItemError

Task 3: Coding DBError

Task 3: Coding DBError

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 15 - 12

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 15: Intermediate DataWindow Topics

Module 15: Intermediate DataWindow Topics

Detailed Instructions

Detailed Instructions

Task 1: Coding ItemChanged

Task 1: Coding ItemChanged

1.

Run the application. After logging in, click FileNewPatient. Click on the Zip
code column and enter 77777. Press the tab key. The cursor will move to the next
column.

1.

Run the application. After logging in, click FileNewPatient. Click on the Zip
code column and enter 77777. Press the tab key. The cursor will move to the next
column.

2.

Exit the application.

2.

Exit the application.

3.

Open w_patient_new.

3.

Open w_patient_new.

4.

Navigate to the DataWindows ItemChanged event.

4.

Navigate to the DataWindows ItemChanged event.

5.

There is one ItemChanged event, and several columns, so it is customary to use a


CHOOSE CASE statement in this event. In the CHOOSE CASE, evaluate dwo.name.

5.

There is one ItemChanged event, and several columns, so it is customary to use a


CHOOSE CASE statement in this event. In the CHOOSE CASE, evaluate dwo.name.

6.

In the CASE of zip, if the data entered (use the data argument of this event) is <> 9,
then code the appropriate return that will reject the value entered and not allow focus
to change. In WinHelp, look up ItemChanged event of the DataWindow for the
proper RETURN code:

6.

In the CASE of zip, if the data entered (use the data argument of this event) is <> 9,
then code the appropriate return that will reject the value entered and not allow focus
to change. In WinHelp, look up ItemChanged event of the DataWindow for the
proper RETURN code:

7.

Save but do not close the painter.

7.

Save but do not close the painter.

8.

Run the application and test your work.

8.

Run the application and test your work.

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 13

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 13

Module 15 Lab: Intermediate DataWindow Topics


9.

Module 15 Lab: Intermediate DataWindow Topics

Enter a zip code of 77777 and press the Tab key. You should now see the default
PowerBuilder message box displaying the data entry error. You can create a better
error message that PowerBuilders.

Enter a zip code of 77777 and press the Tab key. You should now see the default
PowerBuilder message box displaying the data entry error. You can create a better
error message that PowerBuilders.

10. Exit the application.

10. Exit the application.

11. Where did the title of the error message (Error accessing data) come from? HINT:
Open the a_sybhealth application object and look at its properties.

11. Where did the title of the error message (Error accessing data) come from? HINT:
Open the a_sybhealth application object and look at its properties.

Task 2: Coding ItemError

Task 2: Coding ItemError

1.

Navigate to the DataWindows ItemError event.

1.

Navigate to the DataWindows ItemError event.

2.

Put in the same CASE statement that you put in the ItemChanged event.

2.

Put in the same CASE statement that you put in the ItemChanged event.

3.

In CASE zip display a custom message box that tells the user they must enter a Zip
+ 4 value.

3.

In CASE zip display a custom message box that tells the user they must enter a Zip
+ 4 value.

4.

Save and run the application, not closing the painter. Test the same way you did
above.

4.

Save and run the application, not closing the painter. Test the same way you did
above.

5.

You should have received two different error messages, yours and the default
PowerBuilder message.

5.

You should have received two different error messages, yours and the default
PowerBuilder message.

6.

Look up the DataWindows ItemError event in WinHelp.

6.

Look up the DataWindows ItemError event in WinHelp.

7.

Apply the correct RETURN code to the ItemError event that suppresses the default
PowerBuilder message:

7.

Apply the correct RETURN code to the ItemError event that suppresses the default
PowerBuilder message:

8.

Save and test your work.

8.

Save and test your work.

9.

Exit the application and close any open painters.

9.

Exit the application and close any open painters.

Task 3: Coding DBError

Lab 15 - 14

9.

Task 3: Coding DBError

1.

Open u_dw.

1.

Open u_dw.

2.

Navigate to the DBError event.

2.

Navigate to the DBError event.

3.

The code you will put in this event is common code and does not need to be repeated.
Events can always be extended in the descendants or overridden if needed.

3.

The code you will put in this event is common code and does not need to be repeated.
Events can always be extended in the descendants or overridden if needed.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 15 - 14

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 15: Intermediate DataWindow Topics


4.

2010 Sybase, Inc.

Module 15: Intermediate DataWindow Topics

Code DBError as follows:

4.

Code DBError as follows:

a. Call sqlcas of_rollback( ) function.

a. Call sqlcas of_rollback( ) function.

b. Issue a message stating that a Database error has occurred, and in the message
box, display the specific Database error number and the text that goes along
with that number. When coding the message box, use the DBError event
arguments.

b. Issue a message stating that a Database error has occurred, and in the message
box, display the specific Database error number and the text that goes along
with that number. When coding the message box, use the DBError event
arguments.

c. Code a RETURN 1 to override the default PowerBuilder message box, similar


to what you did in the ItemError event.

c. Code a RETURN 1 to override the default PowerBuilder message box, similar


to what you did in the ItemError event.

5.

Sample code follows:

5.

Sample code follows:

6.

Close and save u_dw.

6.

Close and save u_dw.

7.

Using the System Tree, right-click over the SybHealth_target and select Search

7.

Using the System Tree, right-click over the SybHealth_target and select Search

8.

When prompted, enter update( ) as the search criteria.

8.

When prompted, enter update( ) as the search criteria.

9.

The output pane appears and the results display on a Search tab (in PowerBuilder 11).

9.

The output pane appears and the results display on a Search tab (in PowerBuilder 11).

10. There should be two places in the application where youve called update( ).

10. There should be two places in the application where youve called update( ).

11. In the search results, double-click over the line item containing
w_patient_master_detail. That object/event will open in the painter.

11. In the search results, double-click over the line item containing
w_patient_master_detail. That object/event will open in the painter.

12. Because of what you put into the DBError event, you no longer need the ELSE
section of the IF statement. Comment out the unneeded code.

12. Because of what you put into the DBError event, you no longer need the ELSE
section of the IF statement. Comment out the unneeded code.

13. Save and close w_patient_master_detail.

13. Save and close w_patient_master_detail.

14. If you wish, you can also re-factor the code in ue_save( ) of w_data_sheet. This is
optional.

14. If you wish, you can also re-factor the code in ue_save( ) of w_data_sheet. This is
optional.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 15

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 15

Module 15 Lab: Intermediate DataWindow Topics

Module 15 Lab: Intermediate DataWindow Topics

Lab 15-4: Completing Update Functionality

Lab 15-4: Completing Update Functionality

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Code a windows CloseQuery event

Code a windows CloseQuery event

Set DataWindow Update properties

Set DataWindow Update properties

Description:

In this lab, you will finish adding update functionality to the application. You still have
three windows, New Claim, New Patient and New Policy that are not saving their data.
These windows are response windows with only a DataWindow control on them, so you
will code their updates in the CloseQuery event. You also have the issue of not being able
to fully delete a claim. You will set the Claim Search DataWindows Update properties so
that its update code is now successful.

Description:

In this lab, you will finish adding update functionality to the application. You still have
three windows, New Claim, New Patient and New Policy that are not saving their data.
These windows are response windows with only a DataWindow control on them, so you
will code their updates in the CloseQuery event. You also have the issue of not being able
to fully delete a claim. You will set the Claim Search DataWindows Update properties so
that its update code is now successful.

Task Outline:

Task 1: Coding the CloseQuery Event

Task Outline:

Task 1: Coding the CloseQuery Event

Task 2: Setting DataWindow Update Properties

Lab 15 - 16

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Setting DataWindow Update Properties

2010 Sybase, Inc.

Lab 15 - 16

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 15: Intermediate DataWindow Topics

Module 15: Intermediate DataWindow Topics

Detailed Instructions

Detailed Instructions

Task 1: Coding the CloseQuery Event

Task 1: Coding the CloseQuery Event

1.

Open w_data_response.

1.

Open w_data_response.

2.

Create a new event on the window named ue_update that returns (None) and has no
arguments.

2.

Create a new event on the window named ue_update that returns (None) and has no
arguments.

3.

Code the event as youve done before, calling dw_datas Update( ) function and if it
returns 1 calling sqlcas of_commit( ) function.

3.

Code the event as youve done before, calling dw_datas Update( ) function and if it
returns 1 calling sqlcas of_commit( ) function.

4.

Save.

4.

Save.

5.

Navigate to the windows CloseQuery event.

5.

Navigate to the windows CloseQuery event.

6.

Code the event as follows:

6.

Code the event as follows:

a. With an IF statement, test to see if dw_datas ModifiedCount( ) + the


DeletedCount( ) is greater than 0. If so, then:

a. With an IF statement, test to see if dw_datas ModifiedCount( ) + the


DeletedCount( ) is greater than 0. If so, then:

b. Declare an integer variable named li_ret.

b. Declare an integer variable named li_ret.

c. In a message box, ask the user if they want to save changes before the window
closes. Give them three buttons, yes, no and cancel. Set the default button to
yes.

c. In a message box, ask the user if they want to save changes before the window
closes. Give them three buttons, yes, no and cancel. Set the default button to
yes.

d. Assign the return from the message box to the li_ret variable.

d. Assign the return from the message box to the li_ret variable.

e. Use a CHOOSE CASE to evaluate li_ret.

e. Use a CHOOSE CASE to evaluate li_ret.

f.

f.

If li_ret = 1 (which is yes), invoke the windows ue_update( ) event.

g. If li_ret = 2 or 3, look up via WinHelp the CloseQuery event and script the
appropriate RETURN codes for those conditions

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 17

If li_ret = 1 (which is yes), invoke the windows ue_update( ) event.

g. If li_ret = 2 or 3, look up via WinHelp the CloseQuery event and script the
appropriate RETURN codes for those conditions

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 17

Module 15 Lab: Intermediate DataWindow Topics

Lab 15 - 18

Module 15 Lab: Intermediate DataWindow Topics

7.

Sample code follows:

7.

Sample code follows:

8.

Save and test your work by adding a new claim, patient and policy. After you add
yourself as a Patient, use the Master-Detail and the filter feature you added to make
sure your code works and you see yourself as a patient. Add a new claim next. Do
not enter the Charged or Paid amounts. When you close and answer yes to save, you
will receive a DBError.

8.

Save and test your work by adding a new claim, patient and policy. After you add
yourself as a Patient, use the Master-Detail and the filter feature you added to make
sure your code works and you see yourself as a patient. Add a new claim next. Do
not enter the Charged or Paid amounts. When you close and answer yes to save, you
will receive a DBError.

9.

In FastTrack to PowerBuilder, Part II, you will learn how to make columns in a
DataWindow required and check for entry before updating the data.

9.

In FastTrack to PowerBuilder, Part II, you will learn how to make columns in a
DataWindow required and check for entry before updating the data.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 15 - 18

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 15: Intermediate DataWindow Topics

Module 15: Intermediate DataWindow Topics

10. Exit the running application and close any open painters.

10. Exit the running application and close any open painters.

Task 2: Setting DataWindow Update Properties.

2010 Sybase, Inc.

Task 2: Setting DataWindow Update Properties.

1.

Run the application and open the Claims Search window.

1.

Run the application and open the Claims Search window.

2.

Enter a patient_id of 10001 and click Search.

2.

Enter a patient_id of 10001 and click Search.

3.

Select a claim and click on the Delete icon on the toolbar.

3.

Select a claim and click on the Delete icon on the toolbar.

4.

This DataWindow is not Updatable. You will now correct this issue.

4.

This DataWindow is not Updatable. You will now correct this issue.

5.

Exit the application.

5.

Exit the application.

6.

Open the d_claims_list DataWindow object.

6.

Open the d_claims_list DataWindow object.

7.

In the DataWindow painter, select RowsUpdate Properties

7.

In the DataWindow painter, select RowsUpdate Properties

8.

Enable Allow Updates.

8.

Enable Allow Updates.

9.

Choose the claims table as the Table to Update.

9.

Choose the claims table as the Table to Update.

10. Set the Where Clause for Updates/Deletes to use Key and Updatable Columns.

10. Set the Where Clause for Updates/Deletes to use Key and Updatable Columns.

11. Click the Primary Key button which will select the appropriate column.

11. Click the Primary Key button which will select the appropriate column.

12. Under Updatable Columns, select all of the columns with the claims_ prefix:

12. Under Updatable Columns, select all of the columns with the claims_ prefix:

13. Click OK.

13. Click OK.

14. Close and save the DataWindow object.

14. Close and save the DataWindow object.

15. Run the application again to test your work. Make sure you can now delete a claim.

15. Run the application again to test your work. Make sure you can now delete a claim.

16. Exit the application and close any open painters.

16. Exit the application and close any open painters.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 19

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 15 - 19

Module 15 Lab: Intermediate DataWindow Topics

Lab 15 - 20

Fast Track to PowerBuilder, Part I Version 1.0

Module 15 Lab: Intermediate DataWindow Topics

2010 Sybase, Inc.

Lab 15 - 20

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 16: Deploying PowerBuilder Applications

Module 16: Deploying PowerBuilder Applications

Module 16: Deploying PowerBuilder Applications

Module 16: Deploying PowerBuilder Applications

Lab 16-1: Delivering the SybHealth Application

Lab 16-1: Delivering the SybHealth Application

Objectives:

Objectives:

After completing this lab, you should be able to:

After completing this lab, you should be able to:

Create executables from your PowerBuilder objects

Create executables from your PowerBuilder objects

Deploy a two-tier client-server application

Deploy a two-tier client-server application

Description:

You have completed all of the coding tasks for FastTrack to PowerBuilder, Part I. In this
lab, you will take your PBLs /objects and turn them into executables, making the
application ready to deploy to your end users. This process is called Deployment in
PowerBuilder. After you have completed the creation of your executables, you will
prepare the application for installation on an end-users machine.

Description:

You have completed all of the coding tasks for FastTrack to PowerBuilder, Part I. In this
lab, you will take your PBLs /objects and turn them into executables, making the
application ready to deploy to your end users. This process is called Deployment in
PowerBuilder. After you have completed the creation of your executables, you will
prepare the application for installation on an end-users machine.

Task Outline:

Task 1: Creating Executables

Task Outline:

Task 1: Creating Executables

Task 2: Preparing for Deployment to End Users

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Task 2: Preparing for Deployment to End Users

Lab 16 - 1

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 16 - 1

Module 16 Lab: Deploying PowerBuilder Applications

Module 16 Lab: Deploying PowerBuilder Applications

Detailed Instructions

Detailed Instructions

Task 1: Creating Executables

Task 1: Creating Executables

Lab 16 - 2

1.

In order to create executables in PowerBuilder, you must first create a Project.

1.

In order to create executables in PowerBuilder, you must first create a Project.

2.

In the System Tree, right-click over the SybHealth_target and select New

2.

In the System Tree, right-click over the SybHealth_target and select New

3.

On the New dialog, select the Project tab, click on Application and click OK:

3.

On the New dialog, select the Project tab, click on Application and click OK:

4.

You are now in the Project painter. Click FileSave As on the menu, saving the
project as p_sybhealth_exe in the sybhealth.pbl.

4.

You are now in the Project painter. Click FileSave As on the menu, saving the
project as p_sybhealth_exe in the sybhealth.pbl.

5.

Click the ellipsis button to the right of the Executable file name property and be sure
you are pointing to your Student directory. Drop the a_ prefix, naming your
executable sybhealth.exe.

5.

Click the ellipsis button to the right of the Executable file name property and be sure
you are pointing to your Student directory. Drop the a_ prefix, naming your
executable sybhealth.exe.

6.

Click the ellipsis button to the right of the Resource file name property and select the
SybHealth.PBR file you have created in the labs.

6.

Click the ellipsis button to the right of the Resource file name property and select the
SybHealth.PBR file you have created in the labs.

7.

Enable Full ReBuild.

7.

Enable Full ReBuild.

8.

Use PCode generation (you will be creating an EXE and PBDs).

8.

Use PCode generation (you will be creating an EXE and PBDs).

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 16 - 2

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 16: Deploying PowerBuilder Applications


9.

Module 16: Deploying PowerBuilder Applications

Uncheck the Enable DEBUG symbol property as we have written no conditional code
blocks in this application:

9.

10. Click on the Libraries tab of the project.

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Uncheck the Enable DEBUG symbol property as we have written no conditional code
blocks in this application:

10. Click on the Libraries tab of the project.

Lab 16 - 3

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 16 - 3

Module 16 Lab: Deploying PowerBuilder Applications

Lab 16 - 4

Module 16 Lab: Deploying PowerBuilder Applications

11. Click the Select All button. By doing this, you will be creating one (small) executable
and PBDs (for each PBL) that will be loaded and called on demand. This is the way
you should build most of your applications. There is no need to assign a Resource file
since we did that on the EXE:

11. Click the Select All button. By doing this, you will be creating one (small) executable
and PBDs (for each PBL) that will be loaded and called on demand. This is the way
you should build most of your applications. There is no need to assign a Resource file
since we did that on the EXE:

12. Click on the Version tab and complete details as seen below:

12. Click on the Version tab and complete details as seen below:

13. We are deploying to XP, not Vista, so there is no need to adjust properties on the
Security tab. Also no need to set anything on the Run tab.

13. We are deploying to XP, not Vista, so there is no need to adjust properties on the
Security tab. Also no need to set anything on the Run tab.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 16 - 4

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 16: Deploying PowerBuilder Applications

Module 16: Deploying PowerBuilder Applications

14. Save the project.

14. Save the project.

15. Click the Deploy icon (or RunDeploy sybhealth_target). The Output pane will
show the status of the Full Build followed by the creation of the Executables.

15. Click the Deploy icon (or RunDeploy sybhealth_target). The Output pane will
show the status of the Full Build followed by the creation of the Executables.

16. Check the Output pane for a successful deploy:

16. Check the Output pane for a successful deploy:

17. Using the System Tree, count and list below the number of PBLs that make up the
SybHealth application:

17. Using the System Tree, count and list below the number of PBLs that make up the
SybHealth application:

_____________________________________________________________________

_____________________________________________________________________

18. Open Windows Explorer and navigate to your Student directory.

18. Open Windows Explorer and navigate to your Student directory.

19. Sort the List view by Date Modified.

19. Sort the List view by Date Modified.

20. You should see your SybHealth.exe.

20. You should see your SybHealth.exe.

21. How many PBDs were created?

21. How many PBDs were created?

_____________________________________________________________________

_____________________________________________________________________

22. You had 10 PBLs. Where are the other PBDs?

2010 Sybase, Inc.

22. You had 10 PBLs. Where are the other PBDs?

_____________________________________________________________________

_____________________________________________________________________

23. Double-click your sybhealth.exe. Can you successfully run the application outside of
the PowerBuilder environment?

23. Double-click your sybhealth.exe. Can you successfully run the application outside of
the PowerBuilder environment?

_____________________________________________________________________

_____________________________________________________________________

24. Create a new folder under your Student folder. Name this folder For Deployment.

24. Create a new folder under your Student folder. Name this folder For Deployment.

25. Copy all of the PDBs and the EXE from the locations youve identified above to the
new For Deployment folder.

25. Copy all of the PDBs and the EXE from the locations youve identified above to the
new For Deployment folder.

26. In Windows Explorer, navigate to the For Deployment folder and try to execute the
sybhealth.exe. Were you successful this time? What else do you need to copy to this
folder?

26. In Windows Explorer, navigate to the For Deployment folder and try to execute the
sybhealth.exe. Were you successful this time? What else do you need to copy to this
folder?

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

Fast Track to PowerBuilder, Part I Version 1.0

Lab 16 - 5

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 16 - 5

Module 16 Lab: Deploying PowerBuilder Applications

Module 16 Lab: Deploying PowerBuilder Applications

27. Copy the healthcare3.jpg and the sybhealth.ini file into the deployment folder.

27. Copy the healthcare3.jpg and the sybhealth.ini file into the deployment folder.

28. Test running the application from your executables instead of running the application
from PowerBuilder.

28. Test running the application from your executables instead of running the application
from PowerBuilder.

Task 2: Preparing for Deployment to End Users

Lab 16 - 6

Task 2: Preparing for Deployment to End Users

1.

The For Deployment folder contains all of your executables as well as other files
necessary for deployment.

1.

The For Deployment folder contains all of your executables as well as other files
necessary for deployment.

2.

In addition to your files, what else do you need to copy to the end users machines?

2.

In addition to your files, what else do you need to copy to the end users machines?

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

3.

For this application, one of the items you should have identified above are the
PowerBuilder Runtime files. There is an easy way to package the Runtime files for
deployment, the PowerBuilder Runtime Packager.

3.

For this application, one of the items you should have identified above are the
PowerBuilder Runtime files. There is an easy way to package the Runtime files for
deployment, the PowerBuilder Runtime Packager.

4.

Click on the Windows Start buttonAll ProgramsSybasePowerBuilder


12.0PowerBuilder Runtime Packager.

4.

Click on the Windows Start buttonAll ProgramsSybasePowerBuilder


12.0PowerBuilder Runtime Packager.

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Lab 16 - 6

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

Module 16: Deploying PowerBuilder Applications

2010 Sybase, Inc.

Module 16: Deploying PowerBuilder Applications

5.

Select PowerBuilder Components (as this is not a .NET target), de-select all of the
Database Interfaces except for ODBC, and de-select all of the Other Component
options. These options are covered in other PowerBuilder classes. In the Select the
file name property, click the ellipsis button and navigate to your For Deployment
folder. On the Windows Save As dialog, use the icon to create a new folder under
For Deployment named PB Runtime Files. Name the deployment package
PB12Runtime.msi:

5.

Select PowerBuilder Components (as this is not a .NET target), de-select all of the
Database Interfaces except for ODBC, and de-select all of the Other Component
options. These options are covered in other PowerBuilder classes. In the Select the
file name property, click the ellipsis button and navigate to your For Deployment
folder. On the Windows Save As dialog, use the icon to create a new folder under
For Deployment named PB Runtime Files. Name the deployment package
PB12Runtime.msi:

6.

Click the Create button.

6.

Click the Create button.

7.

In Windows Explorer, verify the existence of the MSI (Microsoft Installer) file. This
file contains the core runtime files that will interpret your executables.

7.

In Windows Explorer, verify the existence of the MSI (Microsoft Installer) file. This
file contains the core runtime files that will interpret your executables.

8.

Click Done on the Runtime Packager dialog after you have completed the above step.

8.

Click Done on the Runtime Packager dialog after you have completed the above step.

9.

You would also need to make sure the end users had the SybHealth ODBC DSN
(Data Source Name) set up on their machines as you were instructed to do in Lab 1.

9.

You would also need to make sure the end users had the SybHealth ODBC DSN
(Data Source Name) set up on their machines as you were instructed to do in Lab 1.

10. Ideally, you should get a machine that had a brand new Windows installation, and test
your application installation in such an environment. There are many things that one
has to remember to copy in a production application: database client software/drivers,
help files, ActiveX/OLE controls, images, etc.

10. Ideally, you should get a machine that had a brand new Windows installation, and test
your application installation in such an environment. There are many things that one
has to remember to copy in a production application: database client software/drivers,
help files, ActiveX/OLE controls, images, etc.

11. To get the authoritative checklist for PowerBuilder deployment, you need to open the
PowerBuilder HTML books (StartAll ProgramsSybasePowerBuilder
12.0Compiled HTML Help File. Once opened, select the Contents tab. Under the
Application Techniques book there is a folder called Deployment Techniques.

11. To get the authoritative checklist for PowerBuilder deployment, you need to open the
PowerBuilder HTML books (StartAll ProgramsSybasePowerBuilder
12.0Compiled HTML Help File. Once opened, select the Contents tab. Under the
Application Techniques book there is a folder called Deployment Techniques.

12. Under Chapter 35, there is a section called Delivering your application to end users.
Click that section.

12. Under Chapter 35, there is a section called Delivering your application to end users.
Click that section.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 16 - 7

2010 Sybase, Inc.

Fast Track to PowerBuilder, Part I Version 1.0

Lab 16 - 7

Module 16 Lab: Deploying PowerBuilder Applications

Module 16 Lab: Deploying PowerBuilder Applications

13. You will see the Installation Checklist. This information (at least the location of this
information) needs to be committed to memory. The document contains hyperlinks
that show you other pages that list the runtime files (which were gathered by the
Runtime Packager and put into the MSI file) as well as their location (should you
choose not to use the Runtime Packager) and a wealth of other information. Spend
some time looking at this document when you get back to your office.

13. You will see the Installation Checklist. This information (at least the location of this
information) needs to be committed to memory. The document contains hyperlinks
that show you other pages that list the runtime files (which were gathered by the
Runtime Packager and put into the MSI file) as well as their location (should you
choose not to use the Runtime Packager) and a wealth of other information. Spend
some time looking at this document when you get back to your office.

14. The creation of executables is where PowerBuilder stops. How you get the
executables out to the end user is your decision. Some options you have:

14. The creation of executables is where PowerBuilder stops. How you get the
executables out to the end user is your decision. Some options you have:

a. Copy all of the application files (yours and PowerBuilders), to a shared


network drive and have the users run them from there or copy them locally and
run them.

a. Copy all of the application files (yours and PowerBuilders), to a shared


network drive and have the users run them from there or copy them locally and
run them.

b. Copy all of the application files to a WinZip self-extracting executable to give


to the end users. This is similar to what you did when you installed the course
Student files from the provided CD-ROM.

b. Copy all of the application files to a WinZip self-extracting executable to give


to the end users. This is similar to what you did when you installed the course
Student files from the provided CD-ROM.

c. Purchase a third-party tool like InstallShield and create a more professional


installation routine. The MSI file created by the Runtime Packager could be
called from a tool like InstallShield.

c. Purchase a third-party tool like InstallShield and create a more professional


installation routine. The MSI file created by the Runtime Packager could be
called from a tool like InstallShield.

d. Take the Moving to PowerBuilder 11 course and learn about .NET Windows
Form Target types, which include a Smart Client option where your
application could be deployed to your IIS Web Server (or File or FTP Server),
and your end users could execute or install by clicking a hyperlink on a
provided Web page.

d. Take the Moving to PowerBuilder 11 course and learn about .NET Windows
Form Target types, which include a Smart Client option where your
application could be deployed to your IIS Web Server (or File or FTP Server),
and your end users could execute or install by clicking a hyperlink on a
provided Web page.

15. Final thoughts: You have completed FastTrack to PowerBuilder, Part I. There is
much more to learn about the PowerBuilder environment. This class has been part of
a two-part series. FastTrack to PowerBuilder, Part II will take this same application
and add some of the following features:

15. Final thoughts: You have completed FastTrack to PowerBuilder, Part I. There is
much more to learn about the PowerBuilder environment. This class has been part of
a two-part series. FastTrack to PowerBuilder, Part II will take this same application
and add some of the following features:

a. Tab controls/pages

a. Tab controls/pages

b. Advanced controls: Tree Views, List Views, Rich Text, OLE, etc.

b. Advanced controls: Tree Views, List Views, Rich Text, OLE, etc.

c. Context or Pop Menus

c. Context or Pop Menus

d. Other DataWindow presentation styles like Graph, Crosstab, TreeView, etc.

d. Other DataWindow presentation styles like Graph, Crosstab, TreeView, etc.

e. DataStores

e. DataStores

f.

f.

Dynamically Modifying DataWindows

g. Creating DataWindows Dynamically

h. XML in PowerBuilder

h. XML in PowerBuilder

i.

Exception Handling in methods

i.

Exception Handling in methods

j.

And much more.

j.

And much more.

16. We recommend you take this knowledge home, use PowerBuilder at your job for
about 2 or 3 months and then come back and take Part II. Check the Sybase
Education web site for all of our PowerBuilder offerings.

Lab 16 - 8

Dynamically Modifying DataWindows

g. Creating DataWindows Dynamically

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

16. We recommend you take this knowledge home, use PowerBuilder at your job for
about 2 or 3 months and then come back and take Part II. Check the Sybase
Education web site for all of our PowerBuilder offerings.

Lab 16 - 8

Fast Track to PowerBuilder, Part I Version 1.0

2010 Sybase, Inc.

*DEV134-90-1200-10-LW-S*
Printed In Canada

*DEV134-90-1200-10-LW-S*
Printed In Canada

DEV134-90-1200-10

DEV134-90-1200-10

You might also like