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

    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 the script solution

     

    Set up script

    Activate ScriptBeforeEdit.exe

    Copy the application into the Server scripting directory for automatic update of client

     

    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.

    1. Activate the Schneider Modsoft script by entering the Component type ID connection to the script in the section [General])
    2. If more than one different component type is connected to the script, a new entry is required for each component type.

    3. Save the file.
    4. Copy the file into the Server scripting directory for automatic update of client.

    Example:

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

    Specific example:

    1
    2
    [General]
    5A527AA2D4A846208BB8648EED1146BD=SchneiderModsoft

     

    SchneiderModsoft.script

    1. Open the SchneiderModsoft.script in the text editor
    2. If necessary, make the adjustments listed in the table below.

    3. Save the file.
    4. Copy the file into the Server scripting directory for automatic update of client.

    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.

     

    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 (for example, the USB driver for the Modbusplus coupling).
    5. Save the file.
    6. Copy the file into scripting directory for automatic update of client.

     

    Related topics
    Activate scripting