EDIT
ANSI
The EDIT instruction provides format capability for character or numeric variables. The instruction uses the following formats:
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
source
Required. A previously defined Character String Variable or a Numeric Variable that is formatted into {dest}.
sep
Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.
dest
Required. A previously defined Character String Variable containing the edit mask and in which the results are stored.
mask
Optional. A previously defined Character String Variable or literal containing the edit mask.
align
Optional. A previously defined decimal number or Numeric Variable that controls the decimal alignment of numeric variables.
Flags Affected: EOS, LESS, OVER
Note the following:
{source} is edited into {dest}. If {source} is a character string variable, only Logical String contents are used. If it is a FORM, the entire Physical String contents are used (however, any decimal is ignored). {source} remains unchanged.
The Logical String of {dest} should contain the edit criteria (mask).
The Form Pointer and Length Pointer of {dest} remain unchanged.
The source contents are EDITed left-to-right into {dest} without decimal alignment.
The Logical String length of {dest} determines the length of the operation. It terminates when the last mask character is processed.
The EOS Condition Flag is set if any of the following occurs:
Source string characters were not used.
The source or destination variable was a Null String.
If a dollar sign over stores a non-zero character.
If the source is exhausted before the operation is complete, character string variables are padded to the right with spaces. Numeric variables are padded to the right with zeros.
If {source} is a numeric variable, decimal points are ignored, leading blanks are treated as zeros and minus signs are treated as both a negative number and a leading zero (requiring two positions in {dest}).
If errors are encountered during the operation (for example, an alpha character was present when it should have been numeric), the source character is moved and the OVER Condition Flag is set.
Masking characters for character string variables are as follows:
|
Mask |
Allows |
|
A |
only an alphabetic character (upper or lower case) or a space. |
|
B |
inserts a space (no source string character is used). |
|
X |
any ASCII character. |
|
9 |
numeric digit only (0-9). |
|
0 |
inserts a zero (no source string character is used). |
|
|
Any other character in the mask is inserted into the output string. |
Masking characters for numeric variables are as follows:
|
Mask |
Allows |
|
B |
inserts a space (no source string character is used). |
|
9 |
numeric digit only (0-9). |
|
0 |
inserts a zero (no source string character is used). |
|
Z |
suppress leading zeros. This is terminated by the first non-zero character, excluding the currency symbol ($) or sign request ( + or - ). |
|
, |
inserts a comma unless zero suppression or zero replacement occurs (no source string character is used). |
|
+ |
generate a sign (+ or - ). This must appear only in the right most or left most character position of the mask. |
|
- |
generate a minus sign, if appropriate, or a blank. This must appear only in the right most or left most character position of the mask. |
|
$ |
suppress leading zeros, except the last affected zero is replaced with a $. If this character is specified, it is always placed in the result field providing there is at least one character after the first dollar sign in the mask. If a non-zero character is over stored, the LESS Condition Flag is set. |
|
* |
same as zero suppression above, except each leading zero is replaced with an asterisk (`*' - check protection symbol). |
|
( ) |
if the mask is enclosed in parentheses and the source string is a negative numeric variable, the output is enclosed in parentheses. Otherwise, the parentheses are replaced with spaces. |
|
|
Any other character in the mask is inserted into the output string. |
Under Visual PL/B, if the source variable is numeric then the mask and output variable are changed as follows:
If a '$' character exists in the destination mask, the current Currency and Monetary symbols are used for outputting the following:
The dollar sign ($) character is replaced with the current currency symbol defined.
The period (.) character is replaced with the current monetary decimal symbol.
The comma (,) character is replaced with the current monetary digit grouping symbol.
If a '$' character does not exist in the destination mask, the current Number symbols are used for outputting the following:
The period (.) character is replaced with the current number decimal symbol.
The comma (,) character is replaced with the current number digit grouping symbol.
If {mask} keyword is a string variable, it contains the edit mask. If {mask} is a literal, it cannot be null. When the {MASK} option is specified, the {mask} string is moved to the {dest} before the edit operation begins. If the {MASK} option is not specified, the edit operation assumes that the {dest} variable already contains the mask. If the {mask} string length is larger than the physical length of the {dest}, the string is moved to the {dest} variable with truncation and the edit operation proceeds.
The {ALIGN} keyword identifies when a FORM {source} variable is to have decimal alignment with the edit mask before edit operation begins. The compiler requires that the {source} variable type be a FORM when {ALIGN} is used or a compilation error occurs. The compiler will accept both ALIGN and ALIGNED as the keyword for this option. When this keyword is not specified, the default edit action is to not perform decimal alignment. When this keyword is specified and the value of the {align} is zero, the edit action is to not perform decimal alignment. When this keyword is specified and the value of the {align} is not zero, the edit action is to perform decimal alignment.
See Also: Example Code, Character String Instructions
![]() |