| 1 | <h2>Comments</h2> |
| 2 | <pre><code>(* This is an |
| 3 | old style comment *) |
| 4 | { This is a |
| 5 | Turbo Pascal comment } |
| 6 | // This is a Delphi comment.</code></pre> |
| 7 | |
| 8 | <h2>Strings and characters</h2> |
| 9 | <pre><code>'This is a pascal string' |
| 10 | '' |
| 11 | 'a' |
| 12 | ^G |
| 13 | #7 |
| 14 | #$f4 |
| 15 | 'A tabulator character: '#9' is easy to embed'</code></pre> |
| 16 | |
| 17 | <h2>Numbers</h2> |
| 18 | <pre><code>123 |
| 19 | 123.456 |
| 20 | 132.456e-789 |
| 21 | 132.456e+789 |
| 22 | $7aff |
| 23 | &17 |
| 24 | %11110101</code></pre> |
| 25 | |
| 26 | <h2>Full example</h2> |
| 27 | <pre><code>Type |
| 28 | Str25 = String[25]; |
| 29 | TBookRec = Record |
| 30 | Title, Author, |
| 31 | ISBN : Str25; |
| 32 | Price : Real; |
| 33 | End; |
| 34 | |
| 35 | Procedure EnterNewBook(var newBook : TBookRec); |
| 36 | Begin |
| 37 | Writeln('Please enter the book details: '); |
| 38 | Write('Book Name: '); |
| 39 | Readln(newBook.Title); |
| 40 | Write('Author: '); |
| 41 | Readln(newBook.Author); |
| 42 | Write('ISBN: '); |
| 43 | Readln(newBook.ISBN); |
| 44 | Write('Price: '); |
| 45 | Readln(newBook.Price); |
| 46 | End; |
| 47 | |
| 48 | Var |
| 49 | bookRecArray : Array[1..10] of TBookRec; |
| 50 | i : 1..10; |
| 51 | |
| 52 | Begin |
| 53 | For i := 1 to 10 do |
| 54 | EnterNewBook(bookRecArray[i]); |
| 55 | Writeln('Thanks for entering the book details'); |
| 56 | Write('Now choose a record to display from 1 to 10: '); |
| 57 | Readln(i); |
| 58 | Writeln('Here are the book details of record #',i,':'); |
| 59 | Writeln; |
| 60 | Writeln('Title: ', bookRecArray[i].Title); |
| 61 | Writeln('Author: ', bookRecArray[i].Author); |
| 62 | Writeln('ISBN: ', bookRecArray[i].ISBN); |
| 63 | Writeln('Price: ', bookRecArray[i].Price); |
| 64 | Readln; |
| 65 | End.</code></pre> |