Copy character, justify, pad - Connect_CDC - connect_cdc_mimix_share - 5.8

Connect CDC System Reference Guide

Product type
Product family
Connect > Connect CDC (MIMIX Share)
Product name
Connect CDC
Connect CDC System Reference Guide
First publish date

Method:   Copy character, justify, pad

Function name:   copyjustify

Parameter list:   (CHAR input, char source_justify, char target_justify, char pad_str, integer target_len)

Return type:   CHAR

What the method does:    Copies a left or right justified source string to a left or right justified target string, padding the source string if it is smaller than the target or truncating it if it is larger.

The source string is input and the target string is the returned value. The desired length of the target is always input. If the source is smaller than the target, then the pad character is used to pad the source string to the full length on the target, padding on the right if it is right source justified or padding on the left if it is left source justified.

When truncation of the source string occurs in order for the string to fit into the target, the truncation occurs on the right side of the source string if it is left-justified or on the left side of the source string if it is target right-justified.

When padding of the source string occurs, in order for the target string to be filled up to the length that was input for it, then padding (using the input pad character) occurs on the right side of the target string is left-justified or on the left side if the target string is right justified.

The string designated as the pad character can be of any length, but only the first character is used as the pad character. The pad character can be any desired character (unlike the Version 3 methods in which the pad character can only be a space, a binary zero, or a numeric zero). An escaped “0” (that is, '\0', just like the binary zero in C, C++, and Java) can be used to represent a binary zero in a character literal.

If the pad character argument contains a string of characters, then the copyjustify run-time method just uses the first character.

The source and target justify indicators must be one of 'L' for left justify or 'R' for right justify. These must be upper case letters.

Examples: If C3 eq 'NM' and C5 contains 'Albuquerque”'

The expression  copyjustify(C3, 'L', 'L', '-', 10);yields the value: NM--------

The expression copyjustify(C5,'R','R','0',18 ); 

yields the value: 0000000Albuquerque

The expression copyjustify(C5,'R','R','0',6) ; 

yields the value: uerque