Example for integrating the script editor for Schneider Modsoft components

This scripting solution enables an improvement with regard to the use of Schneider Modsoft components.

 

Necessary files for this script function:

File name

Description

Function

  • ScriptBeforeEdit.exe
  • Available in the scripting package

    Links the configurable project file with an editor, depending on the Component type ID

    ScriptBeforeEdit.ini

    Can be edited with a text editor

    Defines the script BeforeEdit for a specific component type ID

    SchneiderModsoft.script

    Can be edited with a text editor

    versiondog script, which was processed by the script interpreter

    ModsoftCaller.bat

    Can be edited with a text editor

    Batch file for opening the Modsoft editor or another editor

     

    Requirements for scripting solutions

    Set up script

    1. Activate ScriptBeforeEdit.exe
    2. Copy the application into the Server scripting directory for automatic update of client

    1. Edit ScriptBeforeEdit.ini

    We recommend that you edit the ScriptBeforeEdit.ini taken from the Server scripting directory for automatic update of client. If this file is not yet available, use the template from the scripting package.

    General example:

    1
    2
    3
    [General]
    // Mapping for CoDeSys editor component type
    <ComponentTypeID>=SchneiderModsoft

    Example:

    1
    2
    [General]
    5A527AA2D4A846208BB8648EED1146BD=SchneiderModsoft
    1. SchneiderModsoft.script

    Script:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    43
    43
    Function ScriptBeforeEdit
    {
    $def::var1 = C:\Modsoft\Editor
    $def::var2 = $func::getfilename($vdog::specific->SelectedFile)
    $def::var3 = $func::getshortdir($vdog::specific->WorkingDir)
     
    // Create UPF file:
    file.create $def::var1\$def::var2.upf
    {
    write.line rt_directory $def::var1\RUNTIME
    write.line tmp_directory $def::var1\TMP
    write.line files_directory $def::var3
    write.line names_directory $def::var
    }
     
    // ENV edit:
    file.replace $def::var3\$def::var2.env
    {
    row.1 $def::var3\
    row.2 $def::var3\
    row.3 $def::var3\
    row.4 $def::var3\
    row.5 $def::var3\
    }
     
     
    // Update Modsoftcaller:
    file.copy
    {
    source $vdog::myrundir\ModsoftCaller.bat
    dest $def::var1\ModsoftCaller.bat
    }
     
    // Execute Modsoft-Batch:
    call $def::var1\ModsoftCaller.bat
    {
    arg $def::var2.upf
    arg $def::var2.env
    wait 0
    }
     
    done
    }

    Lines

    Description

    3

    Edit the absolute path to the Modsoft editor.

    37

    In this example, only the file name is given as argument.

    The line for the absolute specification of the UPF file:arg $def::var1\$def::var2.upf

    38

    In this example, only the file name is given as argument.

    The line for the absolute specification of the ENV file:arg $def::var3\$def::var2.upf

    39

    Remove line, if you want to wait until the editor is closed.

    1. Edit ModsoftCaller.bat
    1. Open the file ModsoftCaller.bat in the text editor.
    2. // swap to Modsoft directory

      c:

      cd \Modsoft\editor\

      C:\Modsoft\editor\Modsoft.exe /f%1 %2

      Delete REM upf-file

      del %1

    3. If necessary, adjust the Modsoft editor directory.
    4. You can also call another application here (e.g.: the USB driver for the Modbusplus coupling).
    5. Save the file.
    6. Copy the file into scripting directory for automatic update of client.

    For more information about activating scripting functions and moving scripts into the server-sided scripting directory and/or the client-sided scripting directory, see Activate scripting.