Defining Strings (DPL Code)

You can define a variable called a string and initialize it with a sequence of characters. Using strings makes it easy to use the same sequence of characters several times in a DPL program. The following statement defines a string in DPL.

string Report_Title = "Fuel Price Analysis";

The name of the string is Report_Title, and it represents the string literal "Fuel Price Analysis." If you instruct DPL to display Report_Title, it will place the string literal, not the string's identifier, in the Session Log.

You can include non-printing characters in a string using escape sequences. For example, if you wish to include a tab character, use the escape sequence \t. The escape sequences for the double-quote character (") is \" and for the backslash character (\) is \\. The escape sequence to start a new line is \n.

You can form a string literal that takes up more than one line by using the backslash character (\) to represent string continuation. A backslash character contained in a string literal and at the end of a line (with no characters following it) causes DPL to treat the next line as a continuation of the current one.

Strings can depend on events. The following example uses the statename function.

decision Strategy.{Aggressive, Conservative};
string Current_Strategy = statename(Strategy);

You can use a string name in place of a string literal anywhere that DPL allows string literals. You can use strings and string literals as the argument of a display function, as arguments of the lookup functions (@hlookup, @vlookup), and as the arguments of the relational operators.

If strings are used as arguments of the relational operators (<, >, =, and so on), the ordering is determined by the standard ASCII values for characters. For example:

"a" < "z"
"a" > "A"

Both relations are true (that is, they both result in a value of 1).

If a string name appears in a math expression, DPL will generate a Not a number error message.

Versions: DPL Professional, DPL Enterprise, DPL Portfolio

See Also

Selection Spreadsheet Functions

The Definition Section