Date: Mon, 17 Feb 1997 23:46:56 -0800
From: Doug Smith
Subject: Re: help on fileio.dll (XTRAS)
> I've Director 5.0 on Win95 and iam trying to learn how to call extras. So i
> opened the Message window and typed Showxlib. It listed a set of extras
> alongwith "fileio". Later i gave the command : fileio(mdescribe).
>
> It gives me an error message saying "Script Error..Handler not defined"...
It sounds like you have the Xtra version of FileIO loaded, and
need to use Xtra syntax. To get the equivalent of the old mDescribe
with an Xtra, use:
mMessagelist(xtra "fileIO")
Here's a lingo function that copies the contents of one text file
into another. I wrote it tonight. It shows how to open files,
create them, check for some errors, read the contents of a file,
write a file, etc. (Sorry for the long Lingo handler for those
who are opposed to such things ... but I think that's what DIRECT-L
is for.)
on copyTextFile mySourceFile, myDestFile
-- mySourceFile and myDestFile must be full paths
-- to valid files.
set tFileIOName = "fileio"
if not(doesXtraExist(tFileIOName)) then
alert("The FileIO Xtra could not be found in the Xtras directory.")
abort
end if
set tFileIO=new(xtra tFileIOName)
if not(objectP(tFileIO)) then
-- problem loading fileio
alert("Problem creating an instance of FileIO.")
abort
end if
openFile(tFileIO, mySourceFile, 1)
if status(tFileIO) <> 0 then
-- error opening file
alert("Problem opening the file: " & mySourceFile)
abort
end if
set tString = readFile(tFileIO)
closeFile(tFileIO)
createFile(tFileIO, myDestFile)
set tStatus = status(tFileIO)
if error(tFileIO,tStatus) = "File already exists" then
-- problem creating file ... it exists so delete it
openFile(tFileIO, myDestFile, 0)
delete(tFileIO)
closeFile(tFileIO) -- just to make sure
createFile(tFileIO, myDestFile)
set tStatus = status(tFileIO)
end if
if tStatus <> 0 then
-- problem creating file
alert("Problem creating the new file: " & myDestFile)
abort
else
closeFile(tFileIO)
openFile(tFileIO, myDestFile, 0)
writeString(tFileIO, tString)
closeFile(tFileIO)
end if
end copyTextFile
------------------------
on doesXtraExist myXtraName
set tFoundXtra = FALSE
repeat with i = 1 to the number of xtras
if the name of xtra i = myXtraName then
set tFoundXtra = TRUE
exit repeat
end if
end repeat
return tFoundXtra
end doesXtraExist
------------------------