1. Home
  2. Knowledge Base
  3. Versiondog Server
  4. Tutorials
  5. Scripting
  6. ScriptingPackageExamples
  7. KB-133180: Examples of script editor integration for CoDeSys components

KB-133180: Examples of script editor integration for CoDeSys components

Examples of script editor integration for CoDeSys components

This scripting solution allows for improvements when dealing with different components types, which are equally based on CoDeSys, but require different project environments.

Necessary files for this script function

File nam Description Functio
ScriptBeforeEdit.exe Available in the script 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
ScriptBeforeCompare.exe Available in the script package Configures the comparator process for the editor depending on the Component type ID
ScriptBeforeCompare.ini Can be edited with a text editor Defines the script BeforeCompare for a specific component type ID
Codesys_editor.script Can be edited with a text editor versiondog script, which was processed by the script interpreter

The scripting solutions can be used independently from each other.

Requirements for scripting solutions

  • The CoDeSys editors need to be available locally under a common path. In other words, multiple computers need to have the same local access path.

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 theScriptBeforeEdit.initaken from the Server scripting directory for automatic update of client. If this file is not yet available, use the template taken from the script package.

  1. Activate the CoDeSys editor script by entering the Component type ID connection to the script in the section [General])
  2. If more than one kind of 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>=Codesys_editor

Specific example:

1 2

[General] 5A527AA2D4A846208BB8648EED1146BD=Codesys_editor

Edit Codesys_editor.script

  1. Open the Codesys_editor.script in the text editor
  2. Edit the function ScriptBeforeEdit
  3. If necessary, make the changes listed in the table below.
  4. Save the file
  5. 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

Function ScriptBeforeEdit { // The editors for the Codesys components // Assign (ComponenttypId <-> Codesys Editor) $def::var1 = $func::getifcomponenttypeid (<ComponentTypeId 1>, <Editor 1>) $def::var1 = $func::getifcomponenttypeid (<ComponentTypeId 2>, <Editor 2>) $def::var1 = $func::getifcomponenttypeid (<ComponentTypeId 3>,<Editor 3>)

exit.ifemptyvar $def::var1

$def::var2 = $vdog::specific->WorkingDir$vdog::specific->SelectedFile

call $def::var1 { arg $def::var2 wait 0 rundir $def::var1 }

done }

Lines Descriptio
5 A specific component type ID is assigned to a specific editorA component type ID is defined as a condition.$def::var1is assigned the definition to the editor path as a value only exactly when the component type ID matches that of the job.The following applies: $def::var1 = If component type ID equals than use editorThe scripting synxtax is: $def::var1 = $func::getifcomponenttypeid (<ComponentTypeId>, <Editor>)<ComponentTypeId> needs to be replaced with the exact component type ID that you want to link a specific editor to.<Editor> needs to be replaced with an absolute path to the editor that you want to link to the component type ID.Example:$def::var1 = $func::getifcomponenttypeid(5A527AA2D4A846208BB8648EED1146BD, C:Program filesmyeditor.exe)
6, These lines can be removed if there aren’t any other necessary editors. The configuration occurs as seen in line 5Likewise, additional lines need to be added for the additional editors
All editors need to assigned before this line.If the script was executed, even though the specified component type ID was not (yet) included, the script will end exactly at this line. The versiondog system carries out the standard logic to open the editor

Activate ScriptBeforeCompare.exe

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


Edit ScriptBeforeCompare.ini

We recommend that you add (if already available) the ScriptBeforeCompare.ini file taken from the Server scripting directory. If this file is not yet available, use the template from the script package.

Note

Please note: changes to theScriptBeforeCompare.inifile need to be carried outtwice, once when configuring the

Server scripting directory and once when configuring the Client scripting directory. Although the configuration files for server and client have the same name, they may have different content (related to the script configuration for other components).

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

Example:

1 2 3

[General] // Mapping for CoDeSys editor component type<ComponentTypeID>=Codesys_editor

Specific example:

1 2

[General] 5A527AA2D4A846208BB8648EED1146BD=Codesys_editor

Expand the include list

  1. The BeforeCompare event considers a list of component type ids for which the script should be activated (Activation list).
  2. In this list, all component types are listed via the CTIDn key, for which the script should be executed. You can adjust component type IDs for CoDeSys components here.
  3. Save the file
  4. Copy the file into the Server scripting directory.

Example:

1 2 3 4

[CTIDs] 12675=I CTID0 =<ComponenttypeID>CTID1 =<ComponenttypeID>

Specific example:

1 2 3

[CTIDs] 12675=I CTID0=581E9C1B48714ED6ADEE19E5351811BB

Edit Codesys_editor.script

  1. Open the Codesys_editor.script in the text editor.
  2. Edit the function ScriptBeforeCompare.
  3. If necessary, make the adjustments listed in the table below.
  4. Save the file.
  5. Copy the file into the Server scripting directory for automatic update of client and into the Server scripting directory.

Script:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Function ScriptBeforeCompare { // The editors for the Codesys components // Assign (ComponenttypId <-> Codesys Editor) $def::var1 = $func::getifcomponenttypeid (<CoDeSys ComponentTypeId 1>, <Editor for Type 1>) $def::var1 = $func::getifcomponenttypeid (<CoDeSys ComponentTypeId 2>, <Editor for Type 2>) $def::var1 = $func::getifcomponenttypeid (<CoDeSys ComponentTypeId 3>,<Editor for Type 3>)

// set the editor $def::var2 = $vdog::rootdirVD$AConfigurationCompareAgentStation.ini file.append $def::var2 { write.ini [CoDeSys]7220=$def::var1 } }

Lines Descriptio
5 A specific component type ID is assigned to a specific editorA component type ID is defined as a condition.$def::var1is assigned the definition to the editor path as a value only exactly when the component type ID matches that of the job.The following applies: $def::var1 = Condition (ComponenttypeId, Editor)<ComponentTypeId>must now be replaced with the concrete component type id to be associated with a specific editor.<Editor>must now be replaced with the absolute path to the editor to be associated with the component type id.Example:$def::var1 = $func::getifcomponenttypeid(5A527AA2D4A846208BB8648EED1146BD, C:Programsmyeditor.exe)
6, These lines can be removed if no further editor assignments are required. The configuration occurs as seen in line 5Likewise, additional lines may be inserted for additional editor assignments.

Last update: September 15, 2023

Related Articles

IMPRINT | PRIVACY POLICY | COOKIE POLICY

Privacy Preference Center