Naming conventions

As you use PocketBuilder to develop your application, you create many different components for which you need to provide 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. This is critical when you are working in a team to enforce consistency and enable others to understand your code. This section provides tables of common naming conventions. PocketBuilder does not require you to use these conventions, but they are followed in many PocketBuilder books and examples.

All identifiers in PocketBuilder can be up to 40 characters long. You typically use the first few characters 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 3-9 shows common prefixes for objects that you create in PocketBuilder.

Table 3-9: Common prefixes for objects

Prefix

Description

w_

Window

m_

Menu

d_

DataWindow

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 3-10 lists the prefixes used to indicate a variable’s scope. Table 3-11 lists the prefixes for standard datatypes, such as integer or string.

The variable might also be a PocketBuilder object or control. Table 3-12 lists prefixes for some common PocketBuilder system objects. For controls, you can use the standard prefix that PocketBuilder 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 3-10: 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 3-11: 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 3-12: Prefixes for selected PocketBuilder 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