Jump to content

DosPutMessage: Difference between revisions

From EDM2
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..."
 
Ak120 (talk | contribs)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Description==
Sends a message to an output file or device.
Sends a message to an output file or device.


==Syntax==
==Syntax==
<PRE>
DosPutMessage(hfile, cbMsg, pBuf)
#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);
</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.


; 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:
*0  NO_ERROR
*6  ERROR_INVALID_HANDLE
*19  ERROR_WRITE_PROTECT
*87  ERROR_INVALID_PARAMETER
*321 ERROR_MR_UN_PERFORM


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 36: Line 22:
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.
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.  
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==
==Example Code==
Line 74: Line 60:
return NO_ERROR;
return NO_ERROR;
}
}
</PRE>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosGetMessage|DosGetMessage]]
* [[DosGetMessage]]
* [[OS2 API:CPI:DosInsertMessage|DosInsertMessage]]
* [[DosInsertMessage]]
* [[OS2 API:CPI:DosQueryMessageCP|DosQueryMessageCP]]
* [[DosQueryMessageCP]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 22:54, 5 February 2024

Sends a message to an output file or device.

Syntax

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;
}

Related Functions