Skip to content

Instantly share code, notes, and snippets.

@aksiksi
Created March 20, 2016 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aksiksi/11f8634379ca53db8037 to your computer and use it in GitHub Desktop.
Save aksiksi/11f8634379ca53db8037 to your computer and use it in GitHub Desktop.
Some Free Pascal...
program Hello;
uses sysutils;
// Record syntax
type Book = record
title: string;
author: string;
isbn: string;
end;
function max(x, y: integer): integer;
begin
if (x >= y) then
max := x
else
max := y;
end;
var i, j: integer;
var s: string;
var age: 10..100;
var ret: integer;
var b: Book;
var books: array [0..9] of Book; // Create array of 10 books
begin
writeln('Hello, world!');
ret := max(10, 11);
writeln(ret);
b.title := 'Hey dude';
b.author := 'Max';
b.isbn := '1010031301301';
writeln('Title = ', b.title, 'Author = ', b.author, 'ISBN = ', b.isbn);
// Now, create more books!
for i := 0 to 9 do
begin
b.title := 'Harry Potter ' + inttostr(i+1);
b.author := 'JK Rolling';
b.isbn := 'N/A';
books[i] := b;
end;
// Print them books
for i := 0 to 9 do writeln(books[i].title);
end.
@aksiksi
Copy link
Author

aksiksi commented Mar 20, 2016

To compile this example, get Free Pascal.

Then navigate to the file's directory and run:

fpc hello.pas

You'll get a binary for your platform with the name hello.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment