DosPutMessage: Difference between revisions
Appearance
Created page with "==Description== Sends a message to an output file or device. ==Syntax== <PRE> #define INCL_DOSMISC #include <os2.h> HFILE hfile; /* The handle of the output file or de..." |
mNo edit summary |
||
| Line 7: | Line 7: | ||
#include <os2.h> | #include <os2.h> | ||
HFILE hfile; /* | HFILE hfile; /* The handle of the output file or device. */ | ||
ULONG cbMsg; /* | ULONG cbMsg; /* The length, in bytes, of the message to be sent. */ | ||
PCHAR pBuf; /* | PCHAR pBuf; /* The buffer that contains the message to be sent. */ | ||
APIRET ulrc; /* | APIRET ulrc; /* Return Code. */ | ||
ulrc = DosPutMessage(hfile, cbMsg, pBuf); | ulrc = DosPutMessage(hfile, cbMsg, pBuf); | ||
</PRE> | |||
==Parameters== | ==Parameters== | ||
; hfile (HFILE) - input : The handle of the output file or device. | ;hfile (HFILE) - input : The handle of the output file or device. | ||
;cbMsg (ULONG) - input : The length, in bytes, of the message to be sent. | |||
; cbMsg (ULONG) - input : The length, in bytes, of the message to be sent. | ;pBuf (PCHAR) - input : The buffer that contains the message to be sent. | ||
==Return Code== | ==Return Code== | ||
ulrc (APIRET) - returns | ulrc (APIRET) - returns | ||
DosPutMessage returns one of the following values: | DosPutMessage returns one of the following values: | ||
* 0 NO_ERROR | |||
* 6 ERROR_INVALID_HANDLE | |||
* 19 ERROR_WRITE_PROTECT | |||
* 87 ERROR_INVALID_PARAMETER | |||
* 321 ERROR_MR_UN_PERFORM | |||
==Remarks== | ==Remarks== | ||
DosPutMessage sends a message that is currently in a buffer to an output file or device. | DosPutMessage sends a message that is currently in a buffer to an output file or device. | ||
| Line 74: | Line 72: | ||
return NO_ERROR; | return NO_ERROR; | ||
} | } | ||
</PRE> | |||
==Related Functions== | ==Related Functions== | ||
* [[ | * [[DosGetMessage]] | ||
* [[ | * [[DosInsertMessage]] | ||
* [[ | * [[DosQueryMessageCP]] | ||
[[Category: | [[Category:Dos]] | ||
Revision as of 15:19, 6 December 2016
Description
Sends a message to an output file or device.
Syntax
#define INCL_DOSMISC #include <os2.h> HFILE hfile; /* The handle of the output file or device. */ ULONG cbMsg; /* The length, in bytes, of the message to be sent. */ PCHAR pBuf; /* The buffer that contains the message to be sent. */ APIRET ulrc; /* Return Code. */ ulrc = DosPutMessage(hfile, cbMsg, pBuf);
Parameters
- hfile (HFILE) - input
- The handle of the output file or device.
- cbMsg (ULONG) - input
- The length, in bytes, of the message to be sent.
- pBuf (PCHAR) - input
- The buffer that contains the message to be sent.
Return Code
ulrc (APIRET) - returns
DosPutMessage returns one of the following values:
- 0 NO_ERROR
- 6 ERROR_INVALID_HANDLE
- 19 ERROR_WRITE_PROTECT
- 87 ERROR_INVALID_PARAMETER
- 321 ERROR_MR_UN_PERFORM
Remarks
DosPutMessage sends a message that is currently in a buffer to an output file or device.
Screen width is assumed to be 80 characters. If a word would go past column 78, it is moved to the beginning (column 1) of a new line.
DosPutMessage assumes that the starting cursor position is column 1 when handling a word wrap. If the last character to be positioned on a line is a double-byte character, the character is not bisected.
Example Code
This example sends a message to the output file "MYMSG.DAT", automatically wrapping if necessary.
#define INCL_DOSFILEMGR /* File Manager values */
#define INCL_DOSMISC /* Miscellaneous values */
#define INCL_DOSERRORS /* DOS Error values */
#include <os2.h>
#include <stdio.h>
#include <string.h>
int main(VOID) {
HFILE FileHandle = NULLHANDLE; /* File handle */
ULONG ulAction = 0; /* Action taken by DosOpen */
UCHAR uchDataArea[160] = ""; /* Message buffer */
APIRET rc = 0; /* Return code */
rc = DosOpen ("MYMSG.DAT", &FileHandle, &ulAction, 120L, FILE_ARCHIVED,
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYREADWRITE |
OPEN_ACCESS_READWRITE, 0L);
strcpy (uchDataArea, "This is a sample message that is going to be written ");
strcat (uchDataArea, "to the message file. It is longer than 80");
strcat (uchDataArea, " characters, so it should wrap. ");
rc = DosPutMessage(FileHandle, strlen(uchDataArea), uchDataArea);
if (rc != NO_ERROR) {
printf("DosPutMessage error: return code = %u\n", rc);
return 1;
}
rc = DosClose(FileHandle);
return NO_ERROR;
}