|
|
Read Text From File into Member w/ open dialog
Added on 2/15/2000
|
From Technote #3192 at Macromedia.com
on readFromFile
if objectP(myFile) then set myFile = 0 --Delete the instance if it already exists
set myFile = new(xtra "fileio") -- Create an instance of FileIO
if the machinetype = 256 then
setfiltermask (myfile, "All files,*.*,Text files,*.txt") -- set the filter mask (Win)
else
setfiltermask (myfile, "TEXT") -- set the filter mask (Mac)
end if
set fileName = displayOpen(myFile) -- display the "Open" dialog
if not voidP(filename) and not (filename = EMPTY) then
openFile(myFile, filename, 1) -- open file that user selected
if status(myFile) = 0 then
set theFile = readFile(myFile) -- Read the file into a Lingo variable
put theFile into field "myField" -- display the text in a field
else
alert error(myfile,status(myfile)) -- display error message
end if
end if
closeFile(myFile) -- Close the file
set myFile = 0 -- Dispose of the instance
end
|
|