MQMessage class

This class represents an WebSphere MQ message. It includes properties to encapsulate the WebSphere MQ message descriptor (MQMD), and provides a buffer to hold the application-defined message data.

The class includes Write methods to copy data from an ActiveX application to an MQMessage object and similarly Read methods to copy data from an MQMessage object to an ActiveX application. The class manages the allocation and deallocation of memory for the buffer automatically. The application does not have to declare the size of the buffer when an MQMessage object is created because the buffer grows to accommodate data written to it.

You cannot place a message onto an WebSphere MQ queue if the buffer size exceeds the MaximumMessageLength property of that queue.

After it has been constructed, an MQMessage object may be Put onto an WebSphere MQ queue using the MQQueue.Put method. This method takes a copy of the MQMD and message data portions of the object and places that copy on the queue - so the application may modify or delete an MQMessage object after the Put, without affecting the message on the WebSphere MQ queue. The queue manager may adjust some of the fields in the MQMD when it copies the message on the WebSphere MQ queue.

An incoming message may be read into an MQMessage object using the MQQueue.Get method. This replaces any MQMD or message data that may already have been in the MQMessage object with values from the incoming message, adjusting the size of the MQMessage object's data buffer to match the size of the incoming message data.

Containment

Messages are contained by the MQSession class.

Creation

New creates a new MQMessage object. Its Message Descriptor properties are initially set to default values, and its Message Data buffer is empty.

Syntax

Dim msg As New MQMessage
or
Set msg = New MQMessage

Properties

The control properties are:

The Message Descriptor properties are:

Methods

Property access

All properties can be read at any time.

The control properties are read-only, except for DataOffset which is read-write. The Message Descriptor properties are all read-write, except BackoutCount and TotalMessageLength which are both read-only.

Note however that some of the MQMD properties may be modified by the queue manager when the message is put onto an WebSphere MQ queue. See the WebSphere MQ Application Programming Reference for details.

You can pass binary data to an WebSphere MQ message by setting the CharacterSet property to the Coded Character Set Identifier of the queue manager (MQCCSI_Q_MGR), and passing it a string. You can use the chr$ function to set non-character data into the string.

Data conversion

The Read and Write methods perform data conversion. They convert between the ActiveX internal formats, and the WebSphere MQ message formats as defined by the Encoding and CharacterSet properties from the message descriptor. When writing a message you should, if possible, set values into Encoding and CharacterSet that match the characteristics of the recipient of the message before issuing a Write method. When reading a message, this is not normally required because these values will have been set from those in the incoming MQMD.

This is an additional data conversion step that happens after any conversion performed by the MQQueue.Get method.

CompletionCode property

Read-only. Returns the WebSphere MQ completion code set by the most recent method or property access issued against this object.

Defined in: MQMessage class

Data Type: Long

Values:

Syntax:
To get: completioncode& = MQMessage.CompletionCode

DataLength property

Read-only. This property returns the value:

MQMessage.MessageLength - MQMessage.DataOffset

It can be used before a Read method, to check that the expected number of characters are actually present in the buffer.

The initial value is zero.

Defined in: MQMessage class

Data Type: Long

Syntax:
To get: bytesleft& = MQMessage.DataLength

DataOffset property

Read-write. The current position within the Message Data portion of the message object.

The value is expressed as a byte offset from the start of the message data buffer; the first character in the buffer corresponds to a DataOffset value of zero.

A read or write method commences its operation at the character referenced by DataOffset. These methods process data in the buffer sequentially from this position, and update DataOffset to point to the byte (if any) immediately following the last byte processed.

DataOffset may take only values in the range zero to MessageLength inclusive. When DataOffset = MessageLength it is pointing to the end, that is the first invalid character of the buffer. Write methods are permitted in this situation - they extend the data in the buffer and increase MessageLength by the number of bytes added. Reading beyond the end of the buffer is not valid.

The initial value is zero.

Defined in: MQMessage class

Data Type: Long

Syntax:
To get: currpos& = MQMessage.DataOffset

To set: MQMessage.DataOffset = currpos&

MessageLength property

Read-only. Returns the total length of the Message Data portion of the message object in characters, irrespective of the value of DataOffset.

The initial value is zero. It is set to the incoming Message Length after a Get method invocation that referenced this message object. It is incremented if the application uses a Write method to add data to the object. It is unaffected by Read methods.

Defined in: MQMessage class

Data Type: Long

