![]() ![]() |
|
MC ConversionMC codes include facilities for:
One source of confusion when using MC codes is that input conversion does not always invert the code. For most MC codes, if they are used in field 7 of the data definition record, the code will be applied in its original (un-inverted) form to the input data. For this reason you should always try to put MC codes into field 8 of the data definition record. The exceptions to this, where input conversion is effective, are clearly indicated in the following sections.
SUMMARYMC codes are:
CHANGING CASEThe MC codes that can be used to transform text from upper to lower case and vice versa are:
INPUT CONVERSIONInput conversion does not invert. The conversion code will be applied to the input data.
EXAMPLE 1
Assuming a source value of AbCdEf, MCL will return abcdef.
EXAMPLE 2
Assuming a source value of AbC dEf "ghi, MCT will return Abc Def "ghi.
EXAMPLE 3
Assuming a source value of AbCdEf, MCU will return ABCDEF.
EXTRACTING CHARACTERSThe MC codes that can be used to extract characters from a string are:
INPUT CONVERSIONInput conversion does not invert. The original code will be applied to input data.
EXAMPLE 1
Assuming a source value of ABC*123!DEF, MCA will return ABCDEF.
EXAMPLE 2
Assuming a source value of ABC*123!DEF, MC/A will return *123!.
EXAMPLE 3
Assuming a source value of ABC*123!DEF, MCB will return ABC123DEF.
EXAMPLE 4
Assuming a source value of ABC*123!DEF, MC/B will return *!.
EXAMPLE 5
Assuming a source value of ABC*123!DEF, MCN will return 123.
EXAMPLE 6
Assuming a source value of ABC*123!DEF, MC/N will return ABC*!DEF.
REPLACING CHARACTERSSome MC codes replace one set of characters with other characters. These codes can:
INPUT CONVERSIONInput conversion does not invert. The original code will be applied to input data.
EXAMPLE 1
Assuming a source value of ABC*X5X!DEF, MCC will return ABC*YYY!DEF.
EXAMPLE 2
Assuming a source value of ABC]]DEF where ] represents a value mark, MCPN will return ABC.FC.FCDEF.
CONVERTING CHARACTERSThe MC codes that convert ASCII character codes to their binary or hexadecimal representations or vice versa are:
NOTESThe MCAB and MCABS codes convert each ASCII character to its binary equivalent as an eight-digit number. If there is more than one character, MCAB puts a blank space between each pair of eight-digit numbers. MCABS suppresses the spaces. When converting from binary to ASCII characters, MCBA uses blank spaces as dividers, if they are present. MCBA scans from the right-hand end of the data searching for elements of "eight-bit" binary strings. If it encounters a space and the element is not eight binary digits long, it prepends zeros to the front of the number until it contains eight digits. This continues until the leftmost digit is reached. Zeros are again prepended, if necessary. Each eight-digit element is then converted to its ASCII character equivalent.
INPUT CONVERSIONInput conversion does not invert. The original code will be applied to input data.
EXAMPLE 1
Assuming a source value of ABC, MCAX will return 414243.
EXAMPLE 2
Assuming a source value of 414243, MCXA will return ABC.
EXAMPLE 3
Assuming a source value of AB, MCAB will return 01000001 01000010.
EXAMPLE 4
Assuming a source value of AB, MCABS will return 0100000101000010.
EXAMPLE 5
Assuming a source value of 01000001 1000010, MCBA will return AB. Note the missing binary digit at the start of the second element of the source value.
EXAMPLE 6
Assuming a source value of 0100000101000010, MCBA will return AB.
CONVERTING NUMERIC VALUESThe MC codes that convert numeric values (as opposed to characters), to equivalent values in other number schemes are:
NOTESThese codes convert numeric values rather than individual characters. For example, a decimal value of 60 would be converted to X"3C" in hexadecimal, or LX in Roman numerals. The value 60 is converted, not the characters "6" and "0". With the exception of MCBX{S} which will handle spaces, all these codes will stop if they encounter a character that is not a digit of the source number system. The value up to the invalid character will be converted. With the exception of MCDR, if the conversion fails to find any valid digits, a zero will be returned. MCDR will return null. If you submit an odd number of hexadecimal digits to the MCXB code, it will add a leading zero (to arrive at an even number of characters) before converting the value. The MCXB and MCXBS codes convert each pair of hexadecimal digits to its binary equivalent as a eight-digit number. If there is more than one pair of hexadecimal digit, MCXB puts a blank space between each paid of eight-digit numbers. MCXBS suppresses the spaces. When converting from binary to hexadecimal digits, MCBX uses blank spaces as dividers if they are present. MCBX effectively scans from the right-hand end of the data searching for elements of eight-bit binary digits. If it encounters a space and the element is not a multiple of eight binary digits, it prepends zeros to the front of the number until contains eight digits. This continues until the leftmost digit is reached. Zeros are again prepended, if necessary. Each eight-digit element is then converted to a hexadecimal character pair.
INPUT CONVERSIONInput conversion is effective for MCDR, MCDX, MCRD and MCXD. Input conversion is not inverted for the other codes. The original code will be applied to input data.
EXAMPLE 1
Assuming a source value of 01000001 1000010, MCBX will return 4142. Would return the same value if there was no space between the binary source elements.
EXAMPLE 2
Assuming a source value of MLXVI, MCRD will return 1066.
EXAMPLE 3
Assuming a source value of 1066, MCDX will return 42A. jQL |