Skip to content

Reference

This reference summarizes all built-in functions and standard blocks of the Coldwave Script-VM.
It is intended for users who are familiar with the basics of the language and want to look things up directly.

The tables show internally used type codes such as VT_DINT or VT_TOD. They correspond to the data types described in the documentation:

  • VT_BOOL → BOOL
  • VT_SINT, VT_INT, VT_DINT, VT_LINT → Signed integer types
  • VT_USINT, VT_UDINT, VT_ULINT → Unsigned integer types
  • VT_DWORD → DWORD
  • VT_LREAL → LREAL
  • VT_TIME, VT_DATE, VT_TOD, VT_DT → Time and date types

Note: Signatures reflect the metadata used by the VM’s builtin registry. Variadic functions accept additional arguments beyond the listed minimum.

Functions

NameShort DescriptionParameters (IEC-style)Return
ABSAbsolute value.X: DINTVT_DINT
ACOSMath function (radians for trig).X: LREALVT_LREAL
ADDAddition.IN1: DINT, IN2: DINT, ...VT_DINT
ADD_DT_TIMEDate/time arithmetic.DT: DT, T: TIMEVT_DT
ADD_TIMEDate/time arithmetic.T1: TIME, T2: TIMEVT_TIME
ANDBitwise AND (variadic).IN1: DWORD, IN2: DWORD, ...VT_DWORD
ASINMath function (radians for trig).X: LREALVT_LREAL
ATANMath function (radians for trig).X: LREALVT_LREAL
CEILRounding/truncation.X: LREALVT_LREAL
COSMath function (radians for trig).X: LREALVT_LREAL
CURRENT_TIMECurrent time-of-day (TOD).VT_TOD
DATE_TO_DTConvert DATE to DT (TOD = 0).DATE: DATEVT_DT
DIVDivision.A: DINT, B: DINTVT_DINT
DT_TO_DATEExtract DATE part from DT.DT: DTVT_DATE
DT_TO_TODExtract TOD part from DT.DT: DTVT_TOD
EQChain comparison: IN1 == IN2 == ... (variadic).IN1: LREAL, IN2: LREAL, ...VT_BOOL
EXPMath function (radians for trig).X: LREALVT_LREAL
EXPTPower function.X: LREAL, Y: LREALVT_LREAL
FLOORRounding/truncation.X: LREALVT_LREAL
GEChain comparison: IN1 >= IN2 >= ... (variadic).IN1: LREAL, IN2: LREAL, ...VT_BOOL
GTChain comparison: IN1 > IN2 > ... (variadic).IN1: LREAL, IN2: LREAL, ...VT_BOOL
LEChain comparison: IN1 <= IN2 <= ... (variadic).IN1: LREAL, IN2: LREAL, ...VT_BOOL
LIMITClamp X to [LO, HI].LO: DINT, X: DINT, HI: DINTVT_DINT
LNMath function (radians for trig).X: LREALVT_LREAL
LOGMath function (radians for trig).X: LREALVT_LREAL
LTChain comparison: IN1 < IN2 < ... (variadic).IN1: LREAL, IN2: LREAL, ...VT_BOOL
MAKE_DTCombine DATE and TOD into DT.DATE: DATE, TOD: TODVT_DT
MAXMaximum (variadic).IN1: DINT, IN2: DINT, ...VT_DINT
MINMinimum (variadic).IN1: DINT, IN2: DINT, ...VT_DINT
MODRemainder (modulo).A: DINT, B: DINTVT_DINT
MOVEPass-through (identity).IN: DINTVT_DINT
MULMultiplication.IN1: DINT, IN2: DINT, ...VT_DINT
MUXSelect one of IN0..INn by index K (variadic).K: DINT, IN0: LREAL, IN1: LREAL, ...VT_LREAL
NEPairwise comparison: IN1 != IN2 (binary).IN1: LREAL, IN2: LREALVT_BOOL
NOTBitwise NOT.IN: DWORDVT_DWORD
ORBitwise OR (variadic).IN1: DWORD, IN2: DWORD, ...VT_DWORD
POWPower function.X: LREAL, Y: LREALVT_LREAL
ROLRotate left.X: DWORD, N: DINTVT_DWORD
RORRotate right.X: DWORD, N: DINTVT_DWORD
ROUNDRounding/truncation.X: LREALVT_LREAL
SELSelect A or B based on G.G: BOOL, A: DINT, B: DINTVT_DINT
SGNSign function.X: LREALVT_DINT
SHLShift left.X: DWORD, N: DINTVT_DWORD
SHRShift right.X: DWORD, N: DINTVT_DWORD
SINMath function (radians for trig).X: LREALVT_LREAL
SQRTMath function (radians for trig).X: LREALVT_LREAL
SUBSubtraction.A: DINT, B: DINTVT_DINT
SUB_DT_TIMEDate/time arithmetic.DT: DT, T: TIMEVT_DT
SUB_TIMEDate/time arithmetic.T1: TIME, T2: TIMEVT_TIME
TANMath function (radians for trig).X: LREALVT_LREAL
TIME_TO_INTConvert TIME (ms) to DINT.T: TIMEVT_DINT
TIME_TO_REALConvert TIME (ms) to LREAL.T: TIMEVT_LREAL
TOD_TO_DTConvert TOD to DT (DATE = 0).TOD: TODVT_DT
TO_BOOLType conversion to BOOL.X: LREALVT_BOOL
TO_DINTType conversion to DINT.X: LREALVT_DINT
TO_INTType conversion to INT.X: LREALVT_DINT
TO_LINTType conversion to LINT.X: LREALVT_LINT
TO_LREALType conversion to LREAL.X: LREALVT_LREAL
TO_REALType conversion to REAL.X: LREALVT_LREAL
TO_SINTType conversion to SINT.X: LREALVT_SINT
TO_TIMEType conversion to TIME.X: LREALVT_TIME
TO_UDINTType conversion to UDINT.X: LREALVT_UDINT
TO_UINTType conversion to UINT.X: LREALVT_UDINT
TO_ULINTType conversion to ULINT.X: LREALVT_ULINT
TO_USINTType conversion to USINT.X: LREALVT_USINT
TRUNCRounding/truncation.X: LREALVT_DINT
XORBitwise XOR (variadic).IN1: DWORD, IN2: DWORD, ...VT_DWORD

