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_TIME. They correspond to the data types described in the documentation:

  • VT_BOOL → BOOL
  • VT_INT, VT_DINT, VT_LINT, … → Integer types
  • VT_REAL, VT_LREAL → Floating-point types
  • VT_TIME, VT_DATE, VT_TOD, VT_DT → Time and date types

Placeholders such as ANY_NUM, ANY_INT, or ANY refer to type families (e.g., “all numerical types”).
The exact mapping is described in the chapter Architecture & Internals.

Functions

NameShort DescriptionParameters (IEC-style)Return
ABSAbsolute value of a number.x: ANY_NUMVT_DINT
ACOSSee implementation.-VT_LREAL
ADDAddition.a: ANY_NUM, b: ANY_NUMVT_DINT
ADD_DT_TIMESee implementation.-VT_DT
ADD_TIMETime addition.t1: TIME, t2: TIMEVT_TIME
ANDLogical conjunction (AND).a: BOOL, b: BOOLVT_DWORD
ASINSee implementation.-VT_LREAL
ATANSee implementation.-VT_LREAL
CEILRound upward toward +∞.x: REAL/LREALVT_LREAL
COSTrigonometric function (radians).x: REAL/LREAL (angle in rad)VT_LREAL
DATE_TO_DTCombines date and time-of-day into DateTime.date: DATE, tod: TODVT_DT
DIVDivision.a: ANY_NUM, b: ANY_NUMVT_DINT
DT_TO_DATEExtracts date from DateTime.dt: DTVT_DATE
DT_TO_TODExtracts time-of-day from DateTime.dt: DTVT_TOD
EQSee implementation.-VT_BOOL
EXPExponential function e^x.x: REAL/LREALVT_LREAL
EXPTPower x^y.x: REAL/LREAL, y: REAL/LREALVT_LREAL
FLOORRound downward toward −∞.x: REAL/LREALVT_LREAL
GESee implementation.-VT_BOOL
GTSee implementation.-VT_BOOL
LESee implementation.-VT_BOOL
LIMITClamps x to [min,max] (saturating).min: ANY_NUM, x: ANY_NUM, max: ANY_NUMVT_DINT
LNNatural logarithm.x: REAL/LREALVT_LREAL
LOGDecimal logarithm (base 10).x: REAL/LREALVT_LREAL
LTSee implementation.-VT_BOOL
MAKE_DTSee implementation.-VT_DT
MAXLarger value.a: ANY_NUM, b: ANY_NUMVT_DINT
MINSmaller value.a: ANY_NUM, b: ANY_NUMVT_DINT
MODInteger remainder.a: ANY_NUM, b: ANY_NUMVT_DINT
MULMultiplication.a: ANY_NUM, b: ANY_NUMVT_DINT
MUXMultiplexer: selects a (FALSE) or b (TRUE).sel: BOOL, a: ANY, b: ANYVT_LREAL
NESee implementation.-VT_BOOL
ORLogical disjunction (OR).a: BOOL, b: BOOLVT_DWORD
POWPower x^y.x: REAL/LREAL, y: REAL/LREALVT_LREAL
ROLBit rotation left.x: ANY_INT, n: INT (bits)VT_DWORD
RORBit rotation right.x: ANY_INT, n: INT (bits)VT_DWORD
ROUNDRounds to nearest integer.x: REAL/LREALVT_LREAL
SELSelector: chooses a (FALSE) or b (TRUE).sel: BOOL, a: ANY, b: ANYVT_DINT
SGNSee implementation.-VT_DINT
SHLBit shift left.x: ANY_INT, n: INT (bits)VT_DWORD
SHRBit shift right.x: ANY_INT, n: INT (bits)VT_DWORD
SINTrigonometric function (radians).x: REAL/LREAL (angle in rad)VT_LREAL
SQRTSquare root (x ≥ 0).x: REAL/LREALVT_LREAL
SUBSubtraction.a: ANY_NUM, b: ANY_NUMVT_DINT
SUB_DT_TIMESee implementation.-VT_DT
SUB_TIMETime difference.t1: TIME, t2: TIMEVT_TIME
TANTrigonometric function (radians).x: REAL/LREAL (angle in rad)VT_LREAL
TIME_TO_INTSee implementation.-VT_DINT
TIME_TO_REALSee implementation.-VT_LREAL
TOD_TO_DTSee implementation.-VT_DT
TO_BOOLType conversion to BOOL.x: ANYVT_BOOL
TO_DINTType conversion to DINT.x: ANYVT_DINT
TO_INTType conversion to INT.x: ANYVT_DINT
TO_LINTType conversion to LINT.x: ANYVT_LINT
TO_LREALType conversion to LREAL.x: ANYVT_LREAL
TO_REALType conversion to REAL.x: ANYVT_LREAL
TO_SINTType conversion to SINT.x: ANYVT_SINT
TO_TIMEType conversion to TIME.x: ANYVT_TIME
TO_UDINTType conversion to UDINT.x: ANYVT_UDINT
TO_UINTType conversion to UINT.x: ANYVT_UDINT
TO_ULINTType conversion to ULINT.x: ANYVT_ULINT
TO_USINTType conversion to USINT.x: ANYVT_USINT
TRUNCTruncates fractional part.x: REAL/LREALVT_LREAL
XORLogical exclusive OR.a: BOOL, b: BOOLVT_DWORD

