Bruce Epstein - Zeus Productions wrote
> How large a list? Certainly, I've never created 1000 text files with it
> inside a loop.
>
>> This has happened quite
>> consistently over the years (Different versions of Director, MacOS - most
>> recently, MacOS 9.0.4 and D7, FileIO 7.0.2r85 - I think it was). I was told
>> years ago that there was a memory leak with FileIO and that it 'was a known
>> problem' about creating several files within a repeat loop - and my
>> experiences seemed to confirm this. I've never really bothered to verify the
>> claim, happy with workarounds that work fine (such as writing the files out
>> on stepframe or some other threaded system). If you've never heard of the
>> problem, then it may well be a furphy.
>
> Furphy? I suspect that if you don't give director a chance to do garbage
> collection, it could become an issue. Are you repeatedly instantiating the
> instance or using a single instance throughout? I'd recommend the latter.
Hi Bruce,
I just dug up an old project that would crash everytime I would try and save
out the various 'stories' in a repeat loop. 327 of them, 500-2000 words
each. I went through the FileIO code to give it proper scrutiny.
Interestingly, if I took out my error checking code, then it would work fine
(either repeatedly instantiating the fileIO xtra, or with a single
instance). Heres a method (from a parent script).
on mWriteBatch_Mac me, pFileList, pDirectoryPath
fObj = xtra("fileIO").new()
mx = pFileList.count
repeat with i = 1 to mx
thisFilePath = pDirectoryPath & pFileList.getPropat(i)
thisFileText = pFileList[i]
--
fObj.createFile(thisFilePath)
fObj.openFile(thisFilePath, 0)
fObj.writeString(thisFileText)
fObj.setFinderInfo("TEXT R*ch")
fObj.closeFile()
end repeat
fObj = 0
end
Then I put back I put back the error checking code to see what was causing
the crash, then noticed that I was opening the newly created file in "read
only" mode -- ie
fObj.openFile(thisFilePath, 1)
It would work fine if I didnt check for errors, though.
Anyway, opening the file in read write, and doing error checks now seems to
work fine. I guess I shouldn't have given up so early and accepted the
advice that there was a big memory leak in FileIO creating files.
on mWriteBatch_Mac me, pFileList, pDirectoryPath
fObj = xtra("fileIO").new()
mx = pFileList.count
repeat with i = 1 to mx
thisFilePath = pDirectoryPath & pFileList.getPropat(i)
thisFileText = pFileList[i]
--
fObj.createFile(thisFilePath)
errFound = me.mCheckIOerror(fObj)
if errFound then exit
fObj.openFile(thisFilePath, 0)
errFound = me.mCheckIOerror(fObj)
if errFound then exit
fObj.writeString(thisFileText)
errFound = me.mCheckIOerror(fObj)
if errFound then exit
fObj.setFinderInfo("TEXT R*ch")
errFound = me.mCheckIOerror(fObj)
if errFound then exit
fObj.closeFile()
errFound = me.mCheckIOerror(fObj)
if errFound then exit
end repeat
fObj = 0
end
on mCheckIOerror me, pObjRef
errMsg = 0
if voidP(pObjRef) then
errMsg = "No valid instance of fileio Xtra"
else
errNum = pObjRef.status()
if errNum <> 0 then
errStr = pObjRef.error(errNum)
errMsg = errStr & "(Error " & errNum & ")"
end if
end if
if stringP(errMsg) then
alert errMsg
return 1
else return 0
end
> Furphy?
"Furphy" (Colloq) = a fabrication or misleading story, a bit like an 'urban
myth'.
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]