İçeriğe geç
İletişim Başlayın

Built-in Functions

Bu içerik henüz dilinizde mevcut değil.

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.

FunctionArgumentsReturnsWhat it does
ABSIN : ANY_NUMANY_NUMReturns the absolute value
SQRTIN : ANY_NUMANY_REALReturns the square root
LNIN : ANY_NUMANY_REALReturns the natural logarithm
LOGIN : ANY_NUMANY_REALReturns the base-10 logarithm
EXPIN : ANY_NUMANY_REALReturns e raised to the power of IN
SININ : ANY_NUMANY_REALReturns the sine
COSIN : ANY_NUMANY_REALReturns the cosine
TANIN : ANY_NUMANY_REALReturns the tangent
ASININ : ANY_NUMANY_REALReturns the arc sine
ACOSIN : ANY_NUMANY_REALReturns the arc cosine
ATANIN : ANY_NUMANY_REALReturns the arc tangent
EXPTIN1 : ANY_NUM, IN2 : ANY_NUMANY_REALReturns IN1 raised to the power of IN2
TRUNCIN : ANY_REALDINTTruncates a real number to an integer
FunctionArgumentsReturnsWhat it does
SHLIN : ANY_BIT, N : ANY_INTANY_BITShift left
SHRIN : ANY_BIT, N : ANY_INTANY_BITShift right
ROLIN : ANY_BIT, N : ANY_INTANY_BITRotate left
RORIN : ANY_BIT, N : ANY_INTANY_BITRotate right
FunctionArgumentsReturnsWhat it does
SELG : BOOL, IN0 : ANY, IN1 : ANYANYBinary selection
MAXIN1 : ANY, IN2 : ANYANYReturns the maximum value
MININ1 : ANY, IN2 : ANYANYReturns the minimum value
LIMITMN : ANY, IN : ANY, MX : ANYANYLimits the value between MN and MX
MUXK : ANY_INT, IN0 : ANYANYMultiplexer - selects one of multiple inputs
FunctionArgumentsReturnsWhat it does
LENIN : STRINGBYTEReturns the length of a string
LEFTIN : STRING, L : ANY_INTSTRINGReturns the leftmost L characters
RIGHTIN : STRING, L : ANY_INTSTRINGReturns the rightmost L characters
MIDIN : STRING, L : ANY_INT, P : ANY_INTSTRINGReturns L characters starting at position P
CONCATIN1 : STRING, IN2 : STRINGSTRINGConcatenates two strings
INSERTIN1 : STRING, IN2 : STRING, P : ANY_INTSTRINGInserts IN2 into IN1 at position P
DELETEIN : STRING, L : ANY_INT, P : ANY_INTSTRINGDeletes L characters starting at position P
REPLACEIN1 : STRING, IN2 : STRING, L : ANY_INT, P : ANY_INTSTRINGReplaces L characters at position P with IN2
FINDIN1 : STRING, IN2 : STRINGBYTEFinds the position of IN2 in IN1
FunctionArgumentsReturnsWhat it does
MOVEIN : ANYANYMoves a value (pass-through)
REFIN : ANYREFERENCE TO ANYReturns a reference to a variable
SIZEOFIN : ANYINTReturns the size in bytes
FunctionArgumentsReturnsWhat it does
MEMCPYdestAddr : PVOID, srcAddr : PVOID, n : UDINTUDINTCopies n bytes from src to dst (no overlap support)
MEMSETdestAddr : PVOID, fillByte : USINT, n : UDINTUDINTFills n bytes at dst with fillByte
MEMMOVEdestAddr : PVOID, srcAddr : PVOID, n : UDINTUDINTCopies n bytes from src to dst (overlap-safe)
FunctionArgumentsReturnsWhat it does
TO_BOOLIN : ANYBOOLConverts a value to BOOL
TO_BYTEIN : ANYBYTEConverts a value to BYTE
TO_WORDIN : ANYWORDConverts a value to WORD
TO_DWORDIN : ANYDWORDConverts a value to DWORD
TO_LWORDIN : ANYLWORDConverts a value to LWORD
TO_SINTIN : ANYSINTConverts a value to SINT
TO_USINTIN : ANYUSINTConverts a value to USINT
TO_INTIN : ANYINTConverts a value to INT
TO_UINTIN : ANYUINTConverts a value to UINT
TO_DINTIN : ANYDINTConverts a value to DINT
TO_UDINTIN : ANYUDINTConverts a value to UDINT
TO_LINTIN : ANYLINTConverts a value to LINT
TO_ULINTIN : ANYULINTConverts a value to ULINT
TO_REALIN : ANYREALConverts a value to REAL
TO_LREALIN : ANYLREALConverts a value to LREAL
TO_STRINGIN : ANYSTRINGConverts a value to STRING
TO_TIMEIN : ANYTIMEConverts a value to TIME
TO_DATEIN : ANYDATEConverts a value to DATE
TO_TODIN : ANYTODConverts a value to TOD
TO_DTIN : ANYDTConverts 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.