HOME - - - - - - - - - Other material for programmers - - - - - - - - - Pascalite Tutorial Table of Contents

Pascalite Programming: Default boilerplate


If you click on the Pascalite menu's File|New, you are offered "New" and "Default". New gives you a blank page; Default gives you a boilerplate for a program which you can build up into something to accomplish whatever you need. This tutorial (less hands-on than most) takes you through the ideas behind the boilerplate.

You don't need to do things the way the boilerplate anticipates. You may not need it, and consequently may not need this tutorial. But the following may help you follow examples provided with the Pascalite, as at least some of them are organised by the boilerplate's scheme.

You need to understand user defined procedures before this tutorial will make sense.

The raw boilerplate is as follows:
program default;

procedure interrupt;
begin
end;

procedure init;
begin
end;

procedure run;
begin
end;

begin
  init;
  repeat
    run;
  until 0=1;
end.
To use the boilerplate:

The word "default" on the first line can be left, but it would be best to replace it with something more indicative of the program's use.

The skeleton of the procedure named "interrupt" is provided in case you wish to avail yourself of the Pascalite's ability to resond to counter overflows. (Use of the counter and the interrupt facility are one part of this tutorial.)

The skeleton of the procedure named "init" is provided in case you want to put various things that happen once at the start of the program's execution in one place. You don't have to do this.

The skeleton of the procedure named "run" is provided in case you want to put various things make up the "meat" of the program in one place. You don't have to do this.

the main block, i.e.....
begin
  init;
  repeat
    run;
  until 0=1;
end
.....can stay as it is if you have put everything else in the declarations of init and run, and are happy for the program to run indefinately. 0=1 is equivalent to the 4=5 which I tend to use for an obvious "false".

In a moment, I'm going to show you a program written within the default skeleton. First I'll show you a less complex way of doing the same thing. The benefits of using the "init" and "run" procedures become more valid as programs grow larger. I'm afraid that yet again, the program is of little practical use, so don't be too puzzled when it seems not to do anything purposeful!

First... the program written in the simple form....

program Demo;
var bNum1, bNum2:byte;
begin
bNum1:=5;
bNum2:=3;
repeat
if b1 then begin
  bNum1:=bNum1+bNum2;
  bNum2:=bNum2+1;
  write(lcd,bNum1);
  end; {of if's begin. Has no else}
until 4=5;
end.
And now using the Pascalite default skeleton.
program Demo;
var bNum1, bNum2:byte;

procedure init;
 begin
  bNum1:=5;
  bNum2:=3;
  end;

procedure run;
begin
if b1 then begin
  bNum1:=bNum1+bNum2;
  bNum2:=bNum2+1;
  write(lcd,bNum1);
  end; {of if's begin. Has no else}
  end; {of procedure declaration}

begin
  init;
  repeat
    run;
  until 0=1;
end.


To search THIS site.... (Go to the site's above, and use their search buttons if you want to search them.)... Way to search this site without using forms
   Search this site or the web        powered by FreeFind

  Site search Web search

Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run an MS-DOS or Windows pc) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.

Link to editor's (Arunet) homepage
How to email or write this page's editor, Tom Boyd