Previous Topic

Book Contents

Book Index

Next Topic

Templates

If you find yourself using a certain construct often, you can create a template for it (giving it a short descriptive name) and then use it the same way as described above.

You can create, edit or remove a template on the Template tab using the corresponding buttons.

  • Creating a template

    Select a part of the code which you use often, e.g. getBOField(“contract”).getObject(), and press the 'Add' button. A dialog appears asking you to enter the name of the template (this name has to be unique). Enter something reasonably short (e.g. go for 'get object').

    The selected text, which appears in the text area, can be optionally modified. If you do not select any part of the code prior to pressing the Add button, you will have to type it manually in the Code text area.

    Note that the template should not contain any specific attribute/object type names (a different attribute has to be specified every time we use the template) so it is a good idea, in our example, to delete the name of the attribute from the brackets.

    Optionally, type the special keyword $cursor$ (or press the button Cursor) in the brackets of getBOField() – after the template is replaced, the cursor will be positioned at the place of this special keyword so that you can type the name of the attribute.

    Help Image

    If you now type 'g' and press Ctrl+space, you'll see:

    Help Image

    Select 'go' to complete the code to:

    Help Image

    then enter the name of the attribute. (if you type 'go' and press Ctrl+space the code will be completed immediately).

  • Editing a template

    To edit a template, select the template in the list and press the Edit button. You can rename the template (as long as the name is unique) or edit the code of the template.

  • Removing a template

    To remove a template, select the template in the list and press the Remove button.

Note: Templates are stored as user-dependent main parameters (the path is "ScriptEditor.templates"). You can create a set of templates and then export them from the catalog of Mainparameters and import them into another database.

See Also

Script Editor

Using the Script Editor

Script Editor Window

Search in the Script Editor

Code Completion

Python Script and Diacritics