Creating new scripts

www.kxcad.net Home > Electronic Index > Altium(Protel) Index


Your Ad Here

You can add existing or new scripts into the specified project in the Projects panel in DXP. There are two types of scripts : Script Units and Script Forms. With a project open in DXP, right click on a project in the Projects panel, and a pop up menu appears, click on the Add New to Project item, and choose Script Unit. A new script appears.

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. Functions and procedures are defined within a Begin End statement block as well as functions.

It is possible to have no procedures or functions within a script but at least it is necessary to have a Begin End. (with the full stop at end of the End keyword) block so that the script can have a chance to get executed.

Example of a procedure

Procedure CreateSchObjects;

Begin

    If SchServer = Nil Then Exit;

    SchDoc := SchServer.GetCurrentSchDocument;

 

    If SchDoc = Nil Then Exit;

    PlaceSchematicObjects;

    SchDoc.GraphicallyInvalidate;

End;

Example of Begin End. block

Begin

    ShowMessage('The dialog will appear when you run this script');

End.

If you have a statement in your script but there is no Begin End. block or no procedures, then the script will not be executed.

See also

Executing a script in DXP

Designing Script forms

Tips on writing scripts

Your Ad Here