Sign in to follow this  
Followers 0
Mingre

Please differentiate @CR, @LF and @CRLF

4 posts in this topic

#1 ·  Posted (edited)

1. What the acronyms mean. Correct me if I'm wrong, CR - Carriage Return, LF - Line Feed, and CRLF - combination of the two.

2. When do I use which one. I did a simple test but failed to find out the differences among those three.

ConsoleWrite("CR - Four" & @CR)
ConsoleWrite("LF - Four" & @LF)
ConsoleWrite("CRLF - Four" & @CRLF)

ConsoleWrite( "CR " & StringLen(@CR) & @LF)
ConsoleWrite( "LF " & StringLen(@LF) & @LF)
ConsoleWrite( "CRLF " & StringLen(@CRLF) )

And the result was (and perhaps there's no sense posting it here since most, if not all, of you already know the output):

CR - Four
LF - Four
CRLF - Four
CR 1
LF 1
CRLF 2

I don't see any differences at all, save for the last part in which @CRLF amounts to 2 characters!

Again, I apologize should you find this question trivial.

Thanks! (I already checked the Help File but can't make a sense out of it. So please write while thinking you're instructing a non-programmer. Once again, thanks!)

Edited by Lilbert

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi Lilbert,

the line endings (used) to be different with all the operating systems. UNIX uses @LF to mark a line end, WINDOWS @CRLF (I think MAC and @CR). So if you use Notepad you'll see that some of the line ends are not recognized.

As you use @CRLF it creates two characters and that's by design. You could replace @CRLF with a "@CR & @LF".

So for your question: When you want to work with the files in Windows use @CRLF. :unsure:

Edited by Hannes123

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

Hi Lilbert,

the line endings (used) to be different with all the operating systems. UNIX uses @LF to mark a line end, WINDOWS @CRLF (I think MAC and @CR). So if you use Notepad you'll see that some of the line ends are not recognized.

As you use @CRLF it creates two characters and that's by design. You could replace @CRLF with a "@CR & @LF".

So for your question: When you want to work with the files in Windows use @CRLF. :unsure:

LOL, thanks. My AutoIT project doesn't deal too much with working with Windows files so perhaps that's why I barely notice the difference. I used @LF and @CRLF interchangeably when I want to put line breaks in msgboxes, tooltips, traytips, etc.

Share this post


Link to post
Share on other sites

In addition to what Hannes said:

The Scite console is quite smart to figure that you want a single line break in all cases you tested.

Most recent and all decent text editors allow you to use any line break combination.

BUT you need to check the other applications which will be using the text files you produce or modify and verify they don't behave unexpectedly when they encounter line-terminations distinct from what they expect.

As a general rule of thumb, Hannes advice to stick with @CRLF in Windows context is a safe bet.

FYI those names come from the times when typewriter devices (Google for LA36 for instance) were used before CRT terminals appeared (and long after them!). CR meant exactly that: make the print head return to home (leftmost position) and LF caused the paper to advance one line, without moving the print head. So the combination of both was actually required to skip to the home position of a new line. The operator however never had to hit two keys to do that, just hit Return, which was internally translated into either LF or CR (depending on the underlying system) and understood by the terminal driver as a request to "print" CRLF.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0