www.kxcad.net Home > Electronic Index > Altium(Protel) Index
The Delphi Script interpreter allows two kinds of procedures: Procedures and Functions. The only difference between a function and a procedure is that a function returns a value.
A script can have at least one procedure which defines the main program code. You can, however, define other procedures and functions that can be called by your code. As with Borland Delphi, procedures are defined within a Begin End statement block as well as functions are defined within a Begin.End statement block too.
To invoke or call a function or procedure, simply include the name of the function or procedure in a statement in the same way that you would use the built-in Delphi Script functions and procedures. If the function or procedure requires parameters, then you must include these in the calling statement. Both functions and procedures can be defined to accept parameters, but only functions can be defined to return a value to the calling statement.
You may assign any name to functions and procedures that you define, as long as it conforms to the standard Delphi Script naming conventions.
Typical Delphi Script procedure
Procedure CreateSchObjects;
Begin
If SchServer = Nil Then Exit;
SchDoc := SchServer.GetCurrentSchDocument;
If SchDoc = Nil Then Exit;
PlaceSchematicObjects;
SchDoc.GraphicallyInvalidate;
End;
Typical Delphi Script function
Function BooleanToString(AValue : Boolean) : String;
Begin
If (AValue) Then Result := 'True'
Else Result := 'False';
End;
The name of a function can not be used to set its return value. The Result keyword must be used instead.
See also