CONVERT

The CONVERT function replaces each byte of a byte stream or text expression with a byte from another byte stream or text expression. The decimal value of each byte of the first argument is used to locate the corresponding byte in the second argument that will replace it.

Syntax:
CONVERT ( single-byte-stream-or-text-expression , single-byte-stream-or-text-expression )
Meaning:
CONVERT (bytes_to_replace , replacement_bytes)
Returns:
A single byte stream or text item

The CONVERT function replaces each byte of bytes_to_replace with a byte from replacement_bytes. The byte chosen from replacement_bytes is the one whose index is the decimal value of bytes_to_replace. The first byte of replacement_bytes has the index value of zero. If there is no corresponding byte in replacement_bytes, CONVERT returns "none".

You can use the CONVERT function to convert ASCII to EBCDIC or EBCDIC to ASCII data. See the convert.mms map source file in the examples\general\portdata folder of the product installation directory. One of the maps in convert.mms is ASCII_TO_EBCDIC, which converts ASCII to EBCDIC. The EBCDIC_TO_ASCII map converts EBCDIC to ASCII.

ASCII to EBCDIC conversion can be performed automatically by defining the appropriate data language (ASCII or EBCDIC) for each data item.

Examples

  • CONVERT ( SYMBOL ( 0 ) ,"AB" )

    Returns A

  • CONVERT ( SYMBOL ( 1 ) ,"AB" )

    Returns B

  • CONVERT ( SYMBOL ( 2 ) ,"AB" )

    Returns "none"

  • CONVERT ( ASCII , ATOETable )

    Converts ASCII text to EBCDIC based on values in a table named ATOETable


Feedback