printfPLCopen motion icon

FunctionClosedA function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. - Display a trace output.

Inputs

FMT : STRING       Trace message
ARG1..ARG4
: DINT  Numerical arguments to be included in the trace

Outputs

Q : BOOL  Return check

Remarks

This function works as the famous "printf" function of the "C" language, with up to 4 integer arguments. You can use the following pragmas in the FMT trace message to represent the arguments according to their left to the right order:

%ld    signed value in decimal
%lu    unsigned value in decimal
%lx    value in hexadecimal

The trace message is displayed in the LOG window with runtimeClosedIn computer science, runtime (or run-time) describes the operation of a computer program, the duration of its execution, from beginning to termination (compare compile time). Within KAS, runtime also refers to the virtual machine that manage the program written in a computer language while it is running messages. Trace is supported by the KAS Simulator.

Example

(* i1, i2, i3, i4 are declared as DINT *)
i1 := 1;
i2 := 2;
i3 := 3;
i4 := 4;
printf ('i1=%ld; i2=%ld; i3=%ld; i4=%ld', i1, i2, i3, i4);

Output message:

i1=1; i2=2; i3=3; i4=4;