Function _parc() Foundation
Copies a character string parameter into the passed buffer.
ULONG _parc(CHAR* cBuffer, ULONG ulSize,
XppParamList pList, ULONG ulIndex, ...);
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.
_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.
/*
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);
}
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.