Syntax:
To get: msglength& = MQMessage.MessageLength

ReasonCode property

Read-only. Returns the reason code set by the most recent method or property access issued against this object.

Defined in: MQMessage class

Data Type: Long

Values:

Syntax:
To get: reasoncode& = MQMessage.ReasonCode

ReasonName property

Read-only. Returns the symbolic name of the latest reason code. For example, "MQRC_QMGR_NOT_AVAILABLE".
Defined in: MQMessage class

Data Type: String

Values:

Syntax:
To get: reasonname$ = MQMessage.ReasonName

AccountingToken property

Read-write. The MQMD AccountingToken - part of the message Identity Context.

Its initial value is all nulls.

Defined in: MQMessage class

Data Type: String of 32 characters

Syntax:
To get: actoken$ = MQMessage.AccountingToken

To set: MQMessage.AccountingToken = actoken$

Note:
See Message Descriptor properties for a discussion of when you must use AccountingTokenHex in place of te AccountingToken property.

AccountingTokenHex property

Read-write. The MQMD AccountingToken - part of the message Identity Context.

Every two characters represent the hexadecimal equivalent of a single ASCII character. For example, the pair of characters "6" and "1" represent the single character "A", the pair of characters "6" and "2" represent the single character "B", and so on.

You must supply 64 valid hexadecimal characters.

Its initial value is "0...0"

Defined in: MQMessage class

Data Type: String of 64 hexadecimal characters representing 32 ASCII characters

Syntax:
To get: actokenh$ = MQMessage.AccountingTokenHex

To set: MQMessage.AccountingTokenHex = actokenh$

Note:
See Message Descriptor properties for a discussion of when you must use AccountingTokenHex in place of the AccountingToken property.

ApplicationIdData property

Read-write. The MQMD ApplIdentityData - part of the message Identity Context.

Its initial value is all blanks.

Defined in: MQMessage class

Data Type: String of 32 characters

Syntax:
To get: applid$ = MQMessage.ApplicationIdData

To set: MQMessage.ApplicationIdData = applid$

ApplicationOriginData property

Read-write. The MQMD ApplOriginData - part of the message origin context.

Its initial value is all blanks.

Defined in: MQMessage class

Data Type: String of 4 characters

Syntax:
To get: applor$ = MQMessage.ApplicationOriginData

To set: MQMessage.ApplicationOriginData = applor$

BackoutCount property

Read-only. The MQMD BackoutCount.

Its initial value is 0

Defined in: MQMessage class

Data Type: Long

Syntax:
To get: backoutct& = MQMessage.BackoutCount

CharacterSet property

Read-write. The MQMD CodedCharSetId.

Its initial value is the special value MQCCSI_Q_MGR.

If CharacterSet is set to MQCCSI_Q_MGR, the WriteString method does not perform code-page conversion.

For example:

msg.CharacterSet = MQCCSI_Q_MGR
msg.WriteString(chr$(n))

where 'n' is greater than or equal to zero and less than or equal to 255, results in a single byte of value of 'n' being written to the buffer.

Defined in: MQMessage class

Data Type: Long

Syntax:
To get: ccid& = MQMessage.CharacterSet

To set: MQMessage.CharacterSet = ccid&

Example

If you want the string written out in code page 437, issue:

Message.CharacterSet = 437
Message.WriteString ("string to be written")

Set the value you want in the CharacterSet before issuing any WriteString calls.

CorrelationId property

Read-write. The CorrelationId to be included in the MQMD of a message when put on a queue, also the Id to be matched against when getting a message from a queue.

Its initial value is null.

Defined in: MQMessage class

Data Type: String of 24 characters

Syntax:
To get: correlid$ = MQMessage.CorrelationId
To set: MQMessage.CorrelationId = correlid$

Note:
See Message Descriptor properties for a discussion of when you must use CorrelationIdHex in place of the CorrelationId property.

CorrelationIdHex property

Read-write. The CorrelationId to be included in the MQMD of a message when put on a queue, also the CorrelationId to be matched against when getting a message from a queue.

Every two characters of the string represent the hexadecimal equivalent of a single ASCII character. For example, the pair of characters "6" and "1" represent the single character "A", the pair of characters "6" and "2" represent the single character "B", and so on.

You must supply 48 valid hexadecimal characters.

Its initial value is "0...0".

Defined in: MQMessage class

Data Type: String of 48 hexadecimal characters representing 24 ASCII characters

