Naming conventions

As you use PowerBuilder to develop your application, you create many different components that require names. These components include objects such as windows and menus, controls that go into your windows, and variables for your event and function scripts.

You should devise a set of naming conventions and follow them throughout your project. When you are working in a team, this is critical to enforcing consistency and enabling others to understand your code. This section provides tables of common naming conventions. PowerBuilder does not require you to use these conventions, but they are followed in many PowerBuilder books and examples.

All indentifiers in PowerBuilder can be up to 40 characters long. The first few characters are typically used to specify a prefix that identifies the kind of object or variable, followed by an underscore character, followed by a string of characters that uniquely describes this particular object or variable.

Object naming conventions

Table 5-2 shows common prefixes for objects that you create in PowerBuilder.

Table 5-2: Common prefixes for objects

Prefix

Description

w_

Window

m_

Menu

d_

DataWindow

pipe_

Data Pipeline

q_

Query

n_ or n_standardobject_

Standard class user object, where standardobject represents the type of object; for example, n_trans

n_ or n_cst

Custom class user object

u_ or u_standardobject_

Standard visual user object, where standardobject represents the type of object; for example, u_cb

u_

Custom visual user object

f_

Global function

of_

Object-level function

s_

Global structure

str_

Object-level structure

ue_

User event

Variable naming conventions

The prefix for variables typically combines a letter that represents the scope of the variable and a letter or letters that represent its datatype. Table 5-3 lists the prefixes used to indicate a variable’s scope. Table 5-4 lists the prefixes for standard datatypes, such as integer or string.

The variable might also be a PowerBuilder object or control. Table 5-5 lists prefixes for some common PowerBuilder system objects. For controls, you can use the standard prefix that PowerBuilder uses when you add a control to a window or visual user object. To see these prefixes, open the Window painter, select Design>Options, and look at the Prefixes 1 and Prefixes 2 pages.

Table 5-3: Prefixes that indicate the scope of variables

Prefix

Description

a

Argument to an event or function

g

Global variable

i

Instance variable

l

Local variable

s

Shared variable

Table 5-4: Prefixes for standard datatypes

Prefix

Description

a

Any

blb

Blob

b

Boolean

ch

Character

d

Date

dtm

DateTime

dc

Decimal

dbl

Double

e

Enumerated

i

Integer

l

Long

r

Real

s

String

tm

Time

ui

UnsignedInteger

ul

UnsignedLong

Table 5-5: Prefixes for selected PowerBuilder system objects

Prefix

Description

ds

DataStore

dw

DataWindow

dwc

DataWindowChild

dwo

DWobject

env

Environment

err

Error

gr

Graph

inet

Inet

ir

InternetResult

lvi

ListViewItem

mfd

MailFileDescription

mm

MailMessage

mr

MailRecipient

ms

MailSession

msg

Message

nvo

NonVisualObject

tr

Transaction

tvi

TreeViewItem