Strings and Messages

toString

toString(<arg0>, …, <argN>): STRING

Converts and concatenates the given arguments to one string. This string is limited to 255 characters, which is the default string length. The toString-function behaves like the print function, except that it yields a formatted string instead of printing.

Strings and Messages 1:

The toString-function is especially useful to format a string for the msg(…)-function.

msg

msg(str:= String[81])

Send the given message to the message list of TwinCAT. The message is processed by the NC-channel synchronously. It appears in the user-interface when all preceeding NC-commands are completed.

To send formatted strings this function can be combined with the toString-function.

Strings and Messages 2:

The message is restricted to 81 characters. Text exceeding this restriction will be truncated.

Example:

The path of the following example is shown in Figure “ExampleMsg”. It is annotated with the emitted messages.

{
VAR
    x,y,z: LREAL;
    start: LDT;
END_VAR

!N10 G00 X0 Y0 F300
start := currentLdt();
!N20 G01 X30
msg('N20 completed');
!N30 X60 Y10
frameGet(x=>x,y=>y,z=>z);
msg(toString('Current position: [',x,',',y,',',z,']'));
!N40 X90
sync();
msg(toString('Machining time: ', currentLdt()-start));
}
M02
Strings and Messages 3:

Figure “ExampleMsg”.