Function _parc() Foundation

Copies a character string parameter into the passed buffer.

Syntax
ULONG _parc(CHAR* cBuffer, ULONG ulSize,
            XppParamList pList, ULONG ulIndex, ...);
Parameters
CHAR *pcBuffer
Pointer to the buffer into which the character string is to be copied. A NULL character always terminates the character string. Note:Character strings in Xbase++ can also contain NULL characters.
ULONG ulSize
Size of the passed buffer. The copied character string contains a maximum of <ulSize>-1 characters.
XppParamList pList
Pointer to the Xbase++ parameter list, which is used to provide access to the parameter.
ULONG ulIndex
Position of the parameter from which the character string is to be copied (first position is 1).
...
The remaining arguments must be of ULONG type and are considered only when the parameter <ulIndex> is an array. In this case, an index is specified for each array dimension in order to specify the element from which the character string is to be copied. note:The end of an array index list must be indicated by incorporating a NULL as the last value in the list.
Return

Returns the number of characters actually copied (maximum is the value of <ulSize>). When the parameter or the indexed array element is not a character string, NULL is returned and the buffer is not changed.

Description

_parc() makes it possible to access a character string which was passed as a parameter from Xbase++. The caller must make a buffer available into which the character string is copied. The character string is truncated if the buffer is not large enough. In any case, a NULL character is written into the buffer after the character string. The return value indicates the number of characters actually copied (maximum of <ulSize> - 1 characters).

To modify the data in a parameter, storc() is used. To avoid copying or if the character strings are very long, an Xbase++ character string can also be accessed directly through the container API.

A 'static' array should not be used for the buffer. Since Xbase++ can use several threads internally, each function can be active in multiple threads simultaneously. Because the length of character strings is variable, it is also recommended that the buffer will be dynamically allocated. The C functions malloc() and free() may be used, but it is better to request the memory through the memory API since this better prevents memory fragmentation.

Examples
/* 
Copies the first 10 characters of a character string. 
*/ 
#include <xpppar.h> 

ULONG   len; 
CHAR    buffer[10]; 
                             /* Is the second parameter a string? */ 
if ( XPP_IS_CHAR( _partype(<pList>, 2) ) ) 
{                               /* copy the string */ 
len = _parc(buffer, sizeof(buffer), <pList>, 2); 
} 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.