Literals


ANSI

 

Literals are data strings (alpha, numeric, or a combination) that are not declared as variables. Literals are useful in programs where a constant value is needed. They may be in one of the following formats:

Character literals may be defined in any supported numbering base:

 

Decimal

32

Binary

0b00100000

Hexadecimal

0x20

Octal

040

 

The following rules apply to string literals:

 

The following examples show how String Literals may be OPERANDS:

 

 

ADD

"1" TO PAGENCTR

 

MOVE

"YEAR-END" TO TITLE

 

DISPLAY

"PAYROLL ENTRY - VERSION 1.0"

 

KEYIN

"ENTER PART NUMBER: ",PARTNO

 

MATCH

" " TO REPLY

 

SCAN

"YES",ANSWER

 

Ctrl literals must be between the values of 0 and 255 (decimal). Note the following examples:

 

DECESC

INIT

27

BINESC

INIT

0b00011011

HEXESC

INIT

0x1B

OCTESC

INIT

033

 

CMOVE

32 TO DECIMAL

 

CMOVE

0b00100000 TO BINARY

 

CMOVE

0x20 TO HEX

 

CMOVE

040 TO OCTAL

 

The compiler optimizes the User Data Area by converting multiple literal representations of the same value into a single variable within the following guidelines: If the size of the literal is equal to or less than the label size for numeric variables or label size minus 1 for character strings (where the maximum label size is equal to 8 or your defined size), it is no longer more efficient to use:

 

ZERO

FORM

"0"

 

MOVE

ZERO,FIELD

 

COMPARE

ZERO,FIELDX

 

As opposed to:

 

 

MOVE

"0",FIELD

 

COMPARE

"0",FIELDX

 

A literal may be continued on multiple lines:

 

 

DISPLAY

"This is an example "::

 

 

"of a continued literal."

 

 

See Also: Instruction Syntax

 



PL/B Language Reference Comment Instructions National Character String Literals