Comments in st, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 769

Advertising
background image

L-force | PLC Designer

General Editors

DMS 4.1 EN 03/2011 TD29

767

JMP <label>;
The <label> is an arbirary, but unambiguous identifier that is placed at the beginning
of a program line. The instruction JMP has to be followed by the indication of the jump
destination that has to equal a predefined label. When arriving the JMP instruction a
flyback to the program line that is provided with the indicated label will be effected.

Note: The programmer has to avoid the creation of endless loops, for example by
subjecting the jump to an IF condition.

Example:

i:=0;
label1: i:=i+1;
(*instructions*)
IF (i<10) JMP label1;

As long as the variable i being initialized with 0 has a value less than 10, the
conditional jump instruction of the example above will effect a repeated flyback to the
program line provided with label label1 and therefor it will effect a repeated
processing of the instructions comprised between the label and the JMP instruction.
Since these instructions include also the increment of the variable i, we can be sure
that the jump condition will be infringed (at the 9th check) and program flow will be
proceeded.
This functionality may also be achieved by using a WHILE or REPEAT loop in the
example. Generally the use of jump instructions can and should be avoided, because
they reduce the readability of the code.

Comments in ST
There are two possibilities to write comments in a Structured Text object.
1. Start the comment with „(*" and close it with „*)". This allows comments which run
over several lines. Example: "(*This is a comment.*)"
2. Single line comments as an extension to the IEC 61131-3 standard: "//" denotes the
start of a comment that ends with the end of the line. Example: "// This is a comment."
The comments can be placed everywhere within the declaration or implementation
part of the ST-Editor.

Advertising