|
![]() |
![]() |
version 2003
PA_GetArrayStringSize (array) → short
Parameter | Type | Description | |
array | PA_Variable | → | Array to access |
Function result | short | ← | Max size of one string element |
Description
The routine
PA_GetArrayStringSize
returns the maximum size that an element of the string array
array
can have.
Knowing the maximum size of a string is useful in preventing memory overlap when writing a string in an array. If the source string is too long, you will need to cut it.
If
array
is not a
eVK_ArrayString
, the routine returns 0.
Example
Truncate a string if it is too long to fit in the array.
void mySetArrayString( PA_Variable v, long idx, char *s )
{
short max = PA_GetArrayStringSize( v );
TruncateString( s, max );
PA_SetStringInArray( v, idx, s );
}
// generic truncation depending on String Settings
void TruncateString( char *s, short max)
{
if ( PA_GetUserStringKind() == eSK_CString )
{
if ( max < strlen(s) )
strlen[max + 1] = 0;
}
else
{
if ( s[0] > max )
s[0] = max;
}
}
Error Handling
None.