CRLF vs CR&LF

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Krynn
Posts: 10
Joined: Thu Jul 05, 2012 1:11 am

CRLF vs CR&LF

Post by Krynn » Thu Dec 28, 2017 11:22 pm

Good morning. Hello,

I'm looking to get the preview of Windows files.
To do this inside the file, I found the text to recover. It's start by "PNG" and ended by "IEND".

So I open the file with "open" I read it with "read" and close it with "close". I put "it" in a variable. I search for PNG and IEND and remove what is before and after. And I recreate a PNG file with this content. The concern is that when I put this in a variable, Livecode doesn't differentiate between "CRLF","LF" and "CR" at the end of the line. He puts it all in "CRLF". And as with every line, it's never the same, sometime "CR" and sometime "LF". It is almost impossible for me to change it automatically.

I also tried another approach. A full copy of the file with "revCopyFile", but in this case I can't delete the text before and after.

I'm in a dead end.
Do you have an idea or a solution to get me out of here?

Is there another way to get the preview?
Is it possible to force livecode to keep the "LF" and "CR" in a variable?
How do I delete text in a file without using a variable?


Thank you in advance
Krynn

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm
Location: McKenna, WA

Re: CRLF vs CR&LF

Post by quailcreek » Thu Dec 28, 2017 11:44 pm

Looks line your trying to open a binary file. Look up "binfile" in the dictionary and see if that helps.
Tom
MacBook Pro OS Mojave 10.14

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: CRLF vs CR&LF

Post by bwmilby » Fri Dec 29, 2017 1:02 am

The constants return, CR, and LF are all ASCII 10. The constant CRLF is ASCII 13 + ASCII 10. There is no constant for the carriage return character alone (ASCII 13).

When opening text files, LiveCode will convert everything to LF internally. On Windows, when writing a text file out it will convert the line separators to CRLF. On Mac it will use CR (ASCII 13) and on Linux it will use LF.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

Krynn
Posts: 10
Joined: Thu Jul 05, 2012 1:11 am

Re: CRLF vs CR&LF

Post by Krynn » Fri Dec 29, 2017 2:04 am

quailcreek wrote:
Thu Dec 28, 2017 11:44 pm
Looks line your trying to open a binary file. Look up "binfile" in the dictionary and see if that helps.
I had also tried 2 or 3 things with binfile but I didn't succeed.
I insisted and in 3 lines of code, it works.

thank you :D
Krynn

for tips

Code: Select all

get URL "binfile:C:/path/namefile.xxx"
put it into lVariable
........
put lVariable into URL "binfile:C:/path/namefile.yyy"

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”