Variables Overview

Provides a description of the types of variables that can be used in a PBL program.

Variables are locations in memory (and sometimes in a database) in which data can be stored. Each variable has a name, description, type, and value. Most variables only store data of one particular type. For example, if you define a variable to store a number, it would not normally be used to store a text string.

Because data types are commonly fixed, the compiler will check to ensure that you are using correct type for the values your code assigns to them. If a statement is meant to process integers, the compiler will detect when you inadvertently try to use it to process another datatype, such as a string.

Variable Naming

Valid PBL variable names must start with an alphabetic character or an underscore character followed by zero or more alphanumeric characters. The following are valid variable names:
participantName = "John Doe"
iso9001 = "..."
_ugly_var_name_ = 1
The following PBL variable names are not valid:
//Variables cannot begin with numbers
4ever = true

//display is a reserved word
display = true

Reserved Words

Certain names cannot be used as variable names in a PBL program. These are called reserved words. Reserved words are dependant on the current language skin. To use a reserved word as a variable name, you must escape it with the '@' character.
// This is legal because the reserved word
// has been escaped
@display = true

// References to it must also include
// the escape character
display = @display

In this example, the '@' sign is not part of the variable name. It is just a way to tell the compiler that you are not referring to the reserved word but that you want to refer (in this case) to the variable.

Variable Declaration

The exact variable declaration syntax within a PBL program is dependant on the skin you are using, The following examples demonstrate how to declare variables using different programming styles:

Using the PBL Style:
name as String
temp as Any
Using the Visual Basic style:
Dim name as String
Dim temp as Any
Using the Java style:
String name;
Any temp;

Variable Scope

The term scope is used to denote the applicability or availability of a variable within your project. For example, variables defined within the code of a method have a local scope and are therefore called local variables. This means that they can only be seen from within the method where they are declared.

ALBPM variables may have one of the following scopes:
  • Local
  • Instance
  • Project