Blocks

CTD – Down Counter

Down counter (decrements CV on rising edge of CD).

Input

NameTypeMeaning
CDVT_BOOLCount-down; rising edge decrements CV.
LDVT_BOOLLoad; loads PV into CV.
PVVT_INTPreset value.

Output

NameTypeMeaning
QVT_BOOLCounter output.
CVVT_INTCurrent value.

CTU – Up Counter

Up counter (increments CV on rising edge of CU).

Input

NameTypeMeaning
CUVT_BOOLCount-up; rising edge increments CV.
RVT_BOOLReset; sets CV := 0.
PVVT_INTPreset value.

Output

NameTypeMeaning
QVT_BOOLCounter output.
CVVT_INTCurrent value.

CTUD – Up/Down Counter

Up/down counter.

Input

NameTypeMeaning
CUVT_BOOLCount-up; rising edge increments CV.
CDVT_BOOLCount-down; rising edge decrements CV.
RVT_BOOLReset; sets CV := 0.
LDVT_BOOLLoad; loads PV into CV.
PVVT_INTPreset value.

Output

NameTypeMeaning
QUVT_BOOLTRUE if CV >= PV.
QDVT_BOOLTRUE if CV <= 0.
CVVT_INTCurrent value.

F_TRIG – Falling Edge Trigger

Falling edge trigger.

Input

NameTypeMeaning
CLKVT_BOOLClock input; edge detection.

Output

NameTypeMeaning
QVT_BOOLTRUE for one cycle on detected edge.

RS – Reset/Set Latch

Reset/Set latch (implemented with S priority).

Input

NameTypeMeaning
RVT_BOOLReset.
SVT_BOOLSet (priority).

Output

NameTypeMeaning
QVT_BOOLLatch output.

R_TRIG – Rising Edge Trigger

Rising edge trigger.

Input

NameTypeMeaning
CLKVT_BOOLClock input; edge detection.

Output

NameTypeMeaning
QVT_BOOLTRUE for one cycle on detected edge.

SR – Set/Reset Latch

Set/Reset latch (implemented with R priority).

Input

NameTypeMeaning
SVT_BOOLSet.
RVT_BOOLReset (priority).

Output

NameTypeMeaning
QVT_BOOLLatch output.

TOF – Off-delay Timer

Off-delay timer (Q stays TRUE for PT after IN becomes FALSE).

Input

NameTypeMeaning
INVT_BOOLEnable/trigger input.
PTVT_TIMEPreset time.

Output

NameTypeMeaning
QVT_BOOLTimer output.
ETVT_TIMEElapsed time.

TON – On-delay Timer

On-delay timer (Q becomes TRUE after IN has been TRUE for PT).

Input

NameTypeMeaning
INVT_BOOLEnable/trigger input.
PTVT_TIMEPreset time.

Output

NameTypeMeaning
QVT_BOOLTimer output.
ETVT_TIMEElapsed time.

TP – Pulse Timer

Pulse timer (Q becomes TRUE for PT on rising edge of IN).

Input

NameTypeMeaning
INVT_BOOLEnable/trigger input.
PTVT_TIMEPreset time.

Output

NameTypeMeaning
QVT_BOOLTimer output.
ETVT_TIMEElapsed time.