Special

Clearance Sale!

We've been publishing for over five years now and it's time to clear out our inventory of back issues, so we're slashing prices!

RBD Magazines

Check out this amazing clearance sale of all our past issues. Missing some issues? This is a great time to complete your RBD collection. Save up to 40% off the regular price of our printed back issue packages. These prices are only good until the end of the year May 2008 and supplies are limited, so place your order today.

Article Preview


Buy Now

Print:
PDF:

Intel corner

End of the line

How to handle line endings correctly across platforms

Issue: 5.4 (May/June 2007)
Author: Christian Schmitz
Article Description: No description available.
Article Length (in bytes): 4,096
Starting Page Number: 44
RBD Number: 5417
Resource File(s): None
Related Link(s): None
Known Limitations: None

Excerpt of article text...

Overview

You may have seen the "endOfLine" keyword in REALbasic. Actually, it is a class with a global function returning the global endOfLine object. Because endOfLine is a class, you can write:

dim e as EndOfLine

e=new EndOfLine

MsgBox str(asc(e.Macintosh)) // shows "13"

The global function "EndOfLine as EndOfLine" will return to you an object of this endOfLine class. The object reference is cached so on each call you get the same endOfLine object. Now this endOfLine class has some operator methods which let you use it like a string. See this example:

MsgBox "Something interesting"+EndOfLine+EndOfLine+"which needs some details"

We just treat the endOfLine object returned by the endOfLine function as a string and add it to the message text passed to msgBox. Now if you do that the endOfLine object will be the platform dependent endOfLine string. On Linux it returns chr(10), on Mac OS chr(13), and on Windows chr(13)+chr(10).

In the Unix world (which is where Linux comes from), the line end character has always been chr(10), called LF or line feed. On Mac OS Classic the line end character is chr(13), called Carriage Return or just CR. The DOS operating . It uses CR and LF together. First it moves the printer header to the beginning of the printing line before shifting the paper a bit higher. Windows Vista still uses a line ending of CRLF.

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com