A r t i c l e s
Navigation

Note: This Wiki is
outdated, personal views
may have changed.
L505 A.I. bot is dead
long live THX 1138

M a i n P a g e

D i r e c t o r y

Z505 Pascal Coding Standard


Pascal Code is more legible and neater if you follow some simple guidelines. The Z505 Pascal Coding Standard defines some basic guidelines that you may find helpful to keep your Pascal code neat and tidy looking.
Procedures are written as:
 procedure TAny.DoSome(Sender: TObject; Other: Param);

 instead of
   procedure TAny.DoSome(Sender:TObject;Other:Param);
   Procedure TAny.DoSome(Sender: TObject; Other:Param);
   PROCEDURE TAny.DoSome(Sender: TObject; Other:Param);
Lower case procedure is preferred over Procedure or PROCECDURE. A space is preferred after the colon.

Functions are written as:
 function TAny.DoSome(Sender: TObject; Other: Param): info;

 instead of
    function TAny.DoSome(Sender:TObject;Other:Param):info;
    Function TAny.DoSome(Sender: TObject; Other:Param):info;
    FUNCTION TAny.DoSome(Sender: TObject; Other:Param):info;
Lower case function is preferred over Function or FUNCTION. A space is preferred after the colon, akin to procedure.

The begin and end reserved words are written as:

begin
end;
end.
instead of
BEGIN
End;
END.

Indentation is as follows:

Use two spaces to indent code within begin and end.
Do not use real tabs. Two spaces is recommended over 
one space.

begin
  writeln('hello, how are you?');
end;

Variable declarations:
Use two spaces to indent variables under var
Do not use real tabs. Two spaces is recommended over 
one space.

var
  mine: string;     //comments   
  his,              //your comment
  hers,             //a comment
  theirs: integer;  //comment 
  num: real;        //your comments 
You may wish to spend time doing the following:
 
var
  mine   : string;    //comments   
  his,                //your comment
  hers,               //a comment
  theirs : integer;   //comment 
  num    : real;      //your comments 
However, both the above ways are acceptable.

Below is not recommended:



var 
  mine :string;      //comments   
  his,             
  hers,            
  theirs :integer; 
  num :real;      

var 
  mine : string;      //comments   
  his,             
  hers,            
  theirs : integer; 
  num : real;    

Colons should be attached like: that.

Type, public, private, published, indentation as follows:



type
  TSome = class
    private
      function test: integer;
      procedure test6;
    public
      procedure test4;
      procedure test5;
  end; 
 
  TAnything = class
    private
      function testA: integer;
      procedure testB;
    public
      procedure testC;
      procedure testD;
  end; 



The end; lines up with the TClass. The private/public and their functions and procedures are indented. All indentation is by two spaces.


The else statement: coming soon
The and statements: coming soon
The repeat statements: coming soon
The for and while statements: coming soon

About
Note: This Wiki is outdated, personal views may have changed.

This wiki contains info on life, health, humans, nature, programming, database, fads, paradigms, poems, principles, theories.

Articles may contain statements which some may find helpful and encouraging, or even discouraging.

Beware, I believe in the Grand Justice system.
_ _ _