These come with the compiler rather than with a package, so they are callable in any
project with nothing ticked on PLC Libraries. The tree lists them under Built-in.
TO_ on its own takes its target type from what it is being assigned to, so a conversion
into a variable’s own type is written once rather than twice.
A conversion that only gains room happens on its own: INT into DINT, INT into
REAL, STRING into WSTRING. One that can lose something has to be written out, so
DINT into INT, LREAL into REAL and REAL into any integer are refused
until a conversion appears, and a BOOL takes TRUE, FALSE, 0 or 1 and
nothing else.
| Function | Arguments | Returns | What it does |
|---|
ABS | IN : ANY_NUM | ANY_NUM | Returns the absolute value |
SQRT | IN : ANY_NUM | ANY_REAL | Returns the square root |
LN | IN : ANY_NUM | ANY_REAL | Returns the natural logarithm |
LOG | IN : ANY_NUM | ANY_REAL | Returns the base-10 logarithm |
EXP | IN : ANY_NUM | ANY_REAL | Returns e raised to the power of IN |
SIN | IN : ANY_NUM | ANY_REAL | Returns the sine |
COS | IN : ANY_NUM | ANY_REAL | Returns the cosine |
TAN | IN : ANY_NUM | ANY_REAL | Returns the tangent |
ASIN | IN : ANY_NUM | ANY_REAL | Returns the arc sine |
ACOS | IN : ANY_NUM | ANY_REAL | Returns the arc cosine |
ATAN | IN : ANY_NUM | ANY_REAL | Returns the arc tangent |
EXPT | IN1 : ANY_NUM, IN2 : ANY_NUM | ANY_REAL | Returns IN1 raised to the power of IN2 |
TRUNC | IN : ANY_REAL | DINT | Truncates a real number to an integer |
| Function | Arguments | Returns | What it does |
|---|
SHL | IN : ANY_BIT, N : ANY_INT | ANY_BIT | Shift left |
SHR | IN : ANY_BIT, N : ANY_INT | ANY_BIT | Shift right |
ROL | IN : ANY_BIT, N : ANY_INT | ANY_BIT | Rotate left |
ROR | IN : ANY_BIT, N : ANY_INT | ANY_BIT | Rotate right |
| Function | Arguments | Returns | What it does |
|---|
SEL | G : BOOL, IN0 : ANY, IN1 : ANY | ANY | Binary selection |
MAX | IN1 : ANY, IN2 : ANY | ANY | Returns the maximum value |
MIN | IN1 : ANY, IN2 : ANY | ANY | Returns the minimum value |
LIMIT | MN : ANY, IN : ANY, MX : ANY | ANY | Limits the value between MN and MX |
MUX | K : ANY_INT, IN0 : ANY | ANY | Multiplexer - selects one of multiple inputs |
| Function | Arguments | Returns | What it does |
|---|
LEN | IN : STRING | BYTE | Returns the length of a string |
LEFT | IN : STRING, L : ANY_INT | STRING | Returns the leftmost L characters |
RIGHT | IN : STRING, L : ANY_INT | STRING | Returns the rightmost L characters |
MID | IN : STRING, L : ANY_INT, P : ANY_INT | STRING | Returns L characters starting at position P |
CONCAT | IN1 : STRING, IN2 : STRING | STRING | Concatenates two strings |
INSERT | IN1 : STRING, IN2 : STRING, P : ANY_INT | STRING | Inserts IN2 into IN1 at position P |
DELETE | IN : STRING, L : ANY_INT, P : ANY_INT | STRING | Deletes L characters starting at position P |
REPLACE | IN1 : STRING, IN2 : STRING, L : ANY_INT, P : ANY_INT | STRING | Replaces L characters at position P with IN2 |
FIND | IN1 : STRING, IN2 : STRING | BYTE | Finds the position of IN2 in IN1 |
| Function | Arguments | Returns | What it does |
|---|
MOVE | IN : ANY | ANY | Moves a value (pass-through) |
REF | IN : ANY | REFERENCE TO ANY | Returns a reference to a variable |
SIZEOF | IN : ANY | INT | Returns the size in bytes |
| Function | Arguments | Returns | What it does |
|---|
MEMCPY | destAddr : PVOID, srcAddr : PVOID, n : UDINT | UDINT | Copies n bytes from src to dst (no overlap support) |
MEMSET | destAddr : PVOID, fillByte : USINT, n : UDINT | UDINT | Fills n bytes at dst with fillByte |
MEMMOVE | destAddr : PVOID, srcAddr : PVOID, n : UDINT | UDINT | Copies n bytes from src to dst (overlap-safe) |
| Function | Arguments | Returns | What it does |
|---|
TO_BOOL | IN : ANY | BOOL | Converts a value to BOOL |
TO_BYTE | IN : ANY | BYTE | Converts a value to BYTE |
TO_WORD | IN : ANY | WORD | Converts a value to WORD |
TO_DWORD | IN : ANY | DWORD | Converts a value to DWORD |
TO_LWORD | IN : ANY | LWORD | Converts a value to LWORD |
TO_SINT | IN : ANY | SINT | Converts a value to SINT |
TO_USINT | IN : ANY | USINT | Converts a value to USINT |
TO_INT | IN : ANY | INT | Converts a value to INT |
TO_UINT | IN : ANY | UINT | Converts a value to UINT |
TO_DINT | IN : ANY | DINT | Converts a value to DINT |
TO_UDINT | IN : ANY | UDINT | Converts a value to UDINT |
TO_LINT | IN : ANY | LINT | Converts a value to LINT |
TO_ULINT | IN : ANY | ULINT | Converts a value to ULINT |
TO_REAL | IN : ANY | REAL | Converts a value to REAL |
TO_LREAL | IN : ANY | LREAL | Converts a value to LREAL |
TO_STRING | IN : ANY | STRING | Converts a value to STRING |
TO_TIME | IN : ANY | TIME | Converts a value to TIME |
TO_DATE | IN : ANY | DATE | Converts a value to DATE |
TO_TOD | IN : ANY | TOD | Converts a value to TOD |
TO_DT | IN : ANY | DT | Converts a value to DT |
Additional type conversion functions follow the pattern <SOURCE_TYPE>TO<DEST_TYPE> (for example INT_TO_REAL, BOOL_TO_STRING). All numeric and bitstring type conversions are supported.