Creating Scripts for the OpenTM2Scripter

Contents

Introduction

In order to create scripts for the openTM2Scripter, use any text editor such as Notepad etc. Each line in a script file contains one command with a command specific number of tokens. In order to format text parts in the script file, use white spaces at the beginning of a line. Empty lines in the script are ignored.

The OpenTM2Scripter is called from a DOS command line: “OpenTM2Scripter.exe”.

Several parameters can be passed along the command:

  • Scriptfile: the Location of the script. Example: script.txt or \anyfolder\script.txt
  • Logfile: the location of the logfile. Example: /log=log.txt or /logfile=\anyfolder\log.txt
  • Constants: any constants which is contained in the script. Example: /any_name=my_text
  • INFO: prints an information. /INFO=d for Datetime or /INFO=p for ProcessID
  • Help: prints a help to the parameters. Syntax: /HELP
  • DelTemp: Deletes the automatic created temporary script after Execution. Syntax: /delTemp

Example Calls:

  • OpenTM2Scripter.exe \anyfolder\script.txt /log=\anyfolder\log.txt /INFO=d /INFO=p /delTemp
  • OpenTM2Scripter.exe \HELP (only for the help output)
  • OpenTM2Scripter.exe (gives the help output and tries to execute the script OpenTM2.SCR)

Comments

Command lines with a * as first character will be interpreted as comment lines. The * character must be the first character in a line, so do not insert any white space characters (e.g. a tab or a blank) or any other character before the * character.

 

Define and use constants

Constants, which contain strings (for example a path to a folder) can be defined using the DEFINE command. The values of constants can not be changed while the program is running.

DEFINE constant_name, constant_value

The first token contains the constant name, the second token contains the value of the constant. If a “,“ (comma) must be used in the value, braces or double quotes must be used to surround the token.

 

DEFINE constant_name2, (constant,value)
DEFINE constant_name3, “constant,value“

Constants can be used at every position within the script by writing %constant_name%. This statement will be replaced by the constant value before the line is processed.

Define a constant before using it by applying %constant_name%. The program would ignore the constant if it is defined at a later point in time.

 

Set constants at program start

At the program start, pass on the constants-definition as parameters:

OpenTM2Scripter /constant=name,value /constant=name2,value2

Users can create any number of constants using this way. The format of the parameters is identical to other parameters (e.g. the logfile parameter).

Variables

Use variables in OpenTM2Scripter for storing integer values such as return codes from API-calls., No declaration is required. A variable will be created as soon as it is used for the first time.

 

Set a value

Use the SETVALUE command to set an integer value to a variable, or create and initialise a new variable by applying an integer value.

* Will create a variable „varname“ an set the value 15
SETVALUE varname,15
* Will set the value 1 to variable „varname“
SETVALUE varname,1

 

Save returncode in variable

The return code of the last API-call will be saved in a local program variable an can be copied into a user generated variable by applying the SAVERETURNCODE command.

EQFIMPORTDOC foldername,file
SAVERETURNCODE varname
* Returncode is copied to variable „varname“

 

Addition

Add an integer value to a variable by using the ADD command.

* will create the variable „varname“ with 5 as value

ADD varname,5
* will add 5 to variable „varname“
ADD varname,5
* value of varname is 10 here

 

Subtract

Subtract an integer value from a variable by using the SUB command.

* will create the variable „varname“ with 5 as value
SUB varname,5
* will add 5 to variable „varname“
SUB varname,5
* value of varname is 0 here

 

Increment and Decrement

The command INC increments a variable by one. DEC decrements a variable by one.

* will create a variable „varname“ and set value 1
INC varname
* will increment value to 2
INC varname
* will decrement value to one
DEC varname

 

Use a variable value

If the current value of a variable should be used in a program line, write $varname$. Before the line is processed, this statement replaces the variable by its real value.

SETVALUE myvar1,5
SETVALUE myvar2,10
*will be replaces to   IF (5<10)
IF ($myvar1$<$myvar2$)
* Program will sleep one second
  SLEEP 1000
ENDIF

 

Goto, Gotocond and Marker

Create a marker in the code by using the # symbol or by using the command MARKER followed by the name of the new marker.

# my_first_marker
MARKER my_second_marker

Jump to a marker by applying the command GOTO followed by a token for the marker name.

GOTO my_first_marker

By using the command GOTOCOND, it is possible to jump directly to a marker if a specified condition is true. The first token is the condition, the second token contains the marker name.

GOTOCOND (5==5&1!=2), my_second_marker

Braces enclsoing the hole condition are optional, but braces can be used in ordder to create “nested condition” parts. For more information see the chapter “conditions in if-statements”.

In order to negate an entire condition, use a ! as the first character of the condition.

GOTOCOND !(5==5&1!=2), my_second_marker

 

Conditions for if-Statements

List of supported operators

< smaller then
> larger then
== equal
 != not equal
| logical or
& logical and

A condition can contain any number of comparisons with the following operators:

  • <
  • >
  • ==
  •  !=

The operators can be combined by “&” or “|” operators. Braces can be used for “nest” parts of the condition. Braces surrounding the entire condition are optional.

(5==5|1!=2|1!=1)   →   condition is true
(5==5&1!=2&1!=1)   →   condition is false
(5==5&(1!=2|1!=1)) →   condition is true
5==5|(1!=2&1!=1)   →   condition is true
(5==5|1!=2)&1!=1   →   condition is false

The conditions can compare any integer numbers. There is no support for string comparison.

If, elseif, else and endif

Within an “if” block, switch between different program parts by checking a condition. At first the “if” condition will be checked. If this condition is false, the “elseif” condition will be checked. If no condition is true, the program continuos to the “else” block. Close the entire if/elseif/else block with an “endif” command. The usage of “elseif” and “else” cases is optional. An unlimited number of “elseif” statements can be used in an if/elseif/else block.

