Use data conversion
Two forms of data conversion are supported by IBM MQ Automation Classes for ActiveX - numeric encoding, and character set conversion.
Numeric encoding
If you set the MQMessage Encoding property, the following methods convert between different numeric encoding systems:- ReadDecimal2 method
- ReadDecimal4 method
- ReadDouble method
- ReadDouble4 method
- ReadFloat method
- ReadInt2 method
- ReadInt4 method
- ReadLong method
- ReadShort method
- ReadUInt2 method
- WriteDecimal2 method
- WriteDecimal4 method
- WriteDouble method
- WriteDouble4 method
- WriteFloat method
- WriteInt2 method
- WriteInt4 method
- WriteLong method
- WriteShort method
- WriteUInt2 method
/* Encodings for Binary Integers */ MQENC_INTEGER_UNDEFINED MQENC_INTEGER_NORMAL MQENC_INTEGER_REVERSED /* Encodings for Decimals */ MQENC_DECIMAL_UNDEFINED MQENC_DECIMAL_NORMAL MQENC_DECIMAL_REVERSED /* Encodings for Floating-Point Numbers */ MQENC_FLOAT_UNDEFINED MQENC_FLOAT_IEEE_NORMAL MQENC_FLOAT_IEEE_REVERSED MQENC_FLOAT_S390
Dim msg As New MQMessage 'Define an IBM MQ message for our use.. Print msg. Encoding 'Currently 546 (or X'222') 'Set the encoding property to 785 (or X'311') msg. Encoding = MQENC_INTEGER_NORMAL OR MQENC_DECIMAL_NORMAL OR MQENC_FLOAT_S390 Print msg. Encoding 'Print it to see the change Dim local_num As long 'Define a long integer local_num = 1234 'Set it msg. WriteLong (local_num) 'Write the number into the message
Character set conversion
Character set conversion is necessary when you send a message from one system to another system where the code pages are different. Code page conversion is used by:- ReadString method
- ReadNullTerminatedString method
- WriteString method
- WriteNullTerminatedString method
- MessageData Property
You must set the MQMessage CharacterSet property to a supported character set value (CCSID).
IBM MQ Automation Classes for ActiveX uses conversion tables to perform character set conversion.
For example, to convert strings automatically to code page 437:Dim msg As New MQMessage 'Define an IBM MQ message msg.CharacterSet = 437 'Set code page required msg.WriteString "A character string"'Put character string in message
The WriteString method receives the string data ( A character string in the example) as a Unicode string. It then converts this data from Unicode into code page 437 using the conversion table 34B001B5.TBL.
Characters in the Unicode string that are not supported by code page 437 are given the standard substitution character from code page 437.
Similarly, when we use the ReadString method, the incoming message has a character set established by the IBM MQ Message Descriptor (MQMD) value and there is a conversion from this code page into Unicode before it is passed back to your scripting language.