Ver. 1.0 Beta, Don't have a compiler? Now you can write simple scripts ONLINE! This is a basic version -does not include all the Pascal statements. Only to learn basics

Esthetics


Before you begin programming decide to keep some esthetics standards. This is no required for program to work properly, but it really simplify life. It makes easier working with programs not only to teachers or other persons who will watch your scripts, but to you as well. Please take a look at the two examples of code produced by a learning programmer.



Beginnings:

procedure plot;
begin
tlo(nx,ny);
if GetPixel(nx,ny)<>k then
begin
if sp=0 then begin
punkt(nx,ny,k);
Writeln(F,'punkt');
r:=r+15;
Str(nx,t);
Writeln(F,t);
r:=r+Length(t);
Str(ny,t);
Writeln(F,t);
r:=r+Length(t);
Str(k,t);
Writeln(F,t);
r:=r+Length(t);
end;
end;
if ((sp=1) and (roznice)) then
begin
linia(sx,sy,ex,ey,k);
Writeln(F,'linia');
Str(sx,t);
r:=r+17;
Writeln(F,t);
r:=r+Length(t);
Str(sy,t);
Writeln(F,t);
r:=r+Length(t);
Str(ex,t);
Writeln(F,t);
r:=r+Length(t);
Str(ey,t);
Writeln(F,t);
r:=r+Length(t);
Str(k,t);
Writeln(F,t);
r:=r+Length(t);
end;
status3;
kursor(nx,ny);
end;

Few years later:


unit Doors;

{**********************************************************}

interface

uses Errors,        {OBSLUGA I KODY BLEDOW}
    Graph10E,      {GRAFIKA W VESA, TRYB 10Eh}
    Standard,      {STANDARDOWE POLECENIA}
    Fonts;         {OBSLUGA CZCIONEK}


{**********************************************************}

const
     MaxEvents=15;           {WSZYSTKICH ROZNYCH ZDARZEN}
     MINI_BUTTON_SIZE   =10; {ROZMIAR PRZYCISKU NA OKNIE}

     MAX_OBJECTS        =10;

{**********************************************************}

     {NAZWY OBIEKTOW SYSTEMU SKKS DOORS}

     DOORS_FORM         = 1; {OKNO, NA KTORYM USTAWIA SIE OBIEKTY}
     DOORS_BUTTON       = 2; {PRZYCISK}
     DOORS_EDIT         = 3; {POLE TEKSTOWE}
     DOORS_PANEL        = 4; {PANEL NA KTORYM BEDA INNE OBIEKTY}
     DOORS_ICON         = 5;
     DOORS_LABEL        = 6; {NAPIS OBIEKTOWY}


You don't have to many years on starting to use a nice coding style. It is sufficient to keep esthetic style from beginning. A good practice is to indent the code after each starting block of code and return to previous position after its finish. If you have a mess in your code, take a look at the keyboard shortcuts described in the introdiction to the guide and clean up your sources.


It is a good practice to write key words, like: unit, begin, end, const  using lower case.


Sometimes it is worth to write comments in the code, like descriptions of the purpose. In practice comments describing all the lines of code are bad idea. The will hide the most important code. Comment lines when it will be really helpful and will simplify understanding your intentions.


 

ON-LINE scripts!

This website uses cookie files in order to provide Google services (advertisements, analitycs) and Facebook. If you want to block using cookies, turn them off in your browser settings. Need a help? Click me