FindResourceIndex
Size = FindResourceIndex(Index)
 
Parameters:

    Index = The Index of the resource in the internal resource buffer
Returns:

    Size = The Size (in bytes) of the resource
 

     The FindResourceIndex function searches the internal resource buffer for a file that's been previously bound to the program executable at compile time using the #AddResource directive. If successful, the FindResourceIndex function returns the index of the resource buffer (ranging from 0 to GetResourceQuantity). You can then find the pointer and size of the buffer using functions GetResourcePtr,GetResourceSize. If the file isn't in the resource buffer, the function will return -1.



FACTS:


      * FindResourceIndex will return -1 if the resource doesn't exist.

      * Resources can be an alternative to using DATA statements.

      * For more information about resource binding see the #AddResource directive.



 
Example Source: Download This Example
  // Attach this file from the common media folder in the help
  // files, which is located two folders down from where this
  // example is stored.
  #AddResource "..\..\Media/Hello-World.txt"
  
  // Search for a bound resource using the same file name
  Index=findresourceindex("..\..\Media/Hello-World.txt")
  
  // If the resource was found it's index will be 0 or higher
  If Index>-1
     
     // Display information about this resource
     Print "Resource Found"
     
     Address     =getresourceptr(Index)
     Size          =getresourcesize(Index)
     
     Print "Address In Memory:"+Str$(Address)
     Print "Size:"+Str$(Size)+" bytes"
     
     // Since we know this is a text resource
     // next we'll read these bytes into a string
     // using peekstring
     s$=PeekString(Address,Size)
     
     // Now we'll split this string into an array to display it
     Dim Rows$(0)
     
     // remove any ASC chr 13 from the string
     s$=Replace$(s$,Chr$(13),"")
     
     // split the string on the ASC II chr 10
     RowCount=SplitToArray(s$,Chr$(10),Rows$())
     
     // Display the rows of this text file
     For lp =0 To RowCount-1
        Print Rows$(lp)
     Next
     
  EndIf
  
  
  // DIsplay the number of bound resources in memory
  Print "Number OF Resources #"+Str$(getresourcequantity())
  
  Sync
  WaitKey
  
  
  
  
  
 
Related Info: #AddResource | Data | GetResourcePtr | GetResourceSize | PeekByte | PeekInt :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com