Syntax:
To get: correlidh$ = MQMessage.CorrelationIdHex

To set: MQMessage.CorrelationIdHex = correlidh$

Note:
See Message Descriptor properties for a discussion of when you must use CorrelationIdHex in place of the CorrelationId property.

Encoding property

Read-write. The MQMD field that identifies the representation used for numeric values in the application message data.

Its initial value is the special value MQENC_NATIVE, which varies by platform.

This property is used by the following methods:

Defined in: MQMessage class

Data Type: Long

Syntax:
To get: encoding& = MQMessage.Encoding
To set: MQMessage.Encoding = encoding&

If you are preparing to write data to the message buffer, you should set this field to match the characteristics of the receiving queue manager platform if the receiving queue manager is incapable of performing its own data conversion.

Expiry property

Read-write. The MQMD expiry time field, expected in tenths of a second.

Its initial value is the special value MQEI_UNLIMITED

Defined in: MQMessage class

Data Type: Long

Syntax:
To get: expiry& = MQMessage.Expiry

To set: MQMessage.Expiry = expiry&

Feedback property

Read-write. The MQMD feedback field.

Its initial value is the special value MQFB_NONE.

Defined in: MQMessage class

Data Type: Long

Values:

Syntax:
To get: feedback& = MQMessage.Feedback

To set: MQMessage.Feedback = feedback&

Format property

Read-write. The MQMD format field. Gives the name of a built-in or user-defined format that describes the nature of the Message Data.

Its initial value is the special value MQFMT_NONE.

Defined in: MQMessage class

Data Type: String of 8 characters

Syntax:
To get: format$ = MQMessage.Format

To set: MQMessage.Format = format$

GroupId property

Read-write. The GroupId to be included in the MQPMR of a message when put on a queue, also the Id to be matched against when getting a message from a queue. Its initial value is all nulls.

Defined in:
MQMessage class

Data Type:
String of 24 characters

Syntax:
To get: groupid$ = MQMessage.GroupId

To set: MQMessage.GroupId = groupid$

Note:
See Message Descriptor properties for a discussion of when you must use GroupIdHex in place of the GroupId property.

GroupIdHex property

Read-write. The GroupId to be included in the MQPMR of a message when put on a queue, also the Id to be matched against when getting a message from a queue.

Every two characters of the string represent the hexadecimal equivalent of a single ASCII character. For example, the pair of characters "6" and "1" represent the single character "A", the pair of characters "6" and "2" represent the single character "B" and so on.

You must supply 48 valid hexadecimal characters.

Its initial value is "0...0".

Defined in:
MQMessage class

Data Type:
String of 48 hexadecimal characters representing 24 ASCII characters.

Syntax:
To get: groupidh$ = MQMessage.GroupIdHex

To set: MQMessage.GroupIdHex = groupidh$

Note:
See Message Descriptor properties for a discussion of when you must use GroupIdHex in place of the GroupId property.

MessageData property

Read-write. Retrieves or sets the entire contents of a message as a character string.

Defined in: MQMessage class

Data Type: Variant

Note:
The data type used by this property is Variant but MQAX expects this to be a variant type of String. If you pass in a variant of other than this type then the error MQRC_OBJECT_TYPE_ERROR will be returned.

Syntax:
To get: String$ = MQMessage.MessageData

To set: MQMessage.MessageData = String$

MessageFlags property

Read-Write. Message flags specifying Segmentation control information. The initial value is 0.

Defined in:
MQMessage class

Data Type:
Long

Values:
See the WebSphere MQ Application Programming Reference

Syntax:
To get: messageflags& = MQMessage.MessageFlags

To set: MQMessage.MessageFlags = messageflags&

MessageId property

Read-write. The MessageId to be included in the MQMD of a message when put on a queue, also the Id to be matched against when getting a message from a queue.

Its initial value is all nulls.

Defined in: MQMessage class

Data Type: String of 24 characters

Syntax:
To get: messageid$ = MQMessage.MessageId

To set: MQMessage.MessageId = messageid$

Note:
See Message Descriptor properties for a discussion of when you must use MessageIdHex in place of the MessageId property.

MessageIdHex property

Read-write. The MessageId to be included in the MQMD of a message when put on a queue, also the MessageId to be matched against when getting a message from a queue.

Every two characters of the string represent the hexadecimal equivalent of a single ASCII character. For example, the pair of characters "6" and "1" represent the single character "A", the pair of characters "6" and "2" represent the single character "B", and so on.

