Constants
PeopleCode supports numeric, string, and Boolean constants, as well as user-defined constants. It also supports the constant Null, which indicates an object reference that does not refer to a valid object.
Note:
You can express Date, DateTime, and Time values by converting from String and Number constants using the Date, Date3, DateTime6, DateTimeValue, DateValue, Time3, TimePart, and the TimeValue functions. You can also format a DateTime value as text using FormatDateTime.
Numeric Constants
Numeric constants can be any decimal number. Some examples are:
-
7
-
0.8725
-
-172.0036
String Constants
String constants can be delimited by using either single (') or double (") quotation marks. If a quotation mark occurs as part of a string, the string can be surrounded by the other delimiter type. As an alternative, you can include the delimiter twice. Some examples are:
-
"This is a string constant."
-
'So is this.'
-
'She said, "This is a string constant."'
-
"She said, ""This is a string constant."""
Use the following code to include a literal quotation mark as part of your string:
&cDblQuote = '"'; /* singlequote doublequote singlequote */
The following also produces a string with two double quotation marks in it:
&cDblQuote = """"; /* dquote dquote dquote dquote */
You can also directly embed the doubled double quotation mark in strings, such as:
&sImage = Char(10) | '<IMG SRC="%IMAGE(' | &pImageName | ')"';
Strings must be contained on a single line. If you need to create a multi-line string, you must use concatenation to connect the lines to be a single sting. For example, one method to do this is:
&string = "Line 1" | Char(10) | "Line 2" | Char(10);
Boolean Constants
Boolean constants represent a truth value. The two possible values are True and False.
Null Constant
Null constants represent an object reference value that does not refer to a valid object. This means that calling a method on the object or trying to get or set a property of it fails. The Null constant is just the keyword Null.
User-Defined Constants
You can define constants at the start of a PeopleCode program. Then you can use the declared constant anywhere that the corresponding value would be allowed. Constants can be defined as numbers, strings, or Boolean values.
User-defined constants can only be declared as Local.
The following is an example of user-defined constant declarations:
Constant &Start_New_Instance = True;
Constant &Display_Mode = 0;
Constant &AddMode = "A":
Local Field &Start_Date;
. . .
MyFunction(&Start_New_Instance, &Display_Mode, &Add_Mode);