on convert_pc_to_mac
-- this handler
-- converts pc notepad files to mac simpletext
-- (strips first "rectangle" char off each line when neccesary).
-- works like this:
-- gets text from the file, fixes it, deletes the origina filel,
-- then recreates a new one with the same name,
-- and dumps the fixed text into it, and makes it
-- openable by simpletext.
-- Loren Mork, Seattle, Wa. Lmork@aol.com
-- v 1.0 1998
-- variables used:
-- filetofix
-- type:string
-- the name of the file we chose to fix
-- also used to name the new file
-- (since the old one is erased)
-- Fileio_obj
-- type:object
-- holds the instance of the fileio xtra
-- instantiate the object
set Fileio_obj = new(xtra"fileio")
-- open the dialog box
-- get the name of the file that should be fixed
-- put that filename into variable called filetofix
set fileToFix = displayopen (Fileio_obj)
-- open the file
openfile (Fileio_obj, fileToFix, 0)
-- read the file into a local variable
set FileContents = readfile (Fileio_obj)
-- clear the text field that the variable will go into
put "" into field "textfield"
-- put the variable into a text field
put FileContents into field "textfield"
-- Grab the number of lines in the new text field
put the number of lines of field "textfield" into linecount
-- delete the first character of the line if it is a "box"
-- if it is not, do nothing
repeat with counter = 1 to linecount
if char 1 of line counter of field "textfield" = numtochar(10) then
delete char 1 of line counter of field "textfield"
end if
end repeat
-- delete the source file
delete (fileio_obj)
--create a new file
createfile (fileio_obj, filetofix)
-- if mac then make it teachtext compatible
if getfinderinfo(fileio_obj) <> "TEXT ttxt" and the machinetype <> 256 then
setfinderinfo(fileio_obj, "TEXT ttxt")
end if
-- open the new file
openfile (Fileio_obj, fileToFix, 0)
--write a new file with the same name as the old
writestring (Fileio_obj, the text of field "textfield" & RETURN)
-- close the file
closefile (Fileio_obj)
-- dispose of the variable holding the object
set Fileio_obj = void
end