PA_SetStringInArray


version 2003


PA_SetStringInArray (array; index; newString)

Parameter Type Description
array PA_Variable Array to access
index long Index of the element to access
newString char * New value for the index element of array

Description

The routine PA_SetStringInArray sets the index element of the string array array to newString .

If array is not a eVK_ArrayString or if index is out of range, the routine does nothing.

By default, PA_SetStringInArray expect newString to be a C string. If you have called PA_UsePStrings previously, PA_SetStringInArray will expect newString to be a Pascal string.

By default, PA_SetStringInArray expect newString to use Macintosh characters on Macintosh and ANSI characters under Windows. If you have called PA_UseMacCharacters or PA_UseAnsiCharacters previously, PA_SetStringInArray will expect newString to use the specified characters set.

WARNING

In regards to the string size definition of the array, be sure not use a source string that is too long as this may overlap the next element.

Example

Initialize every element of a string array to a special value.

   // (Using C strings under Windows)
   void FillStringArrayWith(PA_Variable arr, char *s)
   {
      long   count, i;
      char   string[256];
      short   maxSize, srceSize;
 
   // Reduce the sting if necessary
      srceSize = strlen( s );
      maxSize = PA_GetArrayStringSize( arr );
      if ( srceSize > maxSize )
      {
         PA_MoveBlock( s, string, maxSize );
         string[ maxSize ] = 0;
      }
      else
         PA_MoveBlock( s, string, srceSize +1 );
 
      count = PA_GetArrayNbElements(arr);
      for(i = 1; i <= count; i++)
         PA_SetStringInArray( arr, i, string );
   }

See Also

PA_GetStringInArray .

Error Handling

None.