Learning Smart Pascal

Usually students learn the Pascal language by writing console programs in Lazarus or Delphi. Our tutorials are arranged in an order suitable for this approach. Since Smart Mobile Studio has been made available free for use in schools and clubs we have observed that talented students can learn the language the fun way by developing motion graphics games from the outset. We now publish Pascal language tutorial pages aimed specifically at students who are learning the language in this way before developing conventional applications in Lazarus and/or Delphi.

We will apply the concepts covered in several of our existing tutorials to specific examples in Smart Mobile Studio so that you can learn some terminology and principles as you develop your own motion graphics programs and games.

We now have fine student programs that we can use for reference and as examples for others to emulate. Some student Pascal programs written in Lazarus were worth porting to Smart Mobile Studio and provide further useful code to draw upon. You might have seen the links to these programs already in the general introduction to this Smart Mobile Studio tutorial. We also have a few demonstration programs which have proved useful for enabling students to learn by making changes to the code in order to test their understanding.

We recommend that students begin by first studying Motion1. The code is intended to be brief, with plenty of opportunities for improvement. Program Motion2 includes several enhancements and is a better starting point for a game of your own. Better still, but much more complicated, is Steven Binns's PlatformDemo. You might prefer to start by modifying a program that enables the user to move an image using the keyboard or to drag a shape or an image with the mouse.

We now use Version 2.1 of Smart Mobile Studio and offer this guidance for using existing code from earlier versions and for using code from new demonstrations in older versions.

Preliminary Knowledge

In order to understand the code snippets and introductory programs you will need to be aware of the following.
  • A single line comment is preceded by two consecutive slashes. Everything after // on a line is for the reader's benefit and is not translated into JavaScript by Smart Mobile Studio.
  • Braces {} enclose a multi-line comment.
  • The semicolon at the end of each instruction is the statement separator.
  • The code is not case sensitive, so, for example inc(v), INC(V), Inc(v) and Inc(V) will all increment a variable named v or V.
  • Blocks of code are enclosed between the keywords begin and end.
  • The operators +, -, / and * are used for addition, subtraction, division and multiplication, respectively.
  • The operator div performs integer division, ignoring any remainder, so that 7 div 3 evaluates to 2.
  • The operator mod gives the remainder after integer division so that 7 mod 3 evaluates to 1.

 

Follow the links below to sections of the Smart Pascal tutorial.

Programming - a skill for life!

Developing graphical web pages including 3D, input from keyboard and mouse and storing and loading data