You must supply 48 valid hexadecimal characters.

Its initial value is "0...0".

Defined in: MQMessage class

Data Type: String of 48 hexadecimal characters representing 24 ASCII characters

Syntax:
To get: messageidh$ = MQMessage.MessageIdHex

To set: MQMessage.MessageIdHex = messageidh$

Note:
See Message Descriptor properties for a discussion of when you must use MessageIdHex in place of the MessageId property.

MessageSequenceNumber property

Read-Write. Sequence information identifying a message within a group. The initial value is 1.

Defined in:
MQMessage class

Data Type:
Long

Values:
See the WebSphere MQ Application Programming Reference

Syntax:
To get: sequencenumber& = MQMessage.SequenceNumber

To set: MQMessage.SequenceNumber = sequencenumber&

MessageType property

Read-write. The MQMD MsgType field.

Its initial value is MQMT_DATAGRAM.

Defined in: MQMessage class

Data Type: Long

Values:

Syntax:
To get: msgtype& = MQMessage.MessageType

To set: MQMessage.MessageType = msgtype&

Offset property

Read-Write. The offset in a segmented message. The initial value is 0.

Defined in:
MQMessage class

Data Type:
Long

Values:
See the WebSphere MQ Application Programming Reference

Syntax:
To get: offset& = MQMessage.Offset

To set: MQMessage.Offset = offset&

OriginalLength property

Read-Write. The original length of a segmented message. The initial value is MQOL_UNDEFINED

Defined in:
MQMessage class

Data Type:
Long

Values:
See the WebSphere MQ Application Programming Reference

Syntax:
To get: originallength& = MQMessage.OriginalLength

To set: MQMessage.OriginalLength = originallength&

Persistence property

Read-write. The message's persistence setting.

Its initial value is MQPER_PERSISTENCE_AS_Q_DEF.

Defined in: MQMessage class

Data Type: Long

Syntax:
To get: persist& = MQMessage.Persistence

To set: MQMessage.Persistence = persist&

Priority property

Read-write. The message's priority.

Its initial value is the special value MQPRI_PRIORITY_AS_Q_DEF

Defined in: MQMessage class

Data Type: Long

Syntax:
To get: priority& = MQMessage.Priority

To set: MQMessage.Priority = priority&

PutApplicationName property

Read-write. The MQMD PutApplName - part of the Message Origin context.

Its initial value is all blanks.

Defined in: MQMessage class

Data Type: String of 28 characters

Syntax:
To get: putapplnm$ = MQMessage.PutApplicationName

To set: MQMessage.PutApplicationName = putapplnm$

PutApplicationType property

Read-write. The MQMD PutApplType - part of the Message Origin context.

Its initial value is MQAT_NO_CONTEXT

Defined in: MQMessage class

Data Type: Long

Values:

Syntax:
To get: putappltp& = MQMessage.PutApplicationType

To set: MQMessage.PutApplicationType = putappltp&

PutDateTime property

Read-write. This property combines the MQMD PutDate and PutTime fields. These are part of the Message Origin context that indicate when the message was put.

The ActiveX Extension converts between ActiveX date/time format and the Date and Time formats used in an WebSphere MQ MQMD. If a message is received which has an invalid PutDate or PutTime, then the PutDateTime property after the get method will be set to EMPTY.

Its initial value is EMPTY.

Defined in: MQMessage class

Data Type: Variant of type 7 (date/time) or EMPTY.

Syntax:
To get: datetime = MQMessage.PutDateTime

To set: MQMessage.PutDateTime = datetime

ReplyToQueueManagerName property

Read-write. The MQMD ReplyToQMgr field.

Its initial value is all blanks

Defined in: MQMessage class

Data Type: String of 48 characters

Syntax:
To get: replytoqmgr$ = MQMessage.ReplyToQueueManagerName

To set: MQMessage.ReplyToQueueManagerName = replytoqmgr$

ReplyToQueueName property

Read-write. The MQMD ReplyToQ field.

Its initial value is all blanks

Defined in: MQMessage class

Data Type: String of 48 characters

Syntax:
To get: replytoq$ = MQMessage.ReplyToQueueName

To set: MQMessage.ReplyToQueueName = replytoq$

Report property

Read-write. The message's Report options.

Its initial value is MQRO_NONE.

Defined in: MQMessage class

Data Type: Long

Values:

Syntax:
To get: report& = MQMessage.Report

