String Output Masking

For BBj-specific information, see String Output Masking - BBj.

Overview

A WRITE (or PRINT) statement may apply an output mask to any string expression.

Output Mask Syntax

str1:str2

Parameter

Description

str1

String to which the mask is to be applied.

str2

Mask.

All characters from str2 are copied directly to the output, with the exception that certain special characters within the mask are substituted with successive characters from str1.

Output Mask Special Characters

The special characters for use within the output mask are as follows:

Mask Character

Accepts

0

Any digit.

a

Any alphabetic character.

A

Any alphabetic character. Converts lower-case alphabetic characters to upper case.

X

Any printable character.

z

Any digit or alphabetic character.

Z

Any digit or alphabetic character. Converts lower-case alphabetic characters to upper case.

The number of characters output is always equal to the length of the mask:

  • If str1 is too short to fill the mask, the remaining positions will be padded with spaces.

  • If str1 is too long, or if a type mismatch occurs (for example, if a digit is required and the next character in str1 is not a digit), an !ERROR=43 is generated.