Recent

Author Topic: What is #13#10 in Pascal?  (Read 7306 times)

avv210

  • New Member
  • *
  • Posts: 13
What is #13#10 in Pascal?
« on: December 27, 2021, 08:58:20 am »
Hi guys! What is the meaning of #13#10 in Pascal? Thank you.

Dodo1977

  • Newbie
  • Posts: 6
Re: What is #13#10 in Pascal?
« Reply #1 on: December 27, 2021, 09:08:15 am »
#13#10 indicates a return and linefeed. In other words, it starts a new line.

Zoran

  • Hero Member
  • *****
  • Posts: 1988
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: What is #13#10 in Pascal?
« Reply #2 on: December 27, 2021, 09:31:14 am »
In Free Pascal code, the hash character in front of unsigned byte number - #n - is a character literal, where n represents ascii value of that character.
So, writting #65 in pascal source is same as 'A'.
You can also use this syntax inside string constants, for example:
Code: Pascal  [Select][+][-]
  1. // All these constants are same:
  2. const
  3.   HW1 = 'Hello, World!';
  4.   HW2 = 'Hello, W'#111#114'ld!';
  5.   HW3 = 'Hello, W' + #111#114 + 'ld!';
  6.   HW4 = 'Hello, W' + Chr(111) + Chr(114) + 'ld!';
  7.  

And 13 and 10 are ASCII codes of "carridge return" and "line feed". Historically, there has been a lot of confusion about their usage (read more in Wikipedia).

For better portability of your programs, better use LineEnding constant, which will be #10 in Linux and #13#10 in Windows.
« Last Edit: December 27, 2021, 09:35:55 am by Zoran »
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

zoltanleo

  • Hero Member
  • *****
  • Posts: 522
Re: What is #13#10 in Pascal?
« Reply #3 on: December 27, 2021, 09:31:35 am »
Hi guys! What is the meaning of #13#10 in Pascal? Thank you.
#13#10(win) = #10(Linux) = #13(MacOS)  = sLineBreak
Win10 LTSC x64/LMDE7-x11-x86_64(gtk2/gtk3)/Fedora-44-wayland-x86_64(gtk2/gtk3)/ Kubuntu-24-x11-x86_64(qt5/qt6)/KDE Neon-wayland-x86_64(qt5/qt6)/Darwin Cocoa x86_64 (15.7.7):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 5.0.3 x86_64; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

Thaddy

  • Hero Member
  • *****
  • Posts: 19272
  • Glad to be alive.
Re: What is #13#10 in Pascal?
« Reply #4 on: January 03, 2022, 11:49:37 pm »
It is the same as ^M^J , which is the old way:o :-X Indeed, use the sLineBreak for platform compatibility.
« Last Edit: January 03, 2022, 11:59:22 pm by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

 

TinyPortal © 2005-2018