(Page 39 of 40 in this chapter)


vceWrite

Description

Writes data at the current position in the current message.

Prototype

DWORD vceWrite ( CTAHD ctahd,
BYTE
*buffer,
unsigned bytes,
unsigned insertmode,
unsigned *byteswritten)

ctahd Handle returned by ctaCreateContext.

buffer Pointer to a buffer of data to write.

bytes Amount of data to write.

insertmode VCE_OVERWRITE or VCE_INSERT.

byteswritten Pointer to the returned number of bytes written.

Return Values

Events

Details

This function copies the specified number of bytes of data from buffer to the current location in the current message in the context specified by ctahd, and returns the number of bytes of data written in byteswritten, unless byteswritten is NULL.

Set insertmode to VCE_OVERWRITE to replace existing data without changing the message size. In overwrite mode, if you attempt to write beyond the end of the current message, SUCCESS will be returned and the current position will be set to the end of the current message.

Set insertmode to VCE_INSERT to insert new data before the current position. If the current position is the end of the message, VCE_INSERT appends the new data to the current message. Inserting data to anywhere except the end of a message is allowed only on file types that support editing (currently only VOX files).

On completion, the current position will be after the inserted data for either insert mode.

The current position will be advanced by the amount written in millisecond units.

To convert between bytes and milliseconds, use vceGetContextInfo to get the frame size and frame time, then use the following formulas:

 milliseconds = (bytes / framesize) * frametime
 bytes = (milliseconds / frametime) * framesize

See Also

vceGetContextInfo, vceRead

Example


/* Append one message to another */

void myMsgCat (CTAHD ctahd, VCEHD destvh, unsigned destmsg,
VCEHD srcvh, unsigned srcmsg)
{
BYTE *buffer;
unsigned msec;
unsigned bytes;
unsigned byteswritten;

/* Read source message to memory - see example in vceRead */
myLoadMessage (ctahd, srcvh, srcmsg, &buffer, &msec, &bytes);

/* Seek to end of destination */
vceSetCurrentMessage (destvh, destmsg);
vceSetPosition (ctahd, 0, VCE_SEEK_END, NULL);

/* Append source message */
vceWrite (ctahd, buffer, bytes, VCE_INSERT, &byteswritten);

/* Release temporary buffer */
free (buffer);

if (byteswritten < bytes)
printf("Insufficient space");
return;
}


(Page 39 of 40 in this chapter)


tech_support@nmss.com
Copyright © 1999, Natural MicroSystems, Inc. All rights reserved.