pjhayward's Pascal Tutorial

pjhayward.net Home

Got a question?

Tutorial Home
Lesson One - Sample Program
Lesson Two - Program Structure
Lesson Three - Data Types
and Constants
Lesson Four - Variables
Lesson Five - Text I/O
Lesson Six - Subroutines
Lesson Seven - Conditional
Lesson Eight - Arrays
Lesson Nine - Loops
Lesson Ten - Units
How do you get a newline in Pascal?
Well, this is somewhat dependent on whether you're using a DOS/Windows system or a Unix/Linux system, but the basic idea is still the same. In Windows, a newline is marked by two characters, Carriage Return + Line Feed. In *nix, it's marked by a single Line Feed. These are standard ASCII characters, and in programs where I need them a lot, I define some simple global constants, like this:
CR = #13;
LF = #10;
Then, whenever I need a newline, I just throw in CRLF, or LF if I'm using Linux. Like this:
var somestring;
  somestring:='I want this string to'+CRLF+'use two lines.';
It's that easy.

Back to Question/Answer list