* Progam will sleep 1 milisecond, because 5==5 is true.
IF (5==5)
  SLEEP 1
* Program will not sleep 2 miliseconds
* because the if-condition was already true.
ELSEIF (1!=2)
  SLEEP 2
ENDIF
* Program will not sleep 3 miliseconds
* because 5>10 is false.
IF 5>10
  SLEEP 3
* Program will not sleep 4 miliseconds
* because 10<5 in false.
ELSEIF 10<5
  SLEEP 4
* Program will not sleep 5 miliseconds
* because the condition is false
ELSEIF 10<5|(11!=11&1==1)
  SLEEP 5
* Program will sleep 6 miliseconds
* because no condition was true
ELSE
  SLEEP 6
ENDIF

 

Counting loops (for-loops)

Use the FOR command to process a part of the program in a loop. Set a counting variable and a start value for the variable. A condition is required to check if the loop has to run one more time. The condition-syntax is identical to the syntax known from if-conditions. Specify an action which is performed on the count variable after every loop.

Choose one of the following action:

INC increments the counting variable by one

DEC decrements the counting variable by one

ADD X adds X to the counting variable (X has to be an integer)

SUB X subtracts X from the counting variable (X has to be an integer)
The Syntax is:

FOR varname,startvalue,condition,action
*  Loop content
ENDFOR

The ENDFOR-command is required at the end of every FOR-block. The FOR commands can be used in other FOR-blocks (nested FOR).

FOR myvar1,0,($myvar$<11),ADD 2
  INC countvar
  FOR myvar2,10,($myvar2&>0),DEC
    INC countvar
  ENDFOR
ENDFOR
* Countvar will have the value 50 here.

 

Compare files

COMPAREBINARY

The COMPABINARY command compares two files character by character. If there is a difference, the function will display an information “returned false”. In other cases, the function will display the info “returned true”.

The tokens must be set to the absolute paths to the files.

COMPAREBINARY C:\path\file.txt,  C:\path\file2.txt

 

COMPAREWORDCOUNT

This is a special function to compare output files created by the OpenTM2 word count function. If there is a difference, the function will display the line where the different was found, the line before the difference and the line number. The information at the end and the formatting of the function call is identical to the “comparebinary” command.

COMPAREBINARY C:\path\file.txt, C:\path\file2.txt

 

Include other script files

The include command includes any other script file from the local file system. Enter the relative path to the file that needs to be included starting in the directory of the script file where the include command is placed in. Includes can be used in included files too (unlimited levels).

File system
C
|->my-folder
|   |->scr-folder
|   |   |->test.script
|   |   '->test3.script
|   '->test1.script
'->test2.script
File: C:\my-folder\scr-folder\test.script
* include the file at C:\my-folder\test1.script
INCLUDE ../test1.script
* include the file at C:\test2.script
INCLUDE ../../test2.script
File C:\my-folder\test1.script
* include in secount level:
* Inlude file at C:\my-folder\test3.script
INCLUDE scr-folder/test3.script

 

Wildcards

In order to perform actions on more than one file at the same time, use a wildcard symbol (* or ?). A “*” can be replaced by any String. A “?” can be replaced by a single character only.

In parameters, that contain a list of files, use wildcards in every element of the list. In this case a new list with all files – which the wildcards includes – will be created and processed.

All functions, which accept wildcards but no lists of files in the parameters, will be processed again until the command was done with all files included by the wildcard.

 

Functions with wildcard support

*  EQFIMPORTDOC folder, list_of_files, memory, markup, editor, source_language, target_language, alias,  start_path, conversion, options
*  EQFDELETEDOC folder, list_of_files
*  EQFEXPORTFOLDER folder, drive, options, list_of_files, description
*  EQFEXPORTFOLDERFP  folder, export_path, options, list_of_files, description
*  EQFCOUNTWORDS folder, list_of_files, options, output_file
*  EQFEXPORTDOC folder, list_of_files, start_path, options
*  EQFANALYZEDOC folder, list_of_files, memory, options
*  EQFCREATECOUNTREPORT folder, list_of_files, output_file, report, type, profile, options
*  EQFANALYZEDOCEX  folder, list_of_files, memory, analysis_profile, unused, options
*  EQFARCHIVETM folder, drive, list_of_files, memory, options
*  EQFCREATECNTREPORT   drive, folder, list_of_files, report_type,   
                              output_file, format, profile, settings, factsheet, column,    
                              category, final_factors, security, single_shipmentf
*  EQFEXPORTFOLDERFPAS  folder, target_path, export_as, options,  
                              list_of_files, description, memory_export_as
*  EQFDELETEFOLDER folder
*  EQFDELETEMTLOG folder
*  EQFDELETEMEM memory
*  EQFORGANIZEMEM memory
*  EQFCHANGEMFLAG memory, action
*  EQFCREATEFOLDER folder, description, drive, memory, markup, editor, list_of_dictionaries, source_language, target_language, conversion, list_of_read-only_memories
*  EQFCREATECONTROLLEDFOLDER folder, description, target_drive, memory, markup, 
                                      editor, list_of_dictionaries, source_language,       
                                        target_language, conversion,
                                      list_of_read-only- memories, password, 
                                      coordinator_name, coordinator_mail, translator, 
                                      translator_mail, product_name, product_family, 
                                      similar_product, product_dict, previos_version,
                                      version, shipment
*  EQFCHANGEFOLPROPSEX folder, drive, target_language, memory, list_of_dictionaries, list_of_read-only_memories
*  EQFCHANGEFOLPROPS folder, drive, target_language, memory, list_of_dictionaries