Re: Write to file - another question
Re: Write to file - another question
- Subject: Re: Write to file - another question
- From: Chris Nebel <email@hidden>
- Date: Tue, 27 Feb 2001 18:07:08 -0800
- Organization: Apple Computer, Inc.
email@hidden wrote:
>
This has to do with using a text file created on a Mac on a windows box. When I am writing to a file, and add a return to the end of a line like this
>
>
write return to file starting at eof
>
>
windows doesn't recognize that as a new line. Is there something other than or in addition to 'return' that will give you the new line in addition to the carriage return?
Windows' idea of a line break is a carriage return-line feed pair (as opposed to Mac OS, where it's just a carriage return, or Unix, where it's just a line feed. There are
-- or were -- real reasons for each choice, though they're all terrible.) It's easy enough to construct a Windows-style line break: just say "(ASCII character 13) & (ASCII
character 10)". At that point, you have a couple of choices. You can put that string into a variable or property, and change all your write calls, like this:
property line_break: (ASCII character 13) & (ASCII character 10)
write line_break to file starting at eof
Alternatively, you can take advantage of the fact that AppleScript built-in properties are writable, and do something like this:
-- somewhere in your script startup...
set return to (ASCII character 13) & (ASCII character 10)
-- later...
write return to file starting at eof
Yes, this is somewhat deviant, and if you plan on writing different line ending styles in the same script, I'd recommend something like Arthur's approach instead.
--Chris Nebel
AppleScript Engineering