TestIT:Programming Functions

From Nolek Wiki
Jump to navigation Jump to search

5.3 Functions Window

The function window encompasses all the codes, which can be inserted in the program. To get information about the function, then, press on the wanted line and use the info button. When a function is going to be created, the wanted function can be selected, or if the code is known then it is possible to write it. To get help with filling in the function, the Config button can be selected and it will show the parameters. In symbol handler, it is possible to add a symbol, and it is also possible to insert a symbol in the function. To insert a symbol, just double-click on the wanted symbol.

5.3.1 Functions

If

Description:
Evaluates a statement and continues if true and skips if it is not true. It compares two values and is always used together with EndIf.

Code example:

Function.If(_B01,=,1)
'Code will only be executed if _B01 = 1
Function.EndIf()
Parameters
Parameter Type Description
Criteria1 Number or number symbol Value 1
Sign Sign Select sign to use for comparison. Must be (<,>, <>,=, >=, ⇐)
Criteria2 Number or number symbol Value 2

IfMinMax

Description:
Evaluates a value against a min. and max. It continues if the value is between the min. and max, and skips if it is not.

Code example:

Function.IfMinMax(_IN01,1,5)
'Code will only be executed if _IN01 is between 1 and 5
Function.EndIf()
Parameters
Parameter Type Description
Value/Symbol to compare Number or number symbol Value 1
Min value Number or number symbol Minimum value
Max value Number or number symbol Maximum value

EndIf

Description:
It is used together with If or IfMinMax. It will stop the if code.

Code example:

Function.If(_B01,=,1)
'Code will only be executed if _B01 = 1
Function.EndIf()

No parameters

Wait

Description:
It will wait until the time has run out or criteria is met.

Code example:

Function.Wait(_D01,>,10,30,S,_TO01)
Function.If(_TO01, =, 1)
'Code will enter if wait times out
Function.EndIf()
Parameters
Parameter Type Description
Criteria1 Number or number symbol Value 1
Sign Sign Select sign to use for comparison. Must be (<,>, <>,=, >=, ⇐)
Criteria2 Number or number symbol Value 2
Timeout Int or Int symbol Time before command times out
Time unit String Select the time unit from the list
Timeout active Bool symbol True if wait command times out

Sub

Description:
It is used to split the program up in smaller programs. The main sub is the sub which TestIT always starts in. The program cannot run if there is no main sub. It must always end with an EndSub.

Code example:

Function.Sub(1000)
'Execute this sub routine
Function.EndSub()
Parameters
Parameter Type Description
Sub name String Name of the sub. Must be unique in the program

EndSub

Description:
It is the end mark of a sub.

Code example:

Function.Sub(1000)
'Execute this sub routine
Function.EndSub()

No parameters

GoSub

Description:
It will jump to a specific sub.

Code example:

Function.GoSub(1000)
Parameters
Parameter Type Description
Sub name String Name of the sub.

Label

Description:
It will set a fix point to jump to.

Code example:

Function.Label(startLoop)
Parameters
Parameter Type Description
Label name String Name of the label. Must be unique within the sub

GoLabel

Description:
It will jump to a specific label.

Code example:

Function.GoLabel(startLoop)
Parameters
Parameter Type Description
Label name String Name of the label

Delay

Description:
It will delay the program, for a specified time.

Code example:

Function.Delay(30,S)
Parameters
Parameter Type Description
Delay time Int or Int symbol Delay time
Time unit String Time unit

StopTest

Description:
It will go to EndSub() in main sub.

Code example:

Function.StopTest()

No parameters

NewPart

Description:
It will clear the production window, the results, and prepare the production to run a new product.

Code example:

Function.NewPart()

No parameters
The command is often used together with a label that jumps to the beginning of the program.

Code example:

Function.NewPart()
Function.GoLabel(lbl_newPart)

IsValue

Description:
It will convert a symbol to a numeric value if it is possible.

Code example:

Function.IsValue(_D01,_B01,_ST01)
Parameters
Parameter Type Description
Result Double symbol Value or symbol to use
IsValue Bool symbol Time unit
ValueToTest String or String symbol String value to test

Back to Programming - Commands