Thanks Mischa & Thorsten1867 - this is an interesting lib for me. I've been trialling this v4 lib for a project, and I found a subtle issue (bug?) in FindPackFile().
Here's my situation. I have a pack file of containing a lot of images - e.g. in this order (most are omitted, what is shown are the important ones for this issue) -
quit-dn.png
.
.
t-dn.png
When I was trying to find 'T-dn.png' using:
Code: Select all
packID = FindPackFile("T-dn.png",0)
I was always getting the 'quit-dn.png' id returned. Looking at the FindPackFile code, I could understand why (the FindString would pass for the case of 't-dn.png' & 'quit-dn.png' since both have the same substring). To fix this I changed the FindPackFile code from:
Code: Select all
Procedure FindPackFile(name.s,startid)
element=SelectElement(PackItem(),startid)
filefound=-1
While element And filefound=-1
If FindString(LCase(PackItem()\name),LCase(name),1)
filefound=ListIndex(PackItem())
EndIf
element=NextElement(PackItem())
Wend
ProcedureReturn filefound
EndProcedure
to
Code: Select all
Procedure FindPackFile(name.s,startid)
element=SelectElement(PackItem(),startid)
filefound=-1
While element And filefound=-1
If FindString(LCase(PackItem()\name),LCase(name),1) = 1
filefound=ListIndex(PackItem())
EndIf
element=NextElement(PackItem())
Wend
ProcedureReturn filefound
EndProcedure
which works for me. Not sure if that was the best solution (or if I used the function correctly - in that case, please let me know). I report this just in case someone else comes across this issue. Thanks again.