Page 1 of 1

CRLF vs CR&LF

Posted: Thu Dec 28, 2017 11:22 pm
by Krynn
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

Re: CRLF vs CR&LF

Posted: Thu Dec 28, 2017 11:44 pm
by quailcreek
Looks line your trying to open a binary file. Look up "binfile" in the dictionary and see if that helps.

Re: CRLF vs CR&LF

Posted: Fri Dec 29, 2017 1:02 am
by bwmilby
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.

Re: CRLF vs CR&LF

Posted: Fri Dec 29, 2017 2:04 am
by Krynn
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"