Professional Documents
Culture Documents
Version 7
PowerBuilder
Windows
MC0024
March 1999
Information in this manual may change without notice and does not represent a commitment on the part of Sybase, Inc. and its
subsidiaries.
The software described in this manual is provided by Sybase, Inc. under a Sybase License agreement. The software may be used only in
accordance with the terms of the agreement.
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 the prior written permission of Sybase, Inc. and its subsidiaries.
Sybase, SYBASE (logo), ADA Workbench, Adaptable Windowing Environment, Adaptive Component Architecture, Adaptive Server,
Adaptive Server Anywhere, Adaptive Server Enterprise, Adaptive Server Enterprise Monitor, Adaptive Server Enterprise Replication,
Adaptive Server Everywhere, Adaptive Server IQ, 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 Developer, 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, DB-Library, dbQueue, Developers Workbench, Direct
Connect Anywhere, DirectConnect, Distribution Director, Electronic Case Management, Embedded SQL, EMS, Enterprise Application
Server, Enterprise Application Studio, Enterprise Client/Server, Enterprise Connect, Enterprise Data Studio, Enterprise Manager,
Enterprise SQL Server Manager, Enterprise Work Architecture, Enterprise Work Designer, Enterprise Work Modeler, EWA, First
Impression, Formula One, Gateway Manager, GeoPoint, ImpactNow, InfoMaker, Information Anywhere, Information Everywhere,
InformationConnect, InstaHelp, 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,
MySupport, Net-Gateway, Net-Library, NetImpact, Next Generation Learning, 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++, PowerJ, Power Through Knowledge, power.stop, PowerAMC,
PowerBuilder, PowerBuilder Foundation Class Library, PowerDesigner, PowerDimensions, PowerDynamo, PowerScript, PowerSite,
PowerSocket, Powersoft, PowerStage, PowerStudio, PowerTips, Powersoft Portfolio, Powersoft Professional, PowerWare Desktop,
PowerWare Enterprise, ProcessAnalyst, 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 Anywhere, SQL Anywhere Studio, SQL Code Checker, SQL Debug, SQL Edit, SQL Edit/TPU, SQL Everywhere, SQL
Modeler, SQL Remote, SQL Server, SQL Server Manager, SQL SMART, SQL Toolset, SQL Server/CFT, SQL Server/DBM, SQL Server
SNMP SubAgent, SQL Station, SQLJ, STEP, SupportNow, Sybase Central, Sybase Client/Server Interfaces, Sybase Development
Framework, Sybase Financial Server, Sybase Gateways, Sybase Learning Connection, Sybase MPP, Sybase SQL Desktop, Sybase SQL
Lifecycle, Sybase SQL Workgroup, Sybase Synergy Program, Sybase Virtual Server Architecture, Sybase User Workbench,
SybaseWare, SyberAssist, 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, UltraLite,
UNIBOM, Unilib, Uninull, Unisep, Unistring, URK Runtime Kit for UniCode, Viewer, Visual Components, VisualSpeller, VisualWriter,
VQL, WarehouseArchitect, Warehouse Studio, Warehouse WORKS, Watcom, Watcom SQL, Watcom SQL Server, Web.PB, Web.SQL,
WebSights, WebViewer, WorkGroup SQL Server, XA-Library, XA-Server and XP Server are trademarks of Sybase, Inc. or its
subsidiaries.
Unicode and the Unicode Logo are registered trademarks of Unicode, Inc.
iii
Contents
iv
Contents
v
About This Book
Subject This book provides information you need to start using PowerBuilder:
• Part 1 is an overview of the PowerBuilder development
environment
• Part 2 is a tutorial in which you build your first PowerBuilder
application
Audience This book is for anyone building applications using PowerBuilder.
Online Help When you have a question about using PowerBuilder, you can access its
extensive online Help system. In online Help you can see:
• Procedures for accomplishing tasks in PowerBuilder
• Reference information about PowerBuilder topics or components
• Context-sensitive information about PowerBuilder functions or
reserved words in scripts
For more information on getting online Help in PowerBuilder, see Part 2,
"The PowerBuilder Tutorial".
vii
About This Book
viii
About This Book
ix
About This Book
x
PART 1 Welcome to PowerBuilder
About this chapter This chapter introduces the PowerBuilder development environment. It
defines a number of terms and concepts that are used throughout the
PowerBuilder documentation set. It also describes each of the
development tools you’ll be using in the tutorial in Part 2.
Contents
Topic Page
About PowerBuilder for Windows 4
What PowerBuilder is 5
PowerBuilder objects 8
The PowerBuilder environment 16
3
About PowerBuilder for Windows
4
Chapter 1 Introduction to PowerBuilder
What PowerBuilder is
PowerBuilder is an object-oriented application development tool that allows
you to build powerful, multitier applications to run on multiple platforms and
interact with various databases. PowerBuilder is one of a group of Sybase
products that together provide the tools to develop client/server, distributed,
and Internet applications.
What’s in a A PowerBuilder application contains:
PowerBuilder
application? • A user interface Menus, windows, and window controls that users
interact with to direct an application.
• Application processing logic Event and function scripts in which you
code business rules, validation rules, and other application processing.
PowerBuilder allows you to code application processing logic as part of
the user interface or in separate modules, called custom class user
objects.
PowerBuilder In a PowerBuilder application, users control what happens by the actions they
applications are event take. For example, when a user clicks a button, chooses an item from a menu,
driven
or enters data into a textbox, one or more events are triggered. You write scripts
that specify the processing that should happen when events are triggered.
Windows, controls, and other application components you create with
PowerBuilder each have a set of predefined events. For example, each button
has a Clicked event associated with it and each textbox has a Modified event.
Most of the time, the predefined events are all you need. However, in some
situations, you may want to define your own events.
PowerScript language You write scripts using PowerScript, the PowerBuilder language. Scripts
consist of PowerScript commands, functions, and statements that perform
processing in response to an event.
For example, the script for a button’s Clicked event might retrieve and display
information from the database; the script for a textbox’s Modified event might
evaluate the data and perform processing based on the data.
The execution of an event script can also cause other events to be triggered. For
example, the script for a Clicked event in a button might open another window,
triggering the Open event in that window.
PowerScript functions PowerScript provides a rich assortment of built-in functions you can use to act
on the various components of your application. For example, there is a function
to open a window, a function to close a window, a function to enable a button,
a function to update the database, and so on.
5
What PowerBuilder is
You can also build your own functions to define processing unique to your
application.
Object-oriented Each menu or window you create with PowerBuilder is a self-contained
programming with module called an object. The basic building blocks of a PowerBuilder
PowerBuilder
application are the objects you create. Each object contains the particular
characteristics and behaviors (properties, events, and functions) that are
appropriate to it. By taking advantage of object-oriented programming
techniques such as encapsulation, inheritance, and polymorphism, you can
get the most out of each object you create, making your work more reusable,
extensible, and powerful.
Internet applications You can develop PowerBuilder applications that run on the web. PowerBuilder
web applications take advantage of these technologies:
• Web.PB Includes object functions that can be invoked by web browsers
• DataWindow plugin Allows a web browser to display a Powersoft
report (PSR)
• PowerBuilder window plugin and PowerBuilder window ActiveX
Allow a web browser to display a PowerBuilder window
• DataWindow ActiveX and DataWindow JavaBeans components
Allow the use of DataWindow objects created in the PowerSite or PowerJ
development environments
• JavaBeans proxy classes Allow a Java client to access a
PowerBuilder server
For information about Web.PB and PowerBuilder plugins, see Using the
PowerBuilder Internet Tools. For information about DataWindow ActiveX and
DataWindow Java Beans components, see the DataWindow Programmer’s
Guide and the DataWindow Reference. For information about the JavaBeans
proxy generator, see Application Techniques.
Distributed PowerBuilder lets you build applications that run in a distributed computing
applications environment. A distributed application lets you:
• Centralize business logic on servers (Jaguar CTS, MTS, and distributed
PowerBuilder servers)
• Partition application functions between the client and the server, thereby
reducing the client workload
• Build scalable applications that are easy to maintain
For information about multitier applications, see the sections on distributed
application techniques in Application Techniques.
6
Chapter 1 Introduction to PowerBuilder
7
PowerBuilder objects
PowerBuilder objects
The basic building blocks of a PowerBuilder application are objects:
Object Use
Application Entry point into an application
Window Primary interface between the user and a PowerBuilder
application
DataWindow Retrieves and manipulates data from a relational database or
other data source
Menu List of commands or options that a user can select in the
currently active window
Global function Performs general-purpose processing
Query SQL statement used repeatedly as the data source for a
DataWindow object
Structure Collection of one or more related variables grouped under a
single name
User object Reusable processing module or set of controls
Library Stores PowerBuilder objects, such as windows and menus
Project Packages application for distribution to users
These objects are described in more detail in the sections that follow.
Application object The Application object is the entry point into an application. It is a discrete
object that is saved in a PowerBuilder library (PBL file), just like a window,
menu, function, or DataWindow object.
8
Chapter 1 Introduction to PowerBuilder
9
PowerBuilder objects
The script you write for the Close event typically does all the cleanup required,
such as closing a database or writing to a preferences file. If there are serious
errors during execution, the Application object’s SystemError event is
triggered.
Windows Windows are the primary interface between the user and a PowerBuilder
application. Windows can display information, request information from a
user, and respond to the user’s mouse or keyboard actions.
A window consists of:
• Properties that define the window’s appearance and behavior (for
example, a window might have a title bar and a Minimize box)
• Events triggered by user actions
• Controls placed in the window
10
Chapter 1 Introduction to PowerBuilder
At the top of the window is the title bar with minimize, maximize, and close
buttons. This window contains a static text control, a dropdown listbox, and a
multiline edit control, as well as two command buttons.
DataWindow objects A DataWindow object is an object that you use to retrieve and manipulate
data from a relational database or other data source (such as an Excel
worksheet or dBASE file).
Presentation styles DataWindow objects also handle the way data is
presented to the user. You can choose from several presentation styles. For
example, you can display the data in a Tabular or a Freeform style.
There are many ways to enhance the presentation and manipulation of data in
a DataWindow object. For example, you can include computed fields, pictures,
and graphs that are tied directly to the data retrieved by the DataWindow.
Display formats, edit styles, and validation You can specify how to
display the values for each column, and you can validate data entered by users
in a DataWindow object. You do this by defining display formats, edit styles,
and validation rules for columns.
11
PowerBuilder objects
For example:
• If a column can take only a small number of values, you can have the data
appear as radio buttons in a DataWindow so users know what their choices
are.
• If the data includes phone numbers, salaries, and dates, you can format the
display to suit the data.
• If a column can take numbers only in a specific range, you can specify a
simple validation rule for the data. This can spare you writing code to
make sure users enter valid data.
Menus Menus are lists of items that a user can select from a menu bar for the active
window. The items on a menu are usually related. They provide the user with
commands (such as Open and Save As on the PowerBuilder File menu) or
alternate ways of performing a task (for example, the items on the Edit menu
in the Window painter correspond to buttons in the PainterBar).
You can select menu items with the mouse or with the keyboard, or use
accelerator (mnemonic access) keys defined for the items. You can define your
own keyboard shortcuts for any PowerBuilder menu item from a dialog box
that you open with the Window>Keyboard Shortcuts menu item.
12
Chapter 1 Introduction to PowerBuilder
A dropdown menu is a menu under an item in the menu bar. A cascading menu
is a menu that appears to the side of an item in a dropdown menu.
13
PowerBuilder objects
14
Chapter 1 Introduction to PowerBuilder
You can create Project objects that build executable applications, dynamic
libraries, and components you can deploy to a transaction server, as well as
Java classes, HTML files, and proxy objects you use in distributed
applications.
Providing additional resources When you package an application, you
may also need to provide some additional resources, such as bitmaps and icons.
PowerBuilder allows you to include additional resources in an executable
and/or dynamic libraries, or distribute them separately.
15
The PowerBuilder environment
You can open painters and perform other tasks by clicking buttons in any
standard or customized PowerBuilder toolbars. Standard toolbars include the
PowerBar, the PainterBar, and the StyleBar.
PowerBar The PowerBar displays when you begin a PowerBuilder session. The
PowerBar is the main control point for building PowerBuilder applications.
From the PowerBar, you can open a PowerBuilder painter or the Browser,
debug or run the current application, change applications, or modify the library
search path.
You can use the New, Inherit, or Open buttons on the PowerBar to open all of
the PowerBuilder painters.
16
Chapter 1 Introduction to PowerBuilder
PainterBar When you open a painter, PowerBuilder displays a new window that has a
workspace in which you design the object you’re building. PowerBuilder also
displays one or more PainterBars with buttons that provide easy access to the
tools available in the painter.
StyleBar The StyleBar displays when you open any painter that can contain text
controls, such as the Window painter. Using buttons on the StyleBar, you can
modify text properties such as the font and point size.
PowerTips When you leave the mouse pointer over a button for a second or two,
PowerBuilder can display a brief description of the button (a PowerTip). The
ability to display PowerTips is toggled on and off by selecting the Show
PowerTips menu item in any toolbar popup menu.
You can also include brief descriptive texts on all toolbar buttons by selecting
ShowText from any toolbar popup menu.
Customizing toolbars In addition to displaying text in toolbar buttons, you can move the toolbars
around, and dock the toolbars wherever you like. You can add new toolbars or
customize existing ones through the New and Customize items of any toolbar
popup menu, or through the Window>Toolbars option of all standard
PowerBuilder menus. You can add buttons for opening painters and
performing other activities.
17
The PowerBuilder environment
PowerBar buttons The buttons in the PowerBar give you access to the most commonly used
PowerBuilder tools:
Button Accesses Use to
New dialog box Create new application, component, or other
object
18
Chapter 1 Introduction to PowerBuilder
19
The PowerBuilder environment
20
CH A PTE R 2 About the PowerBuilder Tutorial
About this chapter This chapter describes what you will do in the PowerBuilder tutorial and
how to get set up for it.
Contents
Topic Page
What you will do 22
How you will proceed 24
How long it will take 24
What you will learn 24
Setting up 26
21
What you will do
Both windows are master/detail windows: each allows you to display a master
list of rows in a particular table and also see detailed information for each row
in the table. For example, the top half of the Maintain Products window
contains a list of products with a pointer to a single product; the bottom half of
the window displays extra detail for the current product.
Logon window The tutorial application also includes a logon window that allows you to
connect to the database at startup time.
22
Chapter 2 About the PowerBuilder Tutorial
A cross-platform application
This tutorial tells you how to build a cross-platform application. That means
the objects you create using PowerBuilder for Windows will also run on UNIX
with little or no modification and will display almost identically in all
environments.
23
How you will proceed
24
Chapter 2 About the PowerBuilder Tutorial
This tutorial will not make you an expert in PowerBuilder. Only experience
building real-world applications can do that. But it will give you hands-on
experience and provide a foundation for continued growth.
25
Setting up
Setting up
Before you start the tutorial, you need to make sure you can connect to a
database and that you have the tutorial files.
Required tutorial This tutorial will use the EAS Demo DB database that installs with
setup PowerBuilder. This is an Adaptive Server Anywhere database and requires an
Adaptive Server Anywhere engine.
If you do not already have Adaptive Server Anywhere on your local machine
or server, you must install it now. (You can install it from the PowerBuilder
CD.) If you installed PowerBuilder in a nondefault location, you must make
sure that the odbc.ini registry entry defining the EAS Demo DB as a data
source points to the correct location of the Adaptive Server Anywhere engine.
The tutorial also uses the following files:
File Contents
tutor_pb.pbl PowerBuilder library that contains several objects you will
use in the tutorial
tutorial.ico An icon
tutsport.bmp A bitmap
Make sure the files you need for the tutorial are on your hard disk in the
Tutorial directory, a subdirectory of the PowerBuilder installation directory.
When you have finished with the tutorial, you can delete the files.
26
PART 2 The PowerBuilder Tutorial
29
Create a new PowerBuilder application
Now you will start PowerBuilder and run the Template Application wizard.
The Template Application wizard creates precoded events, menus, windows,
and user objects in addition to the Application object.
If you only wanted to create the Application object and code the rest by hand,
you could use the Application wizard instead. But for the tutorial, you will use
the Template Application wizard for its greater convenience in getting started
with a new application.
30
Lesson 1 Starting PowerBuilder
2 Select Template Application from the New page of the dialog box.
Click OK.
The Template Application wizard displays.
3 Click Next twice until the Specify New Application And Library page
displays.
You step through two introductory screens of the Template Application
wizard.
31
Create a new PowerBuilder application
6 Click Next four times until the Name MDI Base Sheet, Menu and Service
page displays.
In addition to the names you entered for the tutorial application and library
file, you accept the wizard-proposed defaults for application type, library
search path, and frame and frame menu names.
32
Lesson 1 Starting PowerBuilder
This will be the ancestor window for windows in the tutorial application.
You accept the default sheet menu name and sheet manager service name.
8 Click Next.
On the Name Individual Sheets page, type w_customers for Sheet 1,
w_products for Sheet 2, and clear the Sheet 3 textbox.
You will generate two windows based on the w_master_detail_ancestor
base sheet, one for customers and one for products.
9 Click Next.
Type Maintain Customers as the display name for Sheet 1.
Type Maintain Products as the display name for Sheet 2.
33
Create a new PowerBuilder application
The names you type will display in the title bars of these sheet windows.
11 Select None.
You will add a Connection object later.
12 Click Next twice until the Ready To Create Application page displays.
34
Lesson 1 Starting PowerBuilder
This is the last wizard screen. It lists your current selections. The Generate
To-Do List checkbox is selected by default.
35
Run the application
Now you will run the application to see how it works. At this point the
application doesn’t do very much. By running the application, you can see the
windows and menus that were created for you when you generated the
application using the Template Application wizard. You will modify them later.
36
Lesson 1 Starting PowerBuilder
7 Select Top.
The toolbar is repositioned at the top of the frame.
9 Select File>Exit.
You terminate the application and return to the PowerBuilder development
environment.
37
Open the Application object
Now you will open the Application object in the Application painter and view
the new tutorial application. You will add objects to it later.
38
Lesson 1 Starting PowerBuilder
3 Click OK.
The Application painter displays several views of the current Application
object in the painter workspace.
The picture that follows shows the Script view, the Properties view, and
the Non-Visual Object List view. The Event List and Function List views
are available in a tabbed pane behind a second Script view that displays
declared instance variables (none in this case). Your view layout scheme
may look different.
39
Manipulate views
Manipulate views
Where you are
Create a new PowerBuilder application
Run the application
Open the Application object
> Manipulate views
Control the toolbars
Specify an icon for the application
Now you will control the location and appearance of PowerBuilder painter
views. You can add views to a painter workspace by selecting them from the
View menu in the painter menu bar.
The Application painter has seven types of views. You can add multiple views
of the same type, and you can combine views into a stack of panes with
selection tabs at the bottom.
You can resize a view by grabbing and dragging separator bars that surround it
or that surround neighboring views in the painter workspace. You manipulate
views in all painters the same way.
Now you will:
• Pin view title bars
• Float and dock views
• Save a view layout scheme
• Reset the default view layout scheme
• Manipulate tabbed views
40
Lesson 1 Starting PowerBuilder
1 Move the cursor to the top area of any view in the painter area.
The view title bar rolls down. It contains a pushpin button on the left and
a maximize/minimize button and a close button on the right. Between is
the name of the view, and in certain views, information about a view
selection.
41
Manipulate views
42
Lesson 1 Starting PowerBuilder
43
Manipulate views
3 Click OK.
You return to the painter workspace. The default view layout scheme
displays in the painter workspace.
44
Lesson 1 Starting PowerBuilder
1 Press and hold the mouse button on the Function List tab.
Drag the tab over the separator bar between the tabbed pane and the
Script view that is not part of the stack.
Release the mouse button.
When you start dragging a view, a gray rectangular outline of the view
displays. The rectangle changes size when it is dragged over a separator
bar.
When you release the mouse button, the Function List view is no longer
part of stack, unless you dragged it too far and released it over the Script
view. In this case, just repeat the step and make sure you drop the view
over a separator bar.
2 Press and hold the mouse button on the Function List title bar.
Drag it over the Event List view.
If you release the view when its outline coincides with the target view, it
becomes part of the stack.
Do not close the Application painter. You will use it in the next exercise.
45
Control the toolbars
Now you will learn how to control the location and appearance of the
PowerBuilder toolbars. With the Application painter open, you have access to
two default PainterBars as well as the PowerBar.
1 Move the pointer to any button on the PowerBar, but do not click.
PowerBuilder displays a PowerTip identifying the button’s function.
3 Select the Show Text checkbox, then click the Close button.
PowerBuilder displays a label on each of the buttons in the PowerBar and
the PainterBars.
46
Lesson 1 Starting PowerBuilder
The popup menu for the toolbars displays. The popup menu allows you to
put toolbars in many different locations: left, top, right, bottom, and
floating.
5 Select Floating in the popup menu and release the mouse button.
The PowerBar changes to a floating toolbar. You can adjust its shape.
47
Control the toolbars
7 Drag the floating toolbar toward the left side of the workspace.
Release the mouse button when the toolbar becomes a vertical bar.
9 Click Top.
This repositions the PowerBar at the top of the screen.
48
Lesson 1 Starting PowerBuilder
49
Specify an icon for the application
Now you will specify an icon for the application. The icon will appear in the
workspace when you minimize the application during execution.
PowerBuilder includes the icon automatically when you create an executable
file.
You specify an icon from the Properties view on the Application painter. If the
Properties view is not open, you can open it by selecting View>Properties from
the Application painter menu bar. You can also open a Properties view by
resetting the default view layout scheme.
3 Click Browse.
Navigate to the Tutorial directory.
50
Lesson 1 Starting PowerBuilder
The tutorial icon displays on the Icon page of the Application property
sheet.
51
Specify an icon for the application
52
LE S S O N 2 Building a Logon Window
53
Create a new window
Now you will create a new window for the application. The window you will
create is a logon window that allows the user to enter a user ID and password
and connect to the database. The logon window is a response window.
3 Make sure that the Layout view and a Properties view display in your
Window painter.
The default view layout scheme contains these views.
54
Lesson 2 Building a Logon Window
The rectangle in the Layout view represents the window you are building.
The default properties in the Properties view indicate that the window will
be visible and enabled, and will have the Main window type.
55
Create a new window
4 Type Welcome in the Title box on the General page of the Properties
view.
Select response! in the Window Type dropdown listbox.
56
Lesson 2 Building a Logon Window
You can see the size of the window rectangle in the Layout view change
after you type these values. The values you type are in PowerBuilder Units
(PBUs). You may need to modify these values later, while you are adding
controls to the window.
10 Click OK.
PowerBuilder saves the new logon window.
57
Add controls to the window
58
Lesson 2 Building a Logon Window
Button
appearance Control type Use in tutorial
SingleLineEdit To add user entry textboxes to the logon
window
After you click the picture of the button you want, it appears in place of the
Command button as the active button in PainterBar1.
Now you will modify the logon window you just created by adding controls
and changing some of their properties. You will:
• Add a Picture control
• Add StaticText controls
• Specify properties of the StaticText controls
• Add SingleLineEdit controls
• Specify properties of the SingleLineEdit controls
• Add CommandButton controls
• Specify properties of the CommandButton controls
59
Add controls to the window
3 Select the text p_1 in the Name box in the Properties view.
Type p_sports in the Name box.
This names the Picture control. The prefix p_ is standard for Picture
controls.
60
Lesson 2 Building a Logon Window
The bitmap you selected appears in the control you added to the Layout
view. The Visible, Enabled, and OriginalSize checkboxes are selected by
default in the Properties view.
7 Type 300 in the Width box and 250 in the Height box.
You change the size of the picture control. You may want to adjust the
picture size again after you preview the window.
61
Add controls to the window
2 Click to the right of the Picture control you added in the Layout view.
A StaticText control displays at the selected location. It is selected.
62
Lesson 2 Building a Logon Window
5 Adjust the size of the StaticText control to fit the text you entered.
Keep adjusting until you see all of the text you entered.
To adjust the size, you can drag the upper-right corner of the control
toward the upper-right corner of the window in the Layout view.
You can also enter appropriate values on the Other page of the Properties
view for this control.
63
Add controls to the window
7 Select the second StaticText control you added in the Layout view.
Type st_userid in the Name box on the Properties view General page.
Type User ID: in the Text box.
You change the name of the control and the text that displays in the control
in the Layout view.
8 Select the third StaticText control you added in the Layout view.
Type st_password in the Name box on the Properties view General
page.
Type Password: in the Text box.
Your changes display in the Layout view.
64
Lesson 2 Building a Logon Window
2 Click to the right of the User ID: StaticText control in the Layout view.
A SingleLineEdit control displays where you clicked.
65
Add controls to the window
66
Lesson 2 Building a Logon Window
67
Add controls to the window
2 Type cb_ok in the Name box on the Properties view General page.
Type OK in the Text box.
Select the Default checkbox.
You change the default name of the control to something more descriptive
and add a label to the button. Because you selected the Default checkbox,
the ENTER key will trigger the Clicked event for this button.
68
Lesson 2 Building a Logon Window
When you place controls in a window, PowerBuilder assigns them a default tab
order. The tab order determines the sequence in which focus moves from
control to control when the user presses the TAB key.
Now you will change the tab order for the window you created.
69
Code some Help events and preview the window
Now you will use the Script view to add context Help messages to the
SingleLineEdit controls that you placed on the logon window and you will
preview the window. If a Script view is not currently displayed in your Window
painter, you can open one by double-clicking an object in the Layout view.
Using the Script view The Script view has three dropdown listboxes. The
first dropdown listbox displays the list of available controls for the current
object plus the special entries, Functions and Declare.
The contents of the second dropdown listbox depend on the selection in the
first dropdown listbox. The third dropdown listbox contains all ancestor
objects of the current object, if any.
Selection in first Contents of second Contents of third
dropdown listbox dropdown listbox dropdown listbox
An object or control List of events for the Current object and all
name selected object or control ancestor objects
Functions List of editable functions All ancestor objects with
functions having the same
signature as selected function
Declare List of declaration types: Empty
global, local, and instance
variables, and global and
local external functions
70
Lesson 2 Building a Logon Window
2 Select the Help event in the second dropdown listbox in the Script
view.
The second dropdown listbox shows the complete prototype for the Help
event:
4 Select sle_password from the first dropdown listbox in the Script view.
Select the Help event in the second dropdown listbox.
PowerBuilder compiles the code you typed for the Help event of the
sle_userid SingleLineEdit box. The script for the Help event of the
sle_password SingleLineEdit box is still empty.
71
Code some Help events and preview the window
7 Click OK.
A message box prompts you to save your changes to the window.
72
Lesson 2 Building a Logon Window
The message you typed for this edit box Help event displays in a message
box.
73
Write the script to open the window
Now you will add a one-line script to open the logon window as soon as the
application starts executing. You will add this script to the Open event of the
MDI frame window. This window (w_pbtutor_frame) was created by the
Template Application wizard.
The MDI frame is called by the application Open event. But, because the logon
window is a response window, if you call the logon from the frame window,
the logon window still displays before the frame window.
In this exercise you will:
• Modify the frame window Open event
• Compile the script
74
Lesson 2 Building a Logon Window
Wizard-generated script
The Open event already has a script associated with it that was generated by
the Template Application wizard. The script creates an instance of a wizard-
generated user object that serves as a sheet (window) manager. The Open script
then calls the ue_postopen event.
The ue_postopen event registers sheet windows with the sheet manager. The
event is posted to the end of the messaging queue for the window. It will be
processed after any script that you add to the Open event is executed.
2 Click OK.
The Window painter opens and displays views of the main application
window in the painter workspace.
If the Script view is not open, you can open it by selecting View>Script in
the painter menu bar or by double-clicking inside the Layout view.
75
Write the script to open the window
3 Make sure the Open event displays in the the Script view.
Display the title bar of the Script view.
The title bar of the Script view reads:
Script - open for w_pbtutor_frame returns long
Using comments
A comment in PowerScript is indicated by either two forward slashes (//)
at the start of a single-line comment, or a slash and an asterisk (/*) at the
start and an asterisk and a slash (*/ ) at the end of a single-line or multiline
comment. Comments are not parsed by the script compiler.
You will now modify the Open event script to cause the logon window to
display.
6 Type Open the logon window on the new line in the Script view.
Click the Comment button in PainterBar2.
Two slashes appear in front of the line you typed—it is changed into a
comment.
76
Lesson 2 Building a Logon Window
7 Press ENTER.
Type open (w_welcome) on the new line in the Script view.
This calls the Open function to display the logon window you created.
77
Write the script to open the window
78
LE S S O N 3 Connecting to the Database
This lesson shows you how to make the application connect to the EAS
Demo DB database at execution time and how to use the Database painter
to look at the table definitions and database profile for this database.
In this lesson you will:
• Look at the EAS Demo DB database
• Run the Connection Object wizard
• Declare a global variable
• Modify the connection information
• Complete the logon and logout scripts
• Run the application
79
Look at the EAS Demo DB database
80
Lesson 3 Connecting to the Database
81
Look at the EAS Demo DB database
82
Lesson 3 Connecting to the Database
83
Look at the EAS Demo DB database
3 Click Edit.
PowerBuilder displays the Connection page of the Database Profile Setup
dialog box.
84
Lesson 3 Connecting to the Database
85
Look at the EAS Demo DB database
2 Expand the tree view in the Objects view under the EAS Demo DB V3
database node.
86
Lesson 3 Connecting to the Database
4 Right-click the DBA.customer table and select Add to Layout from the
popup menu.
or
Drag the DBA.customer table from the Objects view to the Object
Layout view.
For Adaptive Server Anywhere databases, each table name is prefixed by
a table owner name (DBA for the tutorial database tables). For greater
convenience in referring to the database tables, the table owner name is
omitted when a table is mentioned in the remainder of this tutorial.
87
Look at the EAS Demo DB database
The Object Layout view shows the two tables you selected.
6 Right-click the title bar of the customer table in the Object Layout view
and select Alter Table from the popup menu.
or
Right-click the customer table in the Objects view and select Alter Table
from the popup menu.
The Columns view shows the column definitions for the table.
88
Lesson 3 Connecting to the Database
The Object Details view for a column has five tabs, one for general
database properties, one for column header information, and the others for
column extended attributes.
89
Run the Connection Object wizard
Now you will run the Connection Object wizard to create a connection service
manager that you will use to establish the runtime database connection.
The connection service manager is a nonvisual user object. It is nonvisual
because it does not have a graphic representation in the runtime application; it
is a user object because it is a customized object. You use it to perform database
connection processing in a PowerBuilder application.
90
Lesson 3 Connecting to the Database
3 Click Next three times until you see the Choose Database Connection
Profile page.
You accept the wizard’s default selections for the destination library
(pbtutor.pbl) and the database connectivity options (SQL). The Choose
Database Connection Profile page lists all the database profiles stored in
the pb.ini file.
5 Click Next three times until the Ready To Create Connection Object
page.
You accept the default settings for the following items:
Wizard page Option Default selection
Specify Source of Connection Application INI File
Connectivity Source Information
Info
Connection Service n_pbtutor_connectservice
Object
Name Application Application INI File pbtutor.ini
INI File
91
Run the Connection Object wizard
6 Click Finish.
The wizard creates the connection service object and the application INI
file. The To Do List is still open.
92
Lesson 3 Connecting to the Database
You will now examine the new connection service manager and create a global
variable to reference it. A global variable is available to all objects in the
application.
In more complex applications, you might prefer to reference the connection
service manager with local variables. This would release more memory as soon
as the local variable went out of scope. But in the tutorial, you want to keep an
instance of the connection service manager available as long as the database
connection is open.
Establishing a connection To make it possible for an application to
connect to the database at execution time, the connection service manager calls
a wizard-generated function to set properties for a Transaction object that
serves as a communications area between the application and the database.
SQLCA Transaction object The connection service manager uses a built-in
nonvisual system object, the SQL Communications Area (SQLCA) object, as
the default Transaction object. The SQLCA object has several default
properties (including database name, login ID, and password) that are
populated by the connection service manager.
If an application communicates with multiple databases, you can create
additional Transaction objects as needed, one for each database connection.
93
Declare a global variable
94
Lesson 3 Connecting to the Database
95
Declare a global variable
Although you declare this object in the Script view for the
n_pbtutor_connectservice user object, it is available everywhere in the
application.
96
Lesson 3 Connecting to the Database
You can now call the connection service manager to establish a database
connection. But you want to open a database connection only if the user enters
a valid ID and password in the logon window. You will therefore add the
connection service call to the Clicked event of the OK button on this window,
substituting user-entered information for information from the pbtutor.ini file.
But before you do that, you remove or comment out the ProfileString calls that
the connection service manager makes to get user ID and password information
from the INI file. Then you modify the DBParm parameter in the pbtutor.ini
file, because it includes hard-coded user ID and password values that were
copied from the pb.ini file.
In this exercise you will:
• Modify the of_GetConnectionInfo function
• Call the connection service manager
97
Modify the connection information
98
Lesson 3 Connecting to the Database
99
Modify the connection information
100
Lesson 3 Connecting to the Database
These lines explain the code you will add to the Clicked event. Adding
double slash marks at the front of a line turns it into a comment.
101
Modify the connection information
You still need to code the Clicked event to instantiate the Transaction
object with user-entered connection information.
102
Lesson 3 Connecting to the Database
Earlier in this lesson, you called the connection service manager from the
Clicked event for the logon window OK button. Now you will add code to the
same Clicked event to instantiate the Transaction object with information
entered by the user.
You will also add code to the logon window Cancel button Clicked event and
to the application Closed event.
103
Complete the logon and logout scripts
1 Make sure you are looking at the Clicked event script for the cb_ok
control.
This is the script in which you added the call to the Connection Service
object.
//Assignment statements
ls_userid = Trim ( sle_userid.text )
ls_password = Trim ( sle_password.text )
ls_database = "ConnectString=’DSN=EAS Demo DB V3;"
You declare local variables here and assign them values. The Trim
function removes leading and trailing spaces from the user ID and
password values passed as arguments to the function from the
SingleLineEdit boxes on the logon window.
3 Click after the lines you just added (and after the CREATE statement)
but before the IF-THEN statement.
Type the following lines:
//Instantiate with user-entry values
SQLCA.userid = ls_userid
SQLCA.dbpass = ls_password
SQLCA.dbparm = ls_database + "UID=" + &
ls_userid + ";PWD=" + ls_password + "’"
These lines instantiate SQLCA parameters with values from the
SingleLineEdit textboxes.
104
Lesson 3 Connecting to the Database
The lines must be added to the script after the CREATE statement to keep
them from being overwritten with blank values from the Constructor event
of the connection service manager. They must be added before the IF-
THEN statement or their values would not be used by the Transaction
object when it is called by the of_ConnectDB function of the connection
service manager.
105
Complete the logon and logout scripts
106
Lesson 3 Connecting to the Database
107
Complete the logon and logout scripts
8 Click Yes.
You save your changes and close the Application painter.
108
Lesson 3 Connecting to the Database
3 Click OK.
The database connection is established and the MDI frame for your
application displays.
109
Run the application
110
LE S S O N 4 Modifying the Ancestor Window
In this lesson you will modify the ancestor sheet window that you
generated with the Application Template wizard. You will:
• Add DataWindow controls to the ancestor sheet window
• Add user events and event scripts
• Add scripts to retrieve data for the DataWindow controls
• Rebuild library objects
111
Add DataWindow controls
Now you will open a window that you generated with the Template Application
wizard and add DataWindow controls to it. The window you will modify was
generated as the ancestor to the sheet windows: w_customers and w_products.
The DataWindow controls you will add to the ancestor window will inherit
their definitions from a user object that was created for the tutorial application.
The user object is a customized DataWindow control that includes scripts to
perform standard database error checking.
The user object is provided in a PBL file that is installed with PowerBuilder.
All you need to do to use this user object is to include its PBL in the library
search path and place it in the ancestor window.
112
Lesson 4 Modifying the Ancestor Window
113
Add DataWindow controls
You return to the library list. The tutor_pb.pbl file is now included in the
search path for the tutorial application.
4 Click OK.
114
Lesson 4 Modifying the Ancestor Window
115
Add DataWindow controls
5 Click OK.
You return to the Window painter.
116
Lesson 4 Modifying the Ancestor Window
8 Select the text dw_1 in the Name box in the Properties view.
Type dw_master in the Name box.
Select the Vscroll Bar checkbox.
117
Add DataWindow controls
6 Select the text dw_1 in the Name box in the Properties view.
Type dw_detail in the Name box.
PowerBuilder changes the name of the control to dw_detail.
118
Lesson 4 Modifying the Ancestor Window
2 Select dberror from the second dropdown listbox in the Script view.
This script is also empty. A script icon next to the event name is purple.
This indicates that the ancestor control has an associated script.
119
Add DataWindow controls
120
Lesson 4 Modifying the Ancestor Window
Windows, user objects, and controls have predefined events associated with
them. Most of the time, the predefined events are all you need. But there are
times when you will want to declare your own events. Events that you define
are called user events.
Purpose of user events One reason to define a user event is to reduce
coding in situations where an application provides several ways to perform a
particular task. For example, a task like updating the database can be
performed by clicking a button, selecting a menu item, or closing a window.
Instead of writing the code to update the database in each of these places, you
could define a user event, then trigger that user event in each place you update
the database.
Now you will define some user events to handle retrieval, insert, update, and
delete operations against the tutorial database. You make these changes in the
Script view of the Window painter. Later in the tutorial, you will add code in
the Menu painter to trigger these events.
121
Add user events and event scripts
122
Lesson 4 Modifying the Ancestor Window
123
Add user events and event scripts
What the scripts do The first line of the script for the ue_insert event
clears the dw_detail DataWindow control. The second line inserts a new
row after the last row in the DataWindow (the argument zero specifies the
last row). The third line positions the cursor in the dw_detail control.
The ue_insert and ue_delete events operate on the DataWindow buffer, not
on the database. When these events are triggered, a row is not inserted or
deleted from the database unless the Update function is also called (the
ue_update event calls this function). If the Update function returns the
integer 1, changes made to the buffer are committed to the database. If it
returns a different integer, changes to the buffer are rolled back.
In the script for the ue_delete event, the argument zero in the DeleteRow
function specifies that the current row in the dw_detail control will be
deleted.
124
Lesson 4 Modifying the Ancestor Window
The scripts you just typed have no effect on the dw_master DataWindow
control. But now that you have a script for the ue_retrieve event, you only need
trigger this event to retrieve data into the dw_master DataWindow.
You will trigger the ue_retrieve event from the sheet window Open event. This
will retrieve data into the dw_master DataWindow as soon as the window (or
one of its descendent windows) opens. Then you will add a script for the
RowFocusChanged event of dw_master to retrieve data into the dw_detail
DataWindow. The RowFocusChanged event is triggered each time the focus is
changed inside the dw_master DataWindow.
Here’s how the script will work for the w_master_detail_ancestor window and
its descendants when you’re done:
• When a sheet window first opens, a list (of all customers or products) will
display in the top DataWindow control. Detail information for the first
item in the list will display in the bottom DataWindow control.
• When a user moves through the list in the top DataWindow control using
the UP ARROW and DOWN ARROW keys or by clicking in a row, the details
for the current row will display in the bottom DataWindow control.
1 Select open from the second dropdown listbox in the Script view for
w_master_detail_ancestor.
The Open event calls the ue_postopen event and posts it to the end of the
window’s message queue. You will modify the ue_postopen event later.
125
Add scripts to retrieve data for the DataWindow controls
2 Type these new lines in the script area below the call to the
ue_postopen event:
dw_master.settransobject ( sqlca )
dw_detail.settransobject ( sqlca )
this.EVENT ue_retrieve()
The first two lines tell the dw_master and dw_detail DataWindows to look
in the SQLCA Transaction object for the values of the database variables.
The third line triggers the ue_retrieve event. The pronoun This refers to the
current object. In this example, the w_master_detail_ancestor window is
the current object.
4 Type this line in the script area for the RowFocusChanged event:
long ll_itemnum
This line declares the local variable ll_itemnum, which has the long data
type.
5 Type this line below the variable declaration line you just typed:
ll_itemnum = this.object.data[currentrow, 1]
This line uses a DataWindow data expression to obtain the item number in
column 1 of the currently selected row of dw_master. It stores the number
in the variable ll_itemnum.
126
Lesson 4 Modifying the Ancestor Window
6 Type these lines below the data expression line you just typed:
IF dw_detail.Retrieve(ll_itemnum) = -1 THEN
MessageBox("Retrieve","Retrieve error-detail")
END IF
This group of lines sends a retrieval request to the dw_detail DataWindow
along with the argument the DataWindow expects (an ID number stored in
the ll_itemnum variable). The IF statement that encloses the Retrieve
function checks for successful completion. If the retrieval operation fails,
it displays an error message box.
127
Rebuild library objects
It’s a good idea to rebuild all your objects after modifying an ancestor object.
You will do this now from the Library painter. You can also use the Library
painter to open objects in other PowerBuilder painters, to copy objects from
one library to another, and to export the code for a PowerBuilder object to a
text file.
2 Expand the Tree view to display all the objects in the pbtutor.pbl
library.
Drag the PBTUTOR application object from the Tree view to the List
view.
128
Lesson 4 Modifying the Ancestor Window
In the List view you can see the comments that you save for any
PowerBuilder objects.
129
Rebuild library objects
130
LE S S O N 5 Setting Up the Menus
In this lesson you will set up the menus for the application. You will:
• Modify the frame menu
• Create a new sheet menu
• Add menu scripts to trigger user events
• Attach the new menu and run the application
Menus are separate objects that you create using the Menu painter. After
you create a menu, you can attach it to as many windows as you want. You
can create menus at any time during the application development process.
131
Modify the frame menu
132
Lesson 5 Setting Up the Menus
5 Make sure that &Report appears in the Text box in the Properties view.
Click the Toolbar tab in the Properties view.
The toolbar item text is New, Open New Sheet. There is no selection in the
ToolbarItemName box, so no toolbar button will appear at runtime for the
Report menu item. You do not add a toolbar button here, because you will
use the Report menu item to access submenu items rather than as a
command to open a new sheet.
6 Click the Open menu item under the File menu in the WYSIWYG view.
Click the General tab in the Properties view.
Clear the Visible checkbox on the General page of the Properties view.
Clear the Enabled checkbox on the General page of the Properties
view.
You hide this item in all runtime menus. When you clear the Visible
property, the WYSIWYG view displays the menu item with a dithered
appearance. It will not be visible at runtime.
133
Modify the frame menu
134
Lesson 5 Setting Up the Menus
Now you will create a new menu that will display whenever the user opens an
MDI sheet to look at customer or product information. The menu you create is
a descendant of the m_pbtutor_sheet menu that was generated by the Template
Application wizard.
The m_pbtutor_sheet menu inherits in turn from m_pbtutor_frame, but has
some additional menu items enabled. In the menu you create, you will add
menu items that are not present in the ancestor menus.
In this exercice you will:
• Inherit and save a new menu
• Add items to the new menu
• Add a new toolbar for the new menu items
135
Create a new sheet menu
5 Click OK.
This names the menu. The prefix m_ is standard for menus.
The name you just assigned to the new menu displays in the title bar of the
Menu painter workspace.
136
Lesson 5 Setting Up the Menus
1 Click the Edit menu in the WYSIWYG view for the new menu.
The list of Edit menu items appears just as they would in a runtime
application. All items of the Edit menu are visible but disabled (they
appear gray—but not dithered—in the WYSIWYG view).
4 Clear the Enabled checkbox in the Properties view for the new
separator line.
137
Create a new sheet menu
You add Edit menu items for updating and deleting database records. Even
though it is not enabled, the Undo item already uses the letter U as an
accelerator key. So you should not use the same accelerator key for the
Update menu item. Instead, you use the letter A for this purpose.
138
Lesson 5 Setting Up the Menus
1 Click the new Insert menu item in the WYSIWYG view Edit menu.
Make sure it is also selected in the Properties view.
4 Click the new Update menu item in the WYSIWYG view Edit menu.
Make sure it is also selected in the Properties view.
5 Click the Toolbar tab if the Toolbar page is not already open.
Type Update in the ToolbarItemText box.
Type or select Update! in the ToolbarItemName dropdown listbox.
This defines a toolbar button for the Update menu item that uses the stock
picture called Update!. The button text is Update.
7 Click the new Delete menu item in the WYSIWYG view Edit menu.
Make sure it is also selected in the Properties view.
139
Create a new sheet menu
8 Click the Toolbar tab if the Toolbar page is not already open.
Type Delete in the ToolbarItemText box.
Type or select DeleteRow! in the ToolbarItemName dropdown listbox.
This defines a toolbar button for the Delete menu item that uses the stock
picture called DeleteRow!. The button text is Delete.
140
Lesson 5 Setting Up the Menus
Now you will add scripts to trigger user events from the sheet window menu
bar. You added these user events in Lesson 4, "Modifying the Ancestor
Window". The Menu painter should still be open for the m_my_sheet menu. If
it is not, you can open it using the Open button in the PowerBar.
3 Repeat steps 1 and 2 for the following menu items and scripts:
Menu name Script
m_edit.m_update w_master_detail_ancestor lw_activesheet
lw_activesheet=w_pbtutor_frame.GetActiveSheet()
lw_activesheet.EVENT ue_update()
m_edit.m_delete w_master_detail_ancestor lw_activesheet
lw_activesheet = w_pbtutor_frame.GetActiveSheet()
lw_activesheet.EVENT ue_delete()
141
Add menu scripts to trigger user events
142
Lesson 5 Setting Up the Menus
Now you will attach the new sheet menu and run the application again.
5 Click in the line that declares the data type for lm_menu.
This is the second line below the opening comments in the event script.
The data type declaration is currently:
m_pbtutor_frame lm_menu
143
Attach the new menu and run the application
144
Lesson 5 Setting Up the Menus
145
Attach the new menu and run the application
146
LE S S O N 6 Building DataWindow Objects
The DataWindow object is one of the most powerful and useful features
of PowerBuilder. A DataWindow object can connect to a database,
retrieve rows, display the rows in various presentation styles, and update
the database.
In this lesson you will:
• Create and preview a new DataWindow object
• Make cosmetic changes to the first DataWindow object
• Create a second DataWindow object
• Make cosmetic changes to the second DataWindow object
147
About this lesson
Now you will create a new DataWindow object and display it in the
DataWindow painter. Like other painters, the DataWindow painter has an
assortment of views that you can open simultaneously.
In the Preview view of the DataWindow painter, you will be able to see how
the object will look in an application at runtime, complete with table data.
148
Lesson 6 Building DataWindow Objects
5 Click id, fname, and lname in the Columns listbox in the order listed.
Scroll down the list and click company_name.
PowerBuilder displays the selected columns in a grid at the bottom of the
Quick Select dialog box.
You can use the grid area at the bottom of the dialog box to specify sort
criteria (for the SQL ORDER BY clause) and selection criteria (for the
SQL WHERE clause). Now you will specify sort criteria only. You will
sort on the id column in ascending order.
6 In the grid area of the Quick Select dialog box, click in the cell next to
Sort and below Id.
A dropdown listbox displays.
149
Create and preview a new DataWindow object
8 Click OK.
The DataWindow wizard asks you to select the colors and borders for the
new DataWindow object. By default, there are no borders for text or for
columns.
9 Click Next.
You accept the border and color defaults. The DataWindow wizard
summarizes your selections.
10 Click Finish.
PowerBuilder creates the new DataWindow object and opens the
DataWindow painter.
In the Design view, PowerBuilder displays a Heading band with default
headings and a Detail band with the columns you selected:
150
Lesson 6 Building DataWindow Objects
151
Save the DataWindow object
Now you will name the DataWindow object and save it. You will save it to the
pbtutor.pbl library.
4 Click OK.
PowerBuilder saves the DataWindow object and closes the Save
DataWindow dialog box.
152
Lesson 6 Building DataWindow Objects
Now you can make cosmetic changes to the DataWindow. You will reposition
the columns and column headings to make room for the hand pointer, which
displays to the left of the currently selected row. You will also move some of
the columns to make them line up with their headings.
You will make these changes in the Design view. You can keep the Preview
view open at the same time to see how the changes you make will affect the
appearance of the DataWindow at runtime.
153
Make cosmetic changes to the first DataWindow object
8 Click Yes.
PowerBuilder saves the DataWindow object and closes the DataWindow
painter.
154
Lesson 6 Building DataWindow Objects
When you built the first DataWindow object, you used Quick Select to specify
the table and columns. This let you retrieve all the customers without having to
use the Select painter.
But to build the second DataWindow object, you will use the Select painter.
You need to define a retrieval argument and WHERE criteria so you can pass
an argument to the DataWindow object during execution. In this case, you will
be passing the customer ID.
Now you will:
• Select the data source and style
• Select the table and columns
• Define a retrieval argument
• Specify a WHERE clause
• View the DataWindow in the DataWindow painter
• Save the DataWindow object
155
Create a second DataWindow object
156
Lesson 6 Building DataWindow Objects
Alternative method
If you double-click the customer table instead of selecting it and clicking
Open, the Select Tables dialog box remains open. In this case, you must
click Cancel to continue.
2 Right-click the header area of the Customer table in the Table Layout
view.
Select Select All from the popup menu.
The column names appear in the Selection List area above the table in the
Table Layout view.
The column order in the Selection List reflects the order in which columns
are selected. Since you selected all the columns at once, the order
displayed is the original order of the columns in the database. You will
change the column presentation order later.
157
Create a second DataWindow object
You can also see the order of selection in the Syntax view. In the default
view layout scheme, you can display the Syntax view by clicking the
Syntax tab at the bottom of a stack of tabbed panes. The Syntax view
displays the generated Select statement.
158
Lesson 6 Building DataWindow Objects
3 Click OK.
The retrieval argument is defined.
159
Create a second DataWindow object
5 Select Arguments.
The arguments dialog box displays.
The arguments dialog box contains the retrieval argument you specified
earlier (cust_id). The colon before cust_id means it is a PowerBuilder
variable that can be used as an argument in a SQL statement.
160
Lesson 6 Building DataWindow Objects
6 Select :cust_id.
Click the Paste button.
The Where tab displays with the retrieval argument.
161
Create a second DataWindow object
3 Click Finish.
Because you selected the Retrieve On Preview checkbox and because the
Preview view is part of the default layout scheme for the DataWindow
painter, the Specify Retrieval Arguments dialog box appears.
This dialog box prompts you for an argument value. When you put this
DataWindow object into the tutorial application, you will write a script
that passes the required argument to the DataWindow object
automatically.
162
Lesson 6 Building DataWindow Objects
163
Create a second DataWindow object
164
Lesson 6 Building DataWindow Objects
4 Click OK.
You return to the DataWindow painter.
165
Make cosmetic changes to the second DataWindow object
166
Lesson 6 Building DataWindow Objects
2 Keep the CTRL key pressed and click the following column labels and
column controls:
Label Column
City: city
State: state
Zip Code: zip
4 Use the CTRL+click technique to move the following label and column
controls to the location indicated:
If necessary, scroll down until you can see all the columns in the
DataWindow.
167
Make cosmetic changes to the second DataWindow object
The DataWindow should now look like this in the Design view:
168
Lesson 6 Building DataWindow Objects
2 While the Zip Code: label is still selected, use the CTRL+click technique
to select the Address:, City:, and State: labels.
5 Move the zip column so that it is right next to the Zip Code: label.
Align the address, city, and state columns with the zip column, just as
you aligned the column labels.
169
Make cosmetic changes to the second DataWindow object
170
LE S S O N 7 Attaching the DataWindow
Objects
After you create and save a DataWindow object, you can use it in a
window. You have already created the d_custlist and the d_customer
DataWindow objects. Now you associate each of these DataWindow
objects with a DataWindow control in the w_customers window.
In this lesson you will:
• Attach a DataWindow object to the master DataWindow control
• Attach the DataWindow object to the detail DataWindow control
• Run the application
• Attach DataWindow objects to the Product window
• Run the completed application
171
Attach a DataWindow object to the master DataWindow control
Now you will attach the DataWindow object to a DataWindow control in the
w_customers window.
172
Lesson 7 Attaching the DataWindow Objects
The Layout view now shows the d_custlist DataWindow headings inside
the dw_master control. But you do not see any data yet. The DataWindow
will not execute its SELECT statement until you run the application.
173
Attach the DataWindow object to the detail DataWindow control
Now you will attach a DataWindow object to the detail DataWindow control.
The Window painter should still be open for the w_customers window.
2 Make the dw_detail control larger so you can see all of the columns
you added to the DataWindow object.
If you need to, you can also enlarge the window to make more room. If you
make the dw_detail control wider, you may also want to make the
dw_master control the same width.
174
Lesson 7 Attaching the DataWindow Objects
Now you will run the application again to test the insert, update, and delete
capabilities of the second DataWindow.
2 Click Yes.
The application begins running, and the logon window displays.
175
Run the application
The top DataWindow control (dw_master) shows all of the rows retrieved
from the Customer table. The hand pointer shows which row is selected.
The bottom DataWindow control (dw_detail) shows further information
about the selected customer.
176
Lesson 7 Attaching the DataWindow Objects
177
Run the application
178
Lesson 7 Attaching the DataWindow Objects
Now you will add two DataWindow objects to the w_products window. The
DataWindow objects you will use are provided for you in the tutor_pb.pbl
library.
179
Attach DataWindow objects to the Product window
180
Lesson 7 Attaching the DataWindow Objects
Now you will run the application again to test the Product window.
At this point the Product window should have all of the capabilities of the
Customer window. Like the Customer window, the Product window functions
as a master/detail window, providing support for retrieval, insert, update, and
delete operations against the database.
2 Click Yes.
The application begins running, and the logon window displays.
181
Run the completed application
182
Lesson 7 Attaching the DataWindow Objects
183
Run the completed application
184
LE S S O N 8 Running the Debugger
Sometimes your application doesn’t behave the way you think it will.
Perhaps a variable is not being assigned the value you expect, or a script
doesn’t do what you want it to. In these situations, you can closely
examine your application by running it in debug mode.
In debug mode, you can set breakpoints (stops) in scripts and functions,
step through the code line by line, and display the contents of variables to
locate logic errors and mistakes that will result in errors during execution.
When you run your application in debug mode, PowerBuilder suspends
execution just before it hits a line containing a breakpoint. You can then
look at and change the values of variables.
In this lesson you will:
• Add breakpoints in application scripts
• Run in debug mode
• Set a watch and a conditional breakpoint
185
Add breakpoints in application scripts
Now you will open the Debugger and add breakpoints to examine the behavior
of the logon and Customer windows. When PowerBuilder runs the application
in debug mode, it stops just before executing a line containing a breakpoint.
When you insert breakpoints in a script, you should select lines that contain
executable statements. If you try to set a breakpoint in variable-declaration
lines, comment lines, or blank lines, PowerBuilder sets the breakpoint at the
next executable line.
186
Lesson 8 Running the Debugger
The source code for the application Open event displays in the Source
view at top left. If it does not display, expand the Application node in the
Source Browser view tree view and double-click the Open event under the
PBTUTOR application.
4 Double-click the Clicked event for the cb_ok button in the Source
Browser view.
The code for the Clicked event displays in the Source view.
187
Add breakpoints in application scripts
188
Lesson 8 Running the Debugger
You should see the breakpoints you set in the Breakpoints view. To
complete this lesson, you need to have these breakpoints set correctly.
189
Run in debug mode
Now you will run the application in debug mode. You will step through the
code line by line.
190
Lesson 8 Running the Debugger
5 Use Step In or Step Over to step through the code until you reach this
statement in the script for the frame window Open event:
open(w_welcome)
When PowerBuilder finishes executing this statement, the logon window
will display and the Debug window will be minimized.
The Open event for the frame window also has a posted call to the
ue_postopen function (that you stepped through without examining). This
in turn calls functions of the sheet manager. These functions will be
processed at the end of the script for the Open event (after the logon
window displays).
191
Run in debug mode
6 Click Step Over until the logon window displays and the Debugger is
minimized.
Type dba in the User ID box of the logon window.
Type sql in the Password box and click OK.
You return to the Debug window. The yellow arrow in the Source view
points to the next executable statement, the CREATE statement for the
connection service object. This is the first executable line in the script for
the Clicked event of the cb_ok command button.
192
Lesson 8 Running the Debugger
The values were assigned during execution of the Constructor event of the
connection service object after the of_GetConnectionInfo function
returned information from the INI file. But because you commented out
the lines in the code for the UserID, DBPass, and DBParm properties,
these values were not retrieved.
193
Run in debug mode
194
Lesson 8 Running the Debugger
Next you will set a watch on a variable whose value changes when the user
selects a row in the Customer window. Then you will change one of the simple
breakpoints you have set into a conditional breakpoint that is triggered only
when a variable has a specific value.
195
Set a watch and a conditional breakpoint
5 Type the following line in the Condition textbox and click OK:
ll_itemnum = 107
196
LE S S O N 9 Preparing the Application for
Deployment
In this lesson you will create an executable version of the application for
distribution to users. Users can run this executable version of the
application just as they can any other application.
You will:
• Create the Project object
• Create the executable file
• Create an icon
• Test the executable file
197
Create the Project object
Now you will create the PBTUTOR Project object. You will then be able to use
the Project object to create the executable file for the application.
About machine code If you are running PowerBuilder Enterprise, you can
choose between Pcode (pseudocode) and machine code as the compile method
for your project executable file.
When you deploy an application to users, you may want to take advantage of
the execution speed of machine code. While you are developing the
application, you will usually use Pcode because it is faster to generate.
About dynamic libraries You can also create dynamic libraries for your
application. Dynamic libraries can be used to store the objects in the
application. By using dynamic libraries, you can break the application into
smaller units that are easier to manage and also reduce the size of the
executable file.
For small applications like the one you’re working on now, you do not need to
use dynamic libraries.
198
Lesson 9 Preparing the Application for Deployment
3 Click Next.
The Specify Destination Library page displays.
You arrive at the last wizard page. It summarizes all your wizard
selections.
199
Create the executable file
Now you will create the executable file for your application. The executable
file you generate will contain definitions for all the objects in the application.
For the tutorial application, this includes the bitmap file used in the logon
window, since you did not include a separate resource file with your project.
200
Lesson 9 Preparing the Application for Deployment
201
Create an icon
Create an icon
Where you are
Create the Project object
Create the executable file
> Create an icon
Test the executable file
Now you will create an icon for the executable file. The icon will serve as a
shortcut to open the executable file. You can add the icon directly to the
desktop or to the program group of your choosing.
1 Minimize PowerBuilder.
PowerBuilder is minimized to an icon on the taskbar.
3 Enter the full path to the EXE file in the Command Line box.
For example, if you accepted the default installation folder, type:
C:\Program Files\Sybase\PowerBuilder 7.0\Tutorial\
pbtutor.exe
You can also click the Browse button and locate pbtutor.exe.
4 Click Next.
5 Type SportsWear, Inc. in the Select A Name For The Shortcut box.
6 Click Finish.
An icon and description display on the desktop.
Now you must modify a property of the shortcut so that you can run the
application. You can also change the icon.
202
Lesson 9 Preparing the Application for Deployment
203
Test the executable file
1 Make sure the pbtutor.ini file is in the same directory as the pbtutor.exe
executable file.
4 When you’ve finished testing the application, select File>Exit from the
menu bar.
204
Lesson 9 Preparing the Application for Deployment
What to do next
Congratulations. You have completed the tutorial. Now you know the basics
of application development with PowerBuilder.
For simple applications like the tutorial, you will also want to edit the About
window (w_pbtutor_about for the tutorial) and to provide a link to an
application help file. You can call application Help topics with the ShowHelp
PowerScript function or by using a WinHelp API external function.
PowerBuilder books to For information on calling Windows Help, see the chapter "Providing Online
consult Help for an Application" in Applications Techniques.
For information about using PowerBuilder with other Enterprise Application
Studio tools, see Building Internet And Enterprise Applications.
The Preface to this book includes a guide to the PowerBuilder documentation.
To further your education, you should continue with these books: User’s Guide,
Building Internet And Enterprise Applications, Application Techniques, and
DataWindow Programmer’s Guide.
Installing the Online All the PowerBuilder books are available in the Online Books and on the
Books Sybase website at www.sybase.com.
For information on how to install the Online Books, see the Installation Guide.
205
What to do next
206
Glossary
accelerator key In PowerBuilder and InfoMaker, a key used in combination with another
key that allows you to select a control or menu item. On Windows, these
keys are called mnemonic or access keys and are used in combination with
ALT. On Motif, these keys are called mnemonics and are used in
combination with the Meta key.
See also shortcut key.
access key See accelerator key.
ActiveX A set of technologies based on COM that enables software components to
interact. See also COM.
ancestor An object that defines basic functionality for a class of objects from which
descendent objects inherit.
any A data type that temporarily takes the data type of the value currently
assigned to it.
applet Code that can be transmitted over a network and then executed on a
recipient’s computer. Typically, these programs are embedded in HTML
pages.
application framework A collection of interrelated base classes (ancestor objects) from which you
inherit the objects you need for an application.
Application object The entry point into an application. The Application object is a discrete
object that is saved in a PowerBuilder library—just like a window, menu,
function, or DataWindow object. The Application object defines
application-level behavior, such as which fonts are used by default for text
and what processing should occur when the application begins and ends.
207
Glossary
application server A gateway program that executes logic on a server machine before
returning HTML to a web browser. An application server dynamically
generates HTML pages.
asynchronous request In a distributed application, a function call made by a client that instructs
the server to perform processing at a later time. When a client issues an
asynchronous function call, it can continue to do other work while the
server handles the request.
automation server A COM component that implements the IDispatch interface. An
automation server (formerly OLE automation server) can be accessed and
programmed from a client application using automation syntax.
base class object The object at the top of a hierarchy (tree structure) of ancestor objects and
descendent objects. The base class object typically performs generalized
processing, and each descendant modifies the inherited processing as
needed. The PowerObject is the base class object for all PowerBuilder
objects.
blob A data type that is used to store an unbounded amount of data (for
example, generic binary, image, or large text).
boolean A data type that is either TRUE or FALSE.
breakpoint A point in your application code where you want to break (interrupt)
normal execution while you are debugging. For example, you might set a
breakpoint at a statement that calls a function, so that the application
temporarily stops executing when that function is called. A breakpoint can
also be called a stop.
cascading menu Another menu that appears when an item on a dropdown menu is selected.
A cascading menu can be nested, so that a menu selection on the cascading
menu displays yet another cascading menu.
cascading style sheet A definition of how HTML styles appear on HTML pages that link to the
style sheet. The specification for cascading style sheets (defined by the
World Wide Web Consortium) defines how styles defined at different
levels—in a global style sheet, in an embedded style, and in an inline
style—are interpreted and displayed. Cascading style sheets stored in
separate files have the extension CSS.
char A standard data type that is a single letter, number, or symbol. Can also be
spelled out as character.
child DataWindow See DataWindow child.
208
Glossary
child class A class contained within a parent class. Also called a nested class. See
also class.
child window A window that is dependent on a main (parent) window and can exist only
within the parent window. The initial position of the child is relative to the
parent and not to the workspace. You can move the child within the parent,
but not outside the parent.
When you move part of the child beyond the parent, PowerBuilder clips
the window so that only the portion within the parent is visible. When you
move the parent window, the child moves with the parent and maintains
the same position relative to the parent.
When you minimize a child window, the icon displays within the parent.
class A definition for a particular type of object. The definition includes the
properties, events, functions, structures, and scripts that make up the
object. All instances of a given class are identical in form and behavior,
but their variables and properties contain different data.
class hierarchy The relationship among a set of classes, usually represented in a tree
structure. A class hierarchy has a single top node (the base class) and can
have an unlimited number of levels.
class library A reusable and extensible collection of classes. In PowerBuilder, classes
are called objects (for example, window objects, user objects, and Menu
objects).
class user object An object you build in the User Object painter that can be used to perform
processing that has no visual component. To use a class user object, you
create an instance of the object in a script and call its functions. You
typically use class objects to define business rules and other processing
that acts as a unit. There are two kinds of class user object: standard and
custom.
code table A table of display values and corresponding data values used in an edit
style. The display values are those the user sees. The data values are those
that are stored in the database.
COM Component Object Model. A software architecture that defines a common
way to access software services and provides the foundation for OLE and
ActiveX technologies.
component In Jaguar or MTS, a reusable module that contains business logic that
executes on a middle-tier server. You can deploy custom class user objects
as Jaguar or MTS components.
209
Glossary
composite report A report that consists entirely of one or more nested reports. A composite
report serves as a container for other reports and has no data source of its
own.
computed field A field in a DataWindow, report, or form consisting of an expression that
yields a value calculated on the client at execution time. The expression
can use columns, constants, functions, and operators. For example, a
DataWindow that includes the Salary and Benefits columns could also
include a computed field using the expression salary + benefits to calculate
the total remuneration for each employee.
Connection object The object you create to establish a connection from a client to a middle-
tier server in a distributed application. The Connection object can be used
to connect to Jaguar or to a distributed PowerBuilder server.
Context feature A set of PowerBuilder objects that allow applications to access certain
host (non-PowerBuilder) services.
control A graphical object that allows users to interact with your application or
that you use to enhance the design of a window, visual user object, or
DataWindow object. In windows and visual user objects, controls can also
have events that can trigger scripts to perform actions or call functions.
cursor type The representation of the cursor on the screen.
custom class user object A class user object you design that encapsulates properties and functions
but is not visible to the user. You define custom class user objects to create
units of processing that have no visual component. You typically use
custom class user objects to define processing that acts as a unit (such as
business rules). A custom class user object is derived from the
PowerBuilder NonVisualObject system object.
custom visual user A user object you design that has several controls that function as a unit.
object (You can think of a custom visual user object as a window that is a single
unit and is used as a control.) For example, if you frequently group
controls together in a window and always use the controls to perform the
same processing, you can build a custom visual user object that contains
these controls and their scripts.
database interface A connection to your data in PowerBuilder or InfoMaker. You can access
data in two ways: through a standard database interface (such as ODBC or
JDBC) or through one of the PowerBuilder native database interfaces.
210
Glossary
211
Glossary
212
Glossary
213
Glossary
dot notation The syntax for identifying objects and controls in order to call their
functions and change or obtain information about their properties. The
syntax format is:
object.function
control.property
The syntax can be more complex, including parent objects and properties
of other properties.
double A standard data type that is a signed floating-point number with 15 digits
of precision in the range 2.2E-308 to 1.7E+308.
drawing control A control that has no events and therefore no scripts. There are four
drawing controls: Line, Oval, Rectangle, and RoundRectangle.
drop area The area within a draggable object in which a control in drag mode can be
dropped. When you or the user drags any portion of a draggable control
into another draggable control, the control is within the drop area.
dropdown menu A list of commands or options under a menu item in the menu bar that
appears when the user clicks the menu item.
drop lines The lines on a graph that connect the data points back to the axis.
dynamic linking The type of linking that occurs when an application uses functions from a
dynamic link library and the functions are not included in the executable
module. Instead, the executable module contains references to these
functions that are resolved at execution time.
dynamic link library See DLL.
dynamic lookup Instructs PowerBuilder to wait until execution time to find the specified
function or event. Allows you to call functions and events in descendants
that don’t exist in the ancestor.
edit mask A format or control used to validate user-entered data and control the
display of that data.
edit style A style that specifies how column data is presented in a DataWindow
object, report, or form. Named, reusable edit styles are stored in the
extended attribute system tables. An edit style can be used by any column
of the appropriate data type in the database. You can also specify edit
styles in the DataWindow object, but then they aren’t reusable.
214
Glossary
215
Glossary
external visual user An object you build that contains controls from objects in the underlying
object windowing system (external objects) that were created outside
PowerBuilder.
floating toolbar A toolbar that displays on top of the painter workspace and any other
windows opened in the painter. It floats above the window and is not
within a toolbar dock.
focus Identifies the control, column, or graphic object that currently can receive
input from the keyboard.
When a DropDownListBox or ListBox has focus, a dotted rectangle
typically surrounds the first item in the box. When a column of a
DataWindow object has focus, a dotted rectangle typically surrounds the
first row of the column.
foreign key A column or set of columns that contains primary key values from another
table. Each item in the column or columns must correspond to an item in
the column of the other table.
form An electronic document for entering and modifying data in a database.
The form can display existing data from the database; you can change or
delete the existing data. The form can be blank; you can add new data
using a blank form.
function In PowerBuilder, a routine that performs specific processing. You
commonly use functions to act on the objects and controls in your
application. PowerBuilder provides a rich assortment of functions (built-
in functions). You can also define your own functions (user-defined
functions). In object-oriented programming, functions are called methods.
garbage collection In PowerBuilder, the process of marking objects that are no longer
accessible, clearing those objects from memory, and reclaiming memory
for objects that the application is actively using.
global function A user-defined function that is not associated with any object in the
application and is always accessible anywhere in the application. Global
functions correspond to the PowerBuilder built-in functions that are not
associated with an object, such as the mathematical and string-handling
functions.
global structure A structure not associated with any object in your application. You can
declare an instance of a global structure and reference the instance
anywhere in your application.
216
Glossary
inheritance The feature that enables you to build windows, user objects, and menus
that are derived from existing objects. Using inheritance has a number of
advantages:
• When you change an ancestor object, the changes are reflected in all
the descendants.
• The descendant inherits the ancestor’s scripts.
• You get consistency in the code and objects in your applications.
inheritance hierarchy An object and all its ancestors.
INI file On Windows, an initialization file that stores variables that define your
preferences. See also PB.INI file and IM.INI file.
217
Glossary
instance An object, as opposed to the definition of the object (called the object
class). An object instance exists in memory and has values assigned to its
properties and variables. Object instances exist only when you run an
application.
instance variable A variable that belongs to an object and is associated with an instance of
that object (you can think of it as a property of the object). Instance
variables have access keywords that determine whether scripts of other
objects can access them. Instance variables can belong to the application,
a window, a user object, or a menu.
instantiate In object-oriented programming, to create an object (an instance) of a
specific class.
integer A standard data type that is a 16-bit signed integer, in the range -32768 to
+32767. The abbreviated form for integer is int.
keyword A word used in PowerScript syntax that is not a variable. In most
situations, keywords are reserved words.
library Where PowerBuilder and InfoMaker store objects. A library is a PBL file
(it has the extension PBL in DOS). A library is a collection of compiled
object definitions (compiled binary representation) and source objects
(including scripts) stored in the same location. The name of the library
identifies the location. The PowerBuilder and InfoMaker painters and
wizards store the following objects in libraries: applications,
DataWindows, forms, functions, menus, pipelines, projects, proxies,
queries, reports, structures, user objects, windows. See PBL file.
library search path A list of the libraries that contain entries that can be used by scripts in the
application. PowerBuilder uses the search path to find referenced objects
during execution. When a new object is referenced, PowerBuilder looks
through the libraries in the order in which they are specified in the library
search path until it finds the object.
local variable A temporary variable that is accessible only in the script in which you
define it. When the script is finished, the variable ceases to exist.
long A standard data type that is a 32-bit signed integer in the range
-2,147,483,648 to +2,147,483,647.
machine code A platform-specific language that produces a fast executable. Compare to
pseudocode.
218
Glossary
main window A standalone window that can be independent of all other windows. You
use the main window as the anchor for your application. The first window
your application opens is a main window (unless you are building an MDI
application, in which case the first window is an MDI frame).
MAPI Message Application Program Interface. A set of Microsoft functions that
you can use to add messaging to your application (make your application
mail-enabled) on Windows. The PowerBuilder mail functions use MAPI.
MASP Method As Stored Procedure. A technique for calling a method on a
middle-tier server as if it were a stored procedure in a database.
MDI application Multiple Document Interface application. An application in which users
work within a frame window that lets them perform activities on multiple
sheets of information. This is useful in applications where users require
the ability to do several different things at a time.
An MDI frame is a window with several parts: a menu bar, a client area,
sheets, and (usually) a toolbar plus a status area that can display
MicroHelp.
An MDI sheet is a window that can be opened in the client area of an MDI
frame. You can use any type of window except an MDI frame as an MDI
sheet.
Compare to SDI application.
menu bar A bar at the top of a window that displays the first level of menu items the
user can select in the window or application.
menu-level variable An instance or shared variable, SQL cursor, or SQL procedure belonging
to the menu. See scope.
method In object-oriented programming, a function or routine associated with an
object. There can be many methods in an object.
In PowerBuilder, methods encompass both functions and events.
MicroHelp A brief description of a menu item or toolbar icon that displays in the
status bar at the bottom of the window when you click the item or icon.
The MicroHelp displays as long as you press the mouse button.
MTS Microsoft Transaction Server. A component-based transaction processing
system that provides a model for developing, deploying, and
administering component-based applications.
nested class A child class.
219
Glossary
220
Glossary
OLE Object Linking and Embedding. Allows you to use other programs (server
applications) and their data in your Windows application. Their data
remains in the server application’s own format. When your application
includes an OLE object, it can invoke the server application to manipulate
the object. See also ActiveX and COM.
overloading A function name that has more than one definition. Each version of the
function has a different argument list, which is how they are distinguished.
See also overriding.
overriding A function in a descendent object that replaces a function of the same
name in its ancestor object. The two functions have the same argument
list. See also overloading.
painter In PowerBuilder and InfoMaker, an object editor used for building objects
or a tool used for managing your data and libraries. For example, you
build a window in the Window painter. There you define the properties of
the window and add controls, such as buttons and textboxes.
PainterBar The toolbar containing the icons associated with the current painter. The
icons in this toolbar depend on the painter, and you use them to initiate
actions and activities associated with the painter.
parent object The object that contains the current object. For example, a window is the
parent object of the controls it contains.
PBD PowerBuilder dynamic library. A library that is loaded when the
application executes. At that time, PowerBuilder looks for any PBDs you
specified in the executable. Any PBDs containing objects that will be
dynamically loaded during execution must be included in your
application’s path.
PB.INI file The PowerBuilder initialization file on Windows. The file containing the
preferences you have defined to customize PowerBuilder. The equivalent
on UNIX is .pb.ini. See also INI file.
PBL file PowerBuilder library file. Pronounced pibble. See also library.
PBR file PowerBuilder resource file. An ASCII file with the extension PBR. A
PBR file contains the name of each file in which a resource that is assigned
dynamically in scripts in the application is stored. These resources can
include bitmap, icon, and cursor files.
221
Glossary
222
Glossary
PowerBuilder window A PowerBuilder feature that lets you display a PowerBuilder child
plugin window on web pages viewed in a browser that supports Netscape
plugins. This window can contain all window controls and can open other
(popup or response) windows.
PowerObject The base class from which all PowerBuilder system objects are
descended.
PowerScript The PowerBuilder language. You use PowerScript in scripts and user-
defined functions to build PowerBuilder applications. PowerScript is a
high-level, object-oriented language designed for the PowerBuilder
environment. It contains commands (functions) for manipulating the
graphic objects in an application, performing calculations, processing
character strings, converting data from one data type to another, and other
processing.
PowerTip Text displayed whenever the pointer pauses over a toolbar button that tells
you what the button is for.
primary key A column or set of columns that uniquely identifies each row in a table.
For example, an Employee table could contain two employees with the
same first name and last name. To prevent confusion, an Employee table
usually has a column called Emp_id containing a unique ID number for
each employee. You define the Emp_id column as the primary key
column. Each row in the Employee table has one employee ID and
contains data for the one employee with that ID.
profile A report containing timing and other information about the execution of
an application. Several different profiles can be created using PowerScript
functions or the Profiler.
project object An object that lets you specify how the executable version of an
application is to be generated. It includes options for compiling code,
creating dynamic libraries, and bundling resources.
property A value that defines the characteristics of a PowerBuilder or InfoMaker
object or control, such as its size, position, color, or tab sequence.
proxy object A local representation of a remote object in a middle-tier server. To
communicate with a Jaguar CTS component or a user object running in a
distributed PowerBuilder server, a PowerBuilder client needs to have a
proxy available locally.
223
Glossary
224
Glossary
225
Glossary
shared variable A variable that belongs to an object definition and exists across all
instances of the object. Shared variables retain their value when an object
is closed and opened again. Shared variables are always private. They are
accessible only in scripts for the object and for controls associated with the
object. Shared variables can belong to the Application object, a window, a
user object, or a menu.
shortcut key A key or combination of keys that provides a quick way to perform certain
operations (such as CTRL+INS). On Windows, these keys are called
shortcut keys or accelerator keys. On Motif, they are called accelerator
keys. See also accelerator key.
SQL Structured Query Language. Pronounced sequel. A language used to
retrieve and manipulate data in a relational database. You can use SQL
commands interactively in PowerBuilder and InfoMaker to work with a
database. You can also embed SQL commands in PowerScript to
communicate with a database.
SQLCA SQL Communications Area. The default Transaction object in
PowerBuilder.
standard class user A user object that inherits its definition from one built-in, nonvisual
object PowerBuilder object, such as the Transaction object or Error object. You
modify the definition to make the object specific to your application. Once
you have defined the standard class user object, you can go to the
Application painter and specify that you want to use it instead of the
corresponding built-in system object in your application.
standard visual user An object you build starting from a standard PowerBuilder control. Such
object an object inherits its properties and events from the standard PowerBuilder
control; you modify it to perform processing specific to your application.
static linking The type of linking that occurs when the functions from a static library are
referenced by an application become part of the executable module.
static lookup Instructs PowerBuilder to find the specified function or event at compile
time.
string A standard data type that is characters enclosed in single (’) or double (")
quotation marks, including a string of 0 length (the empty string ""). The
maximum number of characters in a string is 60,000.
226
Glossary
structure A collection of one or more related variables of the same or different data
types grouped under one name. With a structure, you can refer to related
objects as a unit rather than individually. For example, you could define
the user’s ID, address, access level, and a picture (bitmap) of the user as a
structure called user_struct. In some languages (including Pascal and
COBOL), a structure is called a record.
style The appearance of a PowerBuilder window or control (such as its size,
position, color, or tab sequence). A window or control’s style is
determined by its properties.
StyleBar A toolbar for changing text fonts, font size, style (bold, italic, and
underline), and alignment (left, centered, and right).
style sheet See cascading style sheet.
synchronous request In a distributed application, a function call made by a client that instructs
the server to perform processing immediately. Synchronous requests
cause the client to wait until processing is completed.
system class A class defined by PowerBuilder. An object you define in a painter is a
descendant of a system class, even when you don’t explicitly choose to
use inheritance for the object you define.
table The organizing mechanism in a relational database. A table contains rows
and columns of data. Each row represents a single entry. Each column
represents a category of data.
tag value A text string you associate with a control or a DataWindow column. You
can use the tag for your own purposes in the application.
time A standard data type that is time in 24-hour format: hh:mm:ss.ffffff where:
hh is the hour (a number 00 to 23)
mm is the minutes (a number 00 to 59)
ss is the seconds (a number 00 to 59)
ffffff is the microseconds (a number 000000 to 999999)
The colons (:) and period (.) are required. Blanks are not allowed.
For example, 23:59:59.999999 is one microsecond before midnight.
PowerBuilder and InfoMaker use the 24-hour time format:
hh:mm:ss:ffffff (hours:minutes:seconds:microseconds)
227
Glossary
trace file A binary file containing monitoring information that is generated when
you run an application with profiling enabled. You use PowerScript
functions or the Profiler to create an execution profile of the application
from the data in the trace file.
Transaction object The communications area for a database connection that facilitates
communication between a script and the database. It stores status
information for recent database activity. The default Transaction object in
PowerBuilder is SQLCA (SQL Communications Area).
Transport object The object you create to receive a connection on a server in a distributed
application. The Transport object is instantiated on the server and contains
several properties, including the name of the connection driver being used
and the application name.
type promotion The automatic conversion of values to compatible, higher-ranking data
types. Type promotion occurs when expressions are evaluated.
UnsignedInteger A standard data type that is a 16-bit unsigned integer in the range 0 to
65535. The abbreviated form for UnsignedInteger is unsignedint or uint.
UnsignedLong A standard data type that is a 32-bit unsigned integer in the range 0 to
4,294,967,295. The abbreviated form for UnsignedLong is ulong.
user event An event that you define and trigger from other scripts.
user object An object you build in PowerBuilder to perform processing that you use
frequently in your applications. User objects are reusable, and you can use
them in windows and in other user objects the same way you use the
PowerBuilder controls. Types of user objects are:
Custom class user object
Custom visual user object
External visual user object
Standard class user object
Standard visual user object
validation rule An expression used to ensure that data entered into a column is valid for
the column. The database ensures that all data is the correct data type and
size for a column. You use a validation rule to ensure that the data meets
additional criteria. For example, you could use a validation rule to ensure
that data in the numeric column is equal to or greater than a specified
amount.
228
Glossary
visual user object A reusable control or set of controls with a certain behavior. For example,
a visual user object could consist of several buttons that function as a unit.
The buttons could have scripts associated with them that perform standard
processing. Once the object has been defined, you can use it as often as
you need.
window ActiveX A PowerBuilder feature that lets you display a PowerBuilder child
window on web pages viewed in a browser that supports ActiveX. This
window can contain all window controls and can open other (popup or
response) windows. The window ActiveX provides an interface to the
PowerBuilder application through a set of events and functions that you
access via JavaScript or VBScript.
window-level variable An instance or shared variable, SQL cursor, or SQL procedure belonging
to a window.
.WindU An initialization file required by PowerBuilder on UNIX platforms to
contain settings for Wind/U, a product from Bristol Technology used to
implement PowerBuilder in the UNIX Motif environment.
229
Index
231
Index
232
Index
G M
GetActiveSheet function 141 machine code 198
global manager
functions 13 connection service 90
structures 14 sheet window 75
variables 95 MDI applications 22
menu bars, description 12
menu items
adding scripts for 141
H defining 132
HALT statement 106 description 12
header band in DataWindow objects 148, 150 Menu painter, using 132
Help menus
context messages 70 about 12
Microhelp 138 adding scripts for 141
and toolbars 134, 139
creating 135
inheriting 135
I menu items 132
icons, application 50 saving 136
inheritance MicroHelp 138
and menus 135
and object-oriented programming 6
and user objects 112
and windows 111 O
initialization files object orientation 6
odbc.ini 80 object-level
pb.ini 86 functions 13
pbtutor.ini 95 structures 14
InsertRow function 124 Open event
application 39
frame window 75
sheet window 125
L
libraries
about 14
dynamic 198 P
rebuild objects in 128 PainterBar
search path for application 113 adding controls from 58
popup menus 47
using 17
painters 16
Parent (PowerScript pronoun) 100
Parent (pronoun) 101
PBL see PowerBuilder Library (PBL)
Pcode (pseudocode) 198
233
Index
234
Index
W
U WHERE clause 160
Update function 124 Window painter, deleting a control 60
user events windows
adding scripts for 121 about 10
defining 121 ancestor 111
triggering from menu scripts 141 CommandButton controls on 67
user objects creating 54
about 14 DataWindow controls on 112
using 112 deleting a control 60
opening in a script 74
Picture controls on 60
previewing 72
V response 54
variables saving 54
global 95 StaticText controls on 62
gnv_connect 95 tab order in 69
instance 95 wizards
lm_menu 143 Connection Object 90
naming conventions 96 DataWindow 148
vertical scrollbars 117 Project 198
view, types of Template Application 30
Design (DataWindow painter) 148
HTML Preview (DataWindow painter) 150
Layout 55
Object Details (Database painter) 88
Object Layout (Database painter) 88
Objects (Database painter) 86
Preview (DataWindow painter) 150
Properties 55
Script 70
Syntax (Select painter) 158
Table Layout (Select painter) 157
WYSIWYG (Menu painter) 132
views
docking 42
floating 42
manipulating 40
pinning 41
resetting default layout schemes 44
235