Skip to content

seanpm2001/Learn-Pascal

Repository files navigation


Learning Pascal

2021 Basic syntax (pascal)

Testing basic syntax of Pascal

{ Start of script }
// Pascal comments are weird
{ This type of comment is even weirder, similar to (* *) in CAML }
program aboutPage(output);
begin
  asm 0101000 10101010 00011000 01101100 { Assembly data? } // I know this line is not functional, take it out upon testing
  write('about:blank')
  write('Lorem ipsum')
  helloWorldOnTwoLines(); { DO NOT USE return }
  break
end.
function helloWorldOnTwoLines();
begin
  write('Hello-')
  continue.
  	write('-world')
  	break; // Semicolons are recognized as null statements and are not needed
  break;
end.

/!\ This example has not been tested yet, and may not work

I need feedback on any problems with this, this is basically all my Pascal knowledge as of 2021 Friday September 24th

Comments in Pascal

These are 2 types of comments in Pascal:

Block comments:

{ Block comment }
{ Write like
this as well } // I am not sure if this works

/!\ This example has not been tested yet, and may not work

and Single Line comments:

// Single line comment

Hello World in Pascal

This is a simple Hello World program in Pascal:

begin
	write('Hello World')
end.

/!\ This example has not been tested yet, and may not work

Functions in Pascal

This is a simple function in Pascal:

function helloWorldOnTwoLines();
begin
  write('Hello-')
  continue.
  	write('-world')
  	break; // Semicolons are recognized as null statements and are not needed
  break;
end.

/!\ This example has not been tested yet, and may not work

Break keyword in Pascal

break

To this day, I am still not entirely sure what the break keyword does, but most languages support it.

/!\ This example has not been tested yet, and may not work

Other knowledge of the Pascal programming language

  1. Most early Macintosh software was written in Pascal

  2. Pascal is NOT a curly bracket and semicolon language

  3. Pascal uses the .pas file extension, or the simpler .p file extension

  4. Pascal is similar in syntax to FORTRAN with the begin and end. blocks

  5. No other knowledge of Pascal to list.


Releases

No releases published

Sponsor this project

Packages

No packages published

Languages