TipcMsgSetNumFields


Name

TipcMsgSetNumFields — set the number of fields in a message

Synopsis

T_BOOL TipcMsgSetNumFields(msg, num_fields) 
T_IPC_MSG msg; 
T_INT4 num_fields; 

Arguments

msg — message to set number of fields for

num_fields — number of fields

Return Values

TRUE if the number of fields was successfully set for the message, FALSE otherwise.

Diagnostics

If TipcMsgSetNumFields fails, it returns FALSE and sets the global SmartSockets error number to one of:

Description

TipcMsgSetNumFields sets the number of fields in a message by truncating the message to the desired number of fields. If num_fields is 0, the message is completely emptied (the message data buffer is not changed, but any fields in the data buffer are lost). TipcMsgSetNumFields is useful for reusing messages, rather than continually destroying and creating messages.

Caution

There is no way to recover the old fields in a message after calling TipcMsgSetNumFields.

See Also

TipcMsgSetCurrent, TipcMsgTraverse

Examples

This example creates a message, appends fields, empties the message, and appends different fields:

T_IPC_MT mt; 
T_IPC_MSG msg; 
 
mt = TipcMtLookupByNum(T_MT_NUMERIC_DATA); 
if (mt == NULL) { 
  return;  /* error */ 
}  
 
msg = TipcMsgCreate(mt); 
if (msg == NULL) { 
  return;  /* error */ 
}  
if (!TipcMsgAppendStrReal8(msg, "speed_limit", 65.0)) { 
  return;  /* error */ 
}  
 
if (!TipcMsgSetNumFields(msg, 0)) { 
  return;  /* error */ 
}  
 
if (!TipcMsgAppendStrReal8(msg, "speed_limit", 35.0)) { 
  return;  /* error */ 
}  

TIBCO SmartSockets™ Application Programming Interface
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com