#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2006
    Posts
    146
    Rep Power
    8

    Chr(10) and Chr(13)


    I'm stuck...

    # Chr(10) returns a linefeed character
    # Chr(13) returns a carriage return character

    I am writing to a text file and when I use either Chr(10) or Chr(13), I get data written on file on a new line however the difference I see is if (and that breaks my program) is Chr(10) returns 2 lines at the very end. It's very strange. When I use Chr(13) it returns only one line at the end which is perfect.

    Also, I read some post and suggests using both but that gives me double lines at the end as well...

    Anyone have more info on these two Chr's?

  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,264
    Rep Power
    968
    10 is a Line Feed, and 13 is a Carriage Return. Which means usually people do #Chr(13)##Chr(10)#

    Comments on this post

    • medialint agrees
    • sizablegrin agrees
    • Axweildr agrees
    • Skipt agrees : Well said!
    • requinix agrees : so they tell me you need rep...
  4. #3
  5. Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jun 2005
    Posts
    5,964
    Rep Power
    4852
    From a system point of view Windows tends to use the pair, CR/LF, even if a programmer only provides the LF. 'Nix tends to use LF. Mac (used to be, anyway) uses the CR.

    An early I/O device, the teletype, needed one to return the carriage and the other to feed the line (unlike a typewriter, where both are usually associated with one keystroke).
    Write no code whose complexity leaves you wondering what the hell you did.
    Politically Incorrect DaWei on Pointers Grumpy on Exceptions

IMN logo majestic logo threadwatch logo seochat tools logo