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 identifiers in PowerBuilder can be up to 255 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
The following table shows common prefixes for objects that you
create in PowerBuilder.
Prefix |
Description |
---|---|
w_ |
Window |
m_ |
Menu |
d_ |
DataWindow |
pipe_ |
Data Pipeline |
q_ |
Query |
n_ or n_standardobject_ |
Standard class user object, where standardobject |
n_ or n_cst |
Custom class user object |
u_ or u_standardobject_ |
Standard visual user object, where standardobject |
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. The following table lists the prefixes used to
indicate a variable’s scope. The following table lists the prefixes
for standard datatypes, such as integer or string.
The variable might also be a PowerBuilder object or control. The
following table 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.
Prefix |
Description |
---|---|
a |
Argument to an event or function |
g |
Global variable |
i |
Instance variable |
l |
Local variable |
s |
Shared variable |
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 |
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 |