Blocks

CTD – Down Counter

Down-counter with preset value. On each rising edge at the count input, the counter value is decremented; Q remains TRUE as long as CV is greater than 0.

Input

NameTypeMeaning
CDVT_BOOLCount-down; rising edge decrements.
PVVT_INTStart value.

Output

NameTypeMeaning
QVT_BOOLTRUE as long as CV > 0.
CVVT_INTCurrent value; counter state.

CTU – Up Counter

Up-counter with preset value. On each rising edge at the count input, the counter value is incremented; Q becomes TRUE once the value reaches or exceeds the preset.

Input

NameTypeMeaning
CUVT_BOOLCount-up; rising edge increments.
PVVT_INTPreset threshold.

Output

NameTypeMeaning
QVT_BOOLTRUE if CV ≥ PV.
CVVT_INTCurrent value; counter state.

CTUD – Up/Down Counter

Combined up/down counter with separate inputs. Useful when two events must be counted against each other (e.g., entries and exits of a system).

Input

NameTypeMeaning
CUVT_BOOLCount-up; rising edge increments.
CDVT_BOOLCount-down; rising edge decrements.
PVVT_INTPreset/start value.

Output

NameTypeMeaning
QVT_BOOLTRUE if CV ≥ PV.
CVVT_INTCurrent value; counter state.

F_TRIG – Falling Edge Trigger

Falling-edge detector: outputs TRUE for exactly one cycle when the input transitions from TRUE to FALSE.

Input

NameTypeMeaning
CLKVT_BOOLSignal; falling edge is detected.

Output

NameTypeMeaning
QVT_BOOLTRUE for one cycle on falling edge.

RS – RS Latch

Set/Reset latch. A TRUE signal at the set input sets the output to TRUE permanently; a TRUE signal at reset clears it. Reset dominates.

Input

NameTypeMeaning
RVT_BOOLReset; TRUE clears Q (reset dominates).
SVT_BOOLSet; TRUE sets Q.

Output

NameTypeMeaning
QVT_BOOLStored output (reset dominates).

R_TRIG – Rising Edge Trigger

Rising-edge detector: outputs TRUE for exactly one cycle when the input transitions from FALSE to TRUE.

Input

NameTypeMeaning
CLKVT_BOOLSignal; rising edge is detected.

Output

NameTypeMeaning
QVT_BOOLTRUE for one cycle on rising edge.

SR – SR Latch

Set/Reset latch with set-priority. Used when the set state should dominate.

Input

NameTypeMeaning
SVT_BOOLSet; TRUE sets Q.
RVT_BOOLReset; TRUE clears Q.

Output

NameTypeMeaning
QVT_BOOLStored output (set dominates).

TOF – Off-Delay Timer

Off-delay timer. Q is TRUE as long as IN is TRUE, and after IN falls to FALSE it stays TRUE for duration PT.

Input

NameTypeMeaning
INVT_BOOLInput; FALSE starts delay.
PTVT_TIMEPreset time; delay duration.

Output

NameTypeMeaning
QVT_BOOLTRUE while IN=TRUE or delay active.
ETVT_TIMEElapsed time since IN=FALSE.

TON – On-Delay Timer

On-delay timer. When IN becomes TRUE, timing starts; Q becomes TRUE once IN has remained TRUE for at least PT.

Input

NameTypeMeaning
INVT_BOOLInput; TRUE starts/continues timing.
PTVT_TIMEPreset time; required duration.

Output

NameTypeMeaning
QVT_BOOLTRUE if IN ≥ PT.
ETVT_TIMEElapsed time.

TP – Pulse Timer

Pulse block. On a rising edge at IN, Q becomes TRUE for duration PT — regardless of how long IN remains TRUE.

Input

NameTypeMeaning
INVT_BOOLTrigger; rising edge starts pulse.
PTVT_TIMEPulse length.

Output

NameTypeMeaning
QVT_BOOLTRUE for PT after trigger.