To set: MQMessage.Report = report&

TotalMessageLength property

Read-only. Retrieves the length of the last message received by MQGET. If the message has not been truncated, this value is equal to the value of the MessageLength property.

Defined in: MQMessage class

Data Type: Long

Syntax:
To get: totalmessagelength& = MQMessage.TotalMessageLength

UserId property

Read-write. The MQMD UserIdentifier - part of the message Identity Context.

Its initial value is all blanks.

Defined in: MQMessage class

Data Type: String of 12 characters

Syntax:
To get: userid$ = MQMessage.UserId

To set: MQMessage.UserId = userid$

ClearErrorCodes method

Resets the CompletionCode to MQCC_OK and the ReasonCode to MQRC_NONE for both the MQMessage class and the MQSession class.

Defined in: MQMessage class

Syntax:
Call MQMessage.ClearErrorCodes()

ClearMessage method

This method clears the data buffer portion of the MQMessage object. Any Message Data in the data buffer is lost, because MessageLength, DataLength, and DataOffset are all set to zero.

The Message Descriptor (MQMD) portion is unaffected; an application may need to modify some of the MQMD fields before reusing the MQMessage object. If you wish to set the MQMD fields back to initial values you should use New to replace the object with a new instance.

Defined in: MQMessage class

Syntax:
Call MQMessage.ClearMessage()

Read method

Reads a sequence of bytes from the message buffer into a byte array. DataOffset is incremented and Data Length decremented by the number of bytes read.

Defined in:
MQMessage class

Syntax:
Data = MQMessage.Read(len&)

Parameters:
len&: Long. Length of data in bytes to be read.

ReadBoolean method

Reads a 1-byte Boolean value from the current position in the message buffer and returns a 2-byte Boolean TRUE(-1)/FALSE(0) value. DataOffset is incremented by one and Data Length is decremented by one.

Defined in:
MQMessage class

Syntax:
value = MQMessage.ReadBoolean

ReadByte method

This method reads 1 byte from the Message Data buffer, starting with the character referred to by DataOffset and returns it as an Integer (signed 2-byte) integer value in the range -128 to 127.

The method fails if MQMessage.DataLength is less than 1 when it is issued.

DataOffset is incremented by 1 and DataLength is decremented by 1 if the method succeeds.

The byte of message data is assumed to be a signed binary integer.

Defined in: MQMessage class

Syntax:
integerv% = MQMessage.ReadByte

ReadDecimal2 method

Reads a 2-byte packed decimal number and returns it as a signed 2-byte integer value. DataOffset is incremented by two and Data Length is decremented by two.

Defined in:
MQMessage class

Syntax:
value% = MQMessage.ReadDecimal2

ReadDecimal4 method

Reads a 4-byte packed decimal number and returns it as a signed 4-byte integer value. DataOffset is incremented by four and Data Length is decremented by four.

Defined in:
MQMessage class

Syntax:
Call value& = MQMessage.ReadDecimal4

ReadDouble method

This method reads 8 bytes from the Message Data buffer, starting with the byte referred to by DataOffset and returns it as a Double (signed 8-byte) floating point value.

The method fails if MQMessage.DataLength is less than 8 when it is issued.

DataOffset is incremented by 8 and DataLength is decremented by 8 if the method succeeds.

The 8 characters of message data are assumed to be a binary floating point number whose encoding is specified by the MQMessage.Encoding property. Note that conversion from System/360 format is not supported.

Defined in: MQMessage class

Syntax:
doublev# = MQMessage.ReadDouble

ReadDouble4 method

The ReadDouble4 and WriteDouble4 methods are alternatives to ReadFloat and WriteFloat. This is because they support 4-byte System/390 floating point message values that are too large to convert to 4-byte IEEE floating point format.

This method reads 4 bytes from the Message Data buffer, starting with the byte referred to by DataOffset and returns it as a Double (signed 8-byte) floating point value.

The method fails if MQMessage.DataLength is less than 4 when it is issued.

DataOffset is incremented by 4 and DataLength is decremented by 4 if the method succeeds.

The 4 characters of message data are assumed to be a binary floating point number whose encoding is specified by the MQMessage.Encoding property. Note that conversion from System/360 format is not supported.

Defined in: MQMessage class

Syntax:
doublev# = MQMessage.ReadDouble4

ReadFloat method

This method reads 4 bytes from the Message Data buffer, starting with the byte referred to by DataOffset and returns it as a Single (signed 4-byte) floating point value.

