Kerry Thompson wrote:
> Am I missing something simple here? I wrote a little utility to copy the
> script text out to text files, and it crashes my Mac on about the 15th
> iteration.
>
> on copyScripts castLibName, targetDir
> repeat with i = 1 to the number of members of castlib (castLibName)
> if member(i, castLibName).type = #script then
> theFile = 0
> theFile = new (xtra "fileio")
> theFileName = member(i, castLibName).name & ".txt"
> theText = member(i, castLibName).scriptText
> createFile(theFile, targetDir & theFileName)
> openFile(theFile, targetDir & theFileName, 0)
> writeString(theFile, theText)
> closeFile(theFile)
> end if
> end repeat
> end
>
> It's a movie script, and I'm calling it from the message window:
> copyScripts ("Scripts", "Freddy Kruger:In Development:HMProject:Scripts
> (Demo):")
>
> It successfully writes out about 20 files, then crashes to the debugger.
> Maybe I'm too tired.
it could be because the script instantiates the xtra on every iteration...
try moving the xtra instantiation code before the loop starts, and
set theFile = 0 after the loop finishes, so that only a single
instance of the xtra is used for all operations.
might also be worth errorchecking each operation with status(theFile)
before moving on to the next
regards,
Christian
----------------------------
Christian Wach
[EMAIL PROTECTED]
----------------------------
[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!]