EDIT


ANSI

 

The EDIT instruction provides format capability for character or numeric variables. The instruction uses the following formats:

 

 

[label]

EDIT

{source}{sep}{dest}[{sep}{MASK={mask}[,ALIGN={align}]]

 

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:

  1. {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.

  2. The Logical String of {dest} should contain the edit criteria (mask).

  3. The Form Pointer and Length Pointer of {dest} remain unchanged.

  4. The source contents are EDITed left-to-right into {dest} without decimal alignment.

  5. The Logical String length of {dest} determines the length of the operation. It terminates when the last mask character is processed.

  6. The EOS Condition Flag is set if any of the following occurs:

  7. 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.

  8. 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}).

  9. 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.

  10. Masking characters for character string variables are as follows:
     

  11. 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.

     

  12. Masking characters for numeric variables are as follows:

  13.  

    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.

     

  14. Under Visual PL/B, if the source variable is numeric then the mask and output variable are changed as follows:

  15. 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.

  16. 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

 



PL/B Language Reference DRELEASE ENCODE64