1. Script blocks

    Article: AN0002008Updated:

    Script blocks are used for placing parts of scripts that are used repeatedly to a single place. You get several advantages by setting parts of scripts aside:

    • More simple code in the place from where you call
    • Centralizing common functions in a single place
    • Your code will be maintained in a better way

    Script blocks are visible from all the models and can be used in all the scripts.

    Only enabled blocks can be used. This can be benefit in case of a fast replacement of a complete functionality for another one. You switch off one block, switch on the new prepared one, change the code of the old block and use the orinal code of the old block for the new block.

    Rules for code

    When creating script blocks pay attention to the code of the script block. The code is unique over the whole ObjectGears system and we do not recommend to change it with regard to its use in scripts. If you need to change it, use the functionality search in scripts and functions to make sure you change it also in all the places where it is used.

    We recommend using prefix in the code for your blocks. This helps to avoid collisions with other blocks from future models.


    The first line contains definition of the used script block with code f1. The second line then calls method F1, that is contained in the given block.


    We will define script block with code custom_Functions and define in it:

    function MyFunction1()
    OG.Log.Write('Hello world.');

    Before using block in your script you have to state script block definition. We will put this definition at the beginning of the script. When using more blocks we will put them on separate lines.

    The first line contains definition of the used script block with code custom_Functions. In the second line we will call function MyFunction1, that is contained in the block.

    //#block custom_Functions