I'm using a lib compiled with MSVC++6 using Import..EndImport. I have tested all the functions in the lib, and they all work fine as long as they are not used within procedures. Once I put a call to a lib function inside a procedure I get some pretty odd behavior. Example:
(I'm sorry that I cannot provide a more useful code example because I'm not at liberty to distribute the .lib in question or to reveal my full source.)
Code: Select all
Import "mylib.lib"
MyFunction1(param$)
EndImport
Procedure test1(path$)
dir = ExamineDirectory(#PB_Any, path$, "")
If IsDirectory(dir)
While NextDirectoryEntry(dir)
MyFunction1(DirectoryEntryName(dir))
Wend
FinishDirectory(dir)
EndIf
EndProcedure
mypath$ = "D:\test"
test1(mypath$)
This extremely minimal example (generalized and simplified from my actual code) fails on NextDirectoryEntry(dir), saying that the directory is not initialized even though the call to IsDirectory(dir) passes. If I comment out the call to the lib function it works perfectly. I find this very strange. In other cases I have run into invalid memory access errors calling the lib functions ONLY when they are called within procedures. Is this a known problem or bug? Am I doing something wrong? I'm pulling my hair out over this!