From Mac OS X - Write file with CRLF

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
bobcole
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 175
Joined: Tue Feb 23, 2010 10:53 pm

From Mac OS X - Write file with CRLF

Post by bobcole »

Good citizens of the Talking Revolution Forum:
Using Mac OS X (10.5.8 PPC), I am trying to write a file with Windows (CRLF) line endings so I can pass it to another program that expects Windows (DOS) line endings. The dictionary says that Revolution automatically translates line endings and writes a file with the line ending that are appropriate for the computer platform; consequently, I find my file always has Mac endings (CR). I see that it is possible to write with a binary option that will avoid the translation but how do I get the LFs into the lines before a binary write operation?
As a work around, I created an AppleScript that tells TextWrangler to load the Mac file (CR) from disk, change the line endings to DOS (CRLF) and then save it. That works but it is a bit of kludge.
I am curious if there is a more direct method to creating a CRLF file.
Thanks in advance,
Bob
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10104
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: From Mac OS X - Write file with CRLF

Post by FourthWorld »

replace cr with crlf in tData
put tData into url ("binfile:"& tFile)
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
bobcole
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 175
Joined: Tue Feb 23, 2010 10:53 pm

Re: From Mac OS X - Write file with CRLF

Post by bobcole »

Richard:
That worked. As usual with Rev, many things are easier than they seem at first.
Thank you,
Bob
Post Reply