The method fails if MQMessage.DataLength is less than 4 when it is issued.

DataOffset is incremented by 4 and DataLength is decremented by 4 if the method succeeds.

The 4 characters of message data are assumed to be a floating point number whose encoding is specified by the MQMessage.Encoding property. Note that conversion from System/360 format is not supported.

Defined in: MQMessage class

Syntax:
singlev! = MQMessage.ReadFloat

ReadInt2 method

The method is identical to the ReadShort method.

Syntax:
integerv% = MQMessage.ReadInt2

ReadInt4 method

This method is identical to the ReadLong method.

Syntax:
bigint& = MQMessage.ReadInt4

ReadLong method

This method reads 4 bytes from the Message Data buffer, starting with the byte referred to by DataOffset and returns it as a Long (signed 4-byte) integer value.

The method fails if MQMessage.DataLength is less than 4 when it is issued.

DataOffset is incremented by 4 and DataLength is decremented by 4 if the method succeeds.

The 4 characters of message data are assumed to be a binary integer whose encoding is specified by the MQMessage.Encoding property.

Defined in: MQMessage class

Syntax:
bigint& = MQMessage.ReadLong

ReadNullTerminatedString method

This is for use in place of ReadString if the string may contain embedded null characters.

This method reads the specified number of bytes from the message data buffer starting with the byte referred to by DataOffset and returns it as an ActiveX string. If the string contains an embedded null before the end then the length of the returned string is reduced to reflect only those characters before the null.

DataOffset is incremented and DataLength is decremented by the value specified regardless of whether or not the string contains embedded null characters.

The characters in the message data are assumed to be a string whose code page is specified by the MQMessage.CharacterSet property. Conversion to ActiveX representation is performed for the application.

Defined in:
MQMessage class

Syntax:
string$ = MQMessage.ReadNullTerminatedString(length&)

Parameters:
length& Long. Length of string field in bytes.

ReadShort method

This method reads 2 bytes from the Message Data buffer, starting with the byte referred to by DataOffset and returns it as an Integer (signed 2-byte) value.

The method fails if MQMessage.DataLength is less than 2 when it is issued.

DataOffset is incremented by 2 and DataLength is decremented by 2 if the method succeeds.

The 2 characters of message data are assumed to be a binary integer whose encoding is specified by the MQMessage.Encoding property.

Defined in: MQMessage class

Syntax:
integerv% = MQMessage.ReadShort

ReadString method

This method reads n bytes from the Message Data buffer starting with the byte referred to by DataOffset and returns it as an ActiveX string.

The method fails if MQMessage.DataLength is less than n when it is issued.

DataOffset is incremented by n and DataLength is decremented by n if the method succeeds.

The n characters of message data are assumed to be a string whose code page is specified by the MQMessage.CharacterSet property. Conversion to ActiveX representation is performed for the application.

Defined in: MQMessage class

Syntax:
stringv$ = MQMessage.ReadString(length&)

Parameter
length& Long. Length of string field in bytes.

ReadUInt2 method

This method reads 2 bytes from the Message Data buffer, starting with the byte referred to by DataOffset and returns it as a Long (signed 4-byte) integer value.

The method fails if MQMessage.DataLength is less than 2 when it is issued.

DataOffset is incremented by 2 and DataLength is decremented by 2 if the method succeeds.

The 2 bytes of message data are assumed to be an unsigned binary integer whose encoding is specified by the MQMessage.Encoding property.

Defined in: MQMessage class

Syntax:
bigint& = MQMessage.ReadUInt2

ReadUnsignedByte method

This method reads 1 byte from the Message Data buffer, starting with the byte referred to by DataOffset and returns it as an Integer (signed 2-byte) integer value in the range 0 to 255.

The method fails if MQMessage.DataLength is less than 1 when it is issued.

DataOffset is incremented by 1 and DataLength is decremented by 1 if the method succeeds.

The 1 character of message data is assumed to be an unsigned binary integer.

Defined in: MQMessage class

Syntax:
integerv% = MQMessage.ReadUnsignedByte

ReadUTF method

This method reads a UTF format string from the message starting with the byte referred to by DataOffset and returns it as an ActiveX string. The string in the message consists of a 2-byte length followed by the character data.

The method fails if MQMessage.DataLength is less than the string length when it is issued.

DataOffset is incremented by the string length and DataLength is decremented by the string length if the method succeeds.

Defined in:
MQMessage class

Syntax:
value$ = MQMessage.ReadUTF

ResizeBuffer method

This method alters the amount of storage currently allocated internally to hold the Message Data buffer. It gives the application some control over the automatic buffer management, in that if the application knows that it is going to deal with a large message, it can ensure that a sufficiently large buffer is allocated. The application does not need to use this call - if it does not, the automatic buffer management code will grow the buffer size to fit.

If you resize the buffer to be smaller that the current MessageLength, you risk losing data. If you do lose data, the method returns a CompletionCode of MQCC_WARNING and a ReasonCode of MQRC_DATA_TRUNCATED.

If you resize the buffer to be smaller than the value of the DataOffset property the:

Defined in:
MQMessage class

Syntax:
MQMessage.ResizeBuffer(Length&)

Parameter:
Length& Long. Size required in characters.

Write method

Writes a sequence of bytes to the message buffer from a byte array at the position referred to by Data Offset. If necessary the length of the buffer (MQMessage.MQMessageLength) is extended to accommodate the full length of the byte array. DataOffset is incremented by the number of bytes written if the method succeeds.

Defined in:
MQMessage class

Syntax:
Call MQMessage.Write(value)

Parameters:
data: a byte array or a variant reference to a byte array

WriteBoolean method

Writes a 1-byte Boolean value at the current position in the message buffer from a 2-byte Boolean value. DataOffset is incremented by one.

Defined in:
MQMessage class

Syntax:
Call MQMessage.WriteBoolean(value)

Parameter:
value: Boolean (2-bytes). Value to be written.

WriteByte method

This method takes a signed 2-byte integer value and writes it into the Message Data buffer as a 1-byte binary number at the position referred to by DataOffset. It replaces any data already at the position in the buffer, and extends the length of the buffer (MQMessage.MessageLength) if necessary.

DataOffset is incremented by one if the method succeeds.

The value specified should be in the range -128 to 127. If it is not, the method returns with CompletionCode MQCC_FAILED and ReasonCode MQRC_WRITE_VALUE_ERROR.

Defined in: MQMessage class

Syntax:
Call MQMessage.WriteByte(value% )

Parameter: value% Integer. Value to be written.

WriteDecimal2 method

Writes a signed 2-byte integer as a 2-byte packed decimal number. DataOffset is incremented by two.

Defined in:
MQMessage class

Syntax:
Call MQMessage.WriteDecimal2(value%)

Parameter:
value% Integer. Value to be written.

WriteDecimal4 method

Writes a signed 4-byte integer as a 4-byte packed decimal number. DataOffset is incremented by four.

Defined in:
MQMessage class

Syntax:
Call MQMessage.WritedDecimal4(value&)

Parameter:
value& Long. Value to be written.

WriteDouble method

This method takes a signed 8-byte floating point value and writes it into the Message Data buffer as an 8-byte floating point number starting at the position referred to by DataOffset. It replaces any data already at these positions in the buffer, and extends the length of the buffer (MQMessage.MessageLength) if necessary.

DataOffset is incremented by 8 if the method succeeds.

The method converts to the floating point representation specified by the MQMessage.Encoding property. Conversion to System/360 format is not supported.

Defined in: MQMessage class

Syntax:
Call MQMessage.WriteDouble(value# )

Parameter:
value# Double. Value to be written.

WriteDouble4 method

See ReadDouble4 method for a description of when ReadDouble4 and WriteDouble4 should be used in place of ReadFloat and WriteFloat.

This method takes a signed 8-byte floating point value and writes it into the Message Data buffer as a 4-byte floating number starting at the position referred to by DataOffset.

DataOffset is incremented by 4 if the method succeeds.

It replaces any data already at these positions in the buffer, and extends the length of the buffer (MQMessage.MessageLength) if necessary.

The method converts to the floating point representation specified by the MQMessage.Encoding property. Conversion to System/360 format is not supported.

Defined in: MQMessage class

Syntax:
Call MQMessage.WriteDouble4(value#)

Parameter: value# Double. Value to be written.

WriteFloat method

This method takes a signed 4-byte floating point value and writes it into the Message Data buffer as a 4-byte floating point number starting at the character referred to by DataOffset. It replaces any data already at these positions in the buffer, and extends the length of the buffer (MQMessage.MessageLength) if necessary.

DataOffset is incremented by 4 if the method succeeds.

The method converts to the binary representation specified by the MQMessage.Encoding property. Conversion to System/360 format is not supported.

Defined in: MQMessage class

Syntax:
Call MQMessage.WriteFloat(value! )

Parameter value! Float. Value to be written.

WriteInt2 method

This method is identical to the WriteShort method.

Syntax:
Call MQMessage.WriteInt2(value% )

Parameter value% Integer. Value to be written.

WriteInt4 method

This method is identical to the WriteLong method.

Syntax:
Call MQMessage.WriteInt4(value& )

Parameter value& Long. Value to be written.

WriteLong method

This method takes a signed 4-byte integer value and writes it into the Message Data buffer as a 4-byte binary number starting at the byte referred to by DataOffset. It replaces any data already at these positions in the buffer, and extends the length of the buffer (MQMessage.MessageLength) if necessary.

DataOffset is incremented by 4 if the method succeeds.

The method converts to the binary representation specified by the MQMessage.Encoding property.

Defined in: MQMessage class

Syntax:
Call MQMessage.WriteLong(value&)

Parameter value& Long. Value to be written.

WriteNullTerminatedString method

This method performs a normal WriteString and pads any remaining bytes up to the specified length with null. If the number of bytes written by the initial write string is equal to the specified length then no nulls are written. If the number of bytes exceeds the specified length then an error (reason code MQRC_WRITE_VALUE_ERROR) is set.

DataOffset is incremented by the specified length if the method succeeds.

Defined in: MQMessage class

Syntax:
Call MQMessage.WriteNullTerminatedString(value$, length&)

Parameters:
value$ String. Value to be written.

length& Long. Length of string field in bytes.

WriteShort method

This method takes a signed 2-byte integer value and writes it into the Message Data buffer as a 2-byte binary number starting at the byte referred to by DataOffset. It replaces any data already at these positions in the buffer, and will extend the length of the buffer (MQMessage.MessageLength) if necessary.

DataOffset is incremented by 2 if the method succeeds.

The method converts to the binary representation specified by the MQMessage.Encoding property.

Defined in: MQMessage class

Syntax:
Call MQMessage.WriteShort(value%)

Parameter value% Integer. Value to be written.

WriteString method

This method takes an ActiveX string and writes it into the Message Data buffer starting at the byte referred to by DataOffset. It replaces any data already at these positions in the buffer, and will extend the length of the buffer (MQMessage.MessageLength) if necessary.

DataOffset is incremented by the length of the string in bytes if the method succeeds.

The method converts characters into the code page specified by the MQMessage.CharacterSet property.

Defined in: MQMessage class

Syntax:
Call MQMessage.WriteString(value$)

Parameter value$ String. Value to be written.

WriteUInt2 method

This method takes a signed 4-byte integer value and writes it into the Message Data buffer as a 2-byte unsigned binary number starting at the byte referred to by DataOffset. It replaces any data already at these positions in the buffer, and extends the length of the buffer (MQMessage.MessageLength) if necessary.

DataOffset is incremented by 2 if the method succeeds.

The method converts to the binary representation specified by the MQMessage.Encoding property. The value specified should be in the range 0 to 2**16-1. If it is not the method returns with CompletionCode MQCC_FAILED and ReasonCode MQRC_WRITE_VALUE_ERROR.

Defined in: MQMessage class

Syntax:
Call MQMessage.WriteUInt2(value& )

Parameter value& Long. Value to be written.

WriteUnsignedByte method

This method takes a signed 2-byte integer value and writes it into the Message Data buffer as a 1-byte unsigned binary number starting at the character referred to by DataOffset. It replaces any data already at these positions in the buffer, and extends the length of the buffer (MQMessage.MessageLength) if necessary.

DataOffset is incremented by 1 if the method succeeds.

The value specified should be in the range 0 to 255. If it is not the method returns with CompletionCode MQCC_FAILED and ReasonCode MQRC_WRITE_VALUE_ERROR.

Defined in:
MQMessage class

Syntax:
Call MQMessage.WriteUnsignedByte(value%)

Parameter value% Integer. Value to be written.

WriteUTF method

This method takes an ActiveX string and writes it into the message data buffer at the current position in UTF format. The data written consists of a 2-byte length followed by the character data. DataOffset is incremented by the length of the string if the method succeeds.

Defined in:
MQMessage class

Syntax:
Call MQMessage.WriteUTF(value$)

Parameter:
value$ String. Value to be written.



© IBM Corporation 2002. All Rights Reserved