Getting Started with Free Pascal

An interactive tutorial using the Pas2JS compiler widget.

Lesson 1: Hello World

Every programming journey begins with a "Hello World" program. In Free Pascal, we use the Writeln procedure to print text to the console.

The basic structure of a Pascal program is:

program main;
uses browserconsole;
begin
  // Your code here
end.

Try it: Complete the exercise below by writing a program that prints Hello, World! to the console.

Lesson 2: Variables and Types

Pascal is a strongly typed language. You declare variables in a var section before the begin block.

Common types include:

Try it: Declare a variable name of type String, assign it your name, and print a greeting.

Lesson 3: Creating HTML Elements

Since Pas2JS compiles to JavaScript, you can interact with the browser DOM. Use Document.createElement to create HTML elements and Document.body.appendChild to add them to the page.

Try it: Create a button element with the text "Click me" and add it to the page.