Hi all,
What's up with my code?
If I run this quick test, the Test.dat file length is zero.
Please note that I purposely exited the loop so that I could
see if the function was working... it is. Why is Test.dat
zero length? Boggling my mind!
here's the code:
Code:
#COMPILE DLL "c:\windows\system\pbSearch.dll" GLOBAL sContents AS STRING ' read the files FUNCTION sOFile(sFilename$) AS LONG LOCAL hFile AS LONG OPEN sFilename$ FOR BINARY AS #1 sContents$ = SPACE$(LOF(1)) GET #1, , sContents$ CLOSE #1 IF LEN(sContents$) THEN sOFile = 1 ELSE sOFile = 0 END FUNCTION ' Copy files to Test.dat FUNCTION sCFile(sPathname$) EXPORT AS LONG LOCAL hFile AS LONG LOCAL sBuf AS STRING LOCAL sFile AS STRING LOCAL sPath AS STRING LOCAL sType AS STRING sPath$ = sPathname$ IF RIGHT$(sPath$,1) <> "\" THEN sPath$ = sPath$ & "\" sType$ = sPath$ & "*.txt" sFile$ = DIR$(sType$) hFile = FREEFILE OPEN "c:\test.dat" FOR BINARY AS #hFile DO sFilename$ = sPath$ & sFile$ IF sOFile(sFilename$) THEN IF LEN(sBuf$) < 5120000 THEN sBuf$ = sBuf$ & sContents$ sFile$ = DIR$ ELSE PUT #hFile, , sBuf$ sBuf$ = "" EXIT DO ' exit early to check data 'sFile = Dir$ END IF ELSE sFile$ = DIR$ END IF LOOP UNTIL sFile$ = "" IF LEN(sBuf$)> 0 THEN PUT #1, , sBuf END IF FLUSH #hFile CLOSE #hFile sCFile = 1 END FUNCTION
Thanks in Advance!
Mike
Comment