Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

chr(13)+chr(10) -- CR+LF

Status
Not open for further replies.

JoeyDC

Programmer
Mar 24, 2013
18
US
I saw some code the other day in this forum where the programmer printed the second line of a MESSAGEBOX() by using just "<string>"+chr(13)+<"string>".

I have always seen this done by using "<string>"+chr(13)+chr(10+"<string>"), instead of chr(13) alone. So I had to try it for myself, and it worked. Are there any places(situations) whereby the use of chr(13)+chr(10) would be required?

P.S. For you purists - I know that a either literal string or a variable could be used. [bigsmile]
 
Actually for a Messagebox() I have never needed to have the CHR(10) at all.

Give it a try...
Code:
cMessageTitle = 'MessageBox Test'
cMessageText = 'Line #1';
   + CHR(13);
   + 'Line #2';
   + CHR(13);
   + 'Line #3'
* --- OK Button Only ---
nDialogType = 0 + 48 + 0
* --- Yes/No Buttons ---
*nDialogType = 4 + 32 + 256

nAnswer = MESSAGEBOX(cMessageText, nDialogType, cMessageTitle)

Good Luck,
JRB-Bldr


 
Joey,

The answer really depends on where the string is going to end up being displayed.,

As you have discovered, in the case of a message box, you can use either CR + LF, or just CR; you can even have LF on its own, or even LF + CR.

But with a wait window, you must have either CR or CR + LF; the other combinations don't work.

When it comes displaying text in text editors or word processors, FoxPro is generally quite permissive in which combinations it allows, but other programs might not be. I generally use CR + LF, as that seems to be universally accepted (at least, in the Windows world). But it's always worth experimenting.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
The origin of CR and LF (and the combination of the two) is the old line printers. CR returns the printhead to the beginning of the current line, and LF moves to the next line.

As printers became more digital and less mechanical interpretations varied but most printers will not allow a CR alone so they add the LF automatically. Software followed along with roughly the same consistency.

Operating systems vary as well. In the Windows world, end of line is usually CRLF. In the *nix world, it's just LF.

The only real answer to your question is "it depends".
 
Thanks, guys. I knew someone would know the answer.
 
Dan said:
The origin of CR and LF (and the combination of the two) is the old line printers

Dan,

Just to be ultra-pernickity (if that's the right word):

The origins of CR and LF is not line-printers, but teletypes. A line-printer, by definition, always prints an entire line at a time and has no need for control characters of any kind. It knows when it reaches the end of the line because there's no more data in the buffer.

A teletype, on the other hand, prints one character at a time. The print-head is stationary and the carriage moves. It is the carriage that responds to CR, LF and other control codes (hence the term carriage-return). The teletype is also the origin of such control codes as EOT (end of transmission), ACK (acknowledge) and BELL (good old CHR(7), used to attract the attention of the remote operator).

No doubt this is more than you (or anyone else) wants to know, but it's Sunday morning, and there's nothing else interesting to write about.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
>It it's Sunday morning, and there's nothing else interesting to write about.

While I doubt that, that's one of the best reasons for something done out of the kind of boredom, which results of nothing better to be done, I've read in quite a time.
I wish you a very nice restful weekend.

Bye, Olaf.
 
That's right, Mike, and I knew it too. I came into the workforce just in time to see the teletype (and the teletype operator) retire, replaced by the newfangled "telefax". But the memory of those days are a little hazy at times.
 
Wouldn't be the first time the US and UK have minor differences. Took me a while a few years ago to realize the "whinging" was British for the US "whining."

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top