PA_GetResourceNameList


version 2003


PA_GetResourceNameList (resFile; kind; nameList) → long

Parameter Type Description
resFile short File reference number of the file to access
kind unsigned long Kind (4 Bytes type) of resources
nameList char* List of resource names of a type
Function result long Number of names returned

Description

The routine PA_GetResourceNameList fills the buffer pointed to by nameList with all the resource names of type kind present in the file referenced by resFile , and returns the number of names.

IMPORTANT NOTE

PA_GetResourceNameList

returns the number of names, not the size of the buffer kindList .

kindList

is an array of char[32], starting at element 0 and ending at element (returned value - 1).

If resFile is invalid then there is no resource name for resources of type kind , PA_GetResourceNameList returns 0.

First call the routine passing 0L in kindList to get the count of kinds. Then, allocate a buffer of (thisCount * 32) and call the routine again.

Depending on default settings or on previous calls to PA_UsePStrings or PA_UseCStrings , nameList will be filled with a Pascal or an ANSI C string.

Example

Loading the name list of resource type 'toto'.

   long         count, i;
   char         *names, *oneName;
   #define kNAMES_LENGTH   ((char) 32)
 
   // First, call the routine with a null nameList to get the number of names
   count = PA_GetResourceNameList(resFile, 'toto', 0L);
   if(count)
   {
   // Then, allocate a buffer and call the routine again
      names = malloc(count * kNAMES_LENGTH);
      count = PA_GetResourceNameList(resFile, 'toto', names);
   // Do something with the names
      for(i = 0; i < count; i++)
      {
         oneName = &names[i];
      /* . . . do something with this name . . . */
      }
   }
 

See Also

PA_GetResourceName .

Error Handling

Use PA_GetLastError to see if an error occurred