# ReplyMsg

Sends a reply to a message.

### Synopsis

`Err ReplyMsg( Item msg, int32 result, const void *dataptr,int32 datasize )`

### Description

This procedure sends a reply to a message.

When replying to a message, send back the same message item you received. (Think of this as sending a reply in the same envelope as the original letter.) Note that you must include a result code (which you provide in the result argument).

The meanings of the dataptr and datasize arguments depend on the type of the original message. (You can find out what type of message it is by looking at its msg.n_Flags field. If it is a small message, the value of the field is MESSAGE_SMALL. If it is a buffered message, the value of the field is MESSAGE_PASS_BY_VALUE.)

- If the original message was a small message, the dataptr and datasize are put in the corresponding fields of the message as eight bytes of data.
- If the original message was a standard message, these refer to a data block that your task allocates for returning reply data. For standard messages, the sending task and the replying task must each allocate their own memory blocks for message data. If the message was also buffered, the data is copied into the internal buffer of the message.

### Arguments

msg
  The item number of the message. Note: The reply message item must be same message item that was received.

result
  A result code. This code is placed in the msg_Result field of the message data structure before the reply is sent. Note: There are no standard result codes currently defined; the code must be a value whose meaning is agreed upon by the calling and receiving tasks. In general, you should use negative values to specify errors and 0 to specify that no error occurred.

dataptr
  See the "Description" section above for a description of this argument. If the message is not buffered, set this to 0.

datasize
  See the "Description" section above for a description of this argument. If the message is not buffered, set this to 0.

### Return Value

The procedure returns 0 if the reply was sent successfully or an error code if an error occurs.

### Implementation

SWI implemented in kernel folio V20.

### Associated Files

msgport.h
  ANSI C Prototype

### Notes

Most programs handle only one type of message per message port. Each type of message moves information in a different way; programs choose a particular message type to meet their specific needs.

### See Also

``GetMsg`(), GetThisMsg(), ReplySmallMsg(), SendMsg(), SendSmallMsg(), WaitPort()`

#