Appearance
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→ BOOLVT_INT,VT_DINT,VT_LINT, … → Integer typesVT_REAL,VT_LREAL→ Floating-point typesVT_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
| Name | Short Description | Parameters (IEC-style) | Return |
|---|---|---|---|
| ABS | Absolute value of a number. | x: ANY_NUM | VT_DINT |
| ACOS | See implementation. | - | VT_LREAL |
| ADD | Addition. | a: ANY_NUM, b: ANY_NUM | VT_DINT |
| ADD_DT_TIME | See implementation. | - | VT_DT |
| ADD_TIME | Time addition. | t1: TIME, t2: TIME | VT_TIME |
| AND | Logical conjunction (AND). | a: BOOL, b: BOOL | VT_DWORD |
| ASIN | See implementation. | - | VT_LREAL |
| ATAN | See implementation. | - | VT_LREAL |
| CEIL | Round upward toward +∞. | x: REAL/LREAL | VT_LREAL |
| COS | Trigonometric function (radians). | x: REAL/LREAL (angle in rad) | VT_LREAL |
| DATE_TO_DT | Combines date and time-of-day into DateTime. | date: DATE, tod: TOD | VT_DT |
| DIV | Division. | a: ANY_NUM, b: ANY_NUM | VT_DINT |
| DT_TO_DATE | Extracts date from DateTime. | dt: DT | VT_DATE |
| DT_TO_TOD | Extracts time-of-day from DateTime. | dt: DT | VT_TOD |
| EQ | See implementation. | - | VT_BOOL |
| EXP | Exponential function e^x. | x: REAL/LREAL | VT_LREAL |
| EXPT | Power x^y. | x: REAL/LREAL, y: REAL/LREAL | VT_LREAL |
| FLOOR | Round downward toward −∞. | x: REAL/LREAL | VT_LREAL |
| GE | See implementation. | - | VT_BOOL |
| GT | See implementation. | - | VT_BOOL |
| LE | See implementation. | - | VT_BOOL |
| LIMIT | Clamps x to [min,max] (saturating). | min: ANY_NUM, x: ANY_NUM, max: ANY_NUM | VT_DINT |
| LN | Natural logarithm. | x: REAL/LREAL | VT_LREAL |
| LOG | Decimal logarithm (base 10). | x: REAL/LREAL | VT_LREAL |
| LT | See implementation. | - | VT_BOOL |
| MAKE_DT | See implementation. | - | VT_DT |
| MAX | Larger value. | a: ANY_NUM, b: ANY_NUM | VT_DINT |
| MIN | Smaller value. | a: ANY_NUM, b: ANY_NUM | VT_DINT |
| MOD | Integer remainder. | a: ANY_NUM, b: ANY_NUM | VT_DINT |
| MUL | Multiplication. | a: ANY_NUM, b: ANY_NUM | VT_DINT |
| MUX | Multiplexer: selects a (FALSE) or b (TRUE). | sel: BOOL, a: ANY, b: ANY | VT_LREAL |
| NE | See implementation. | - | VT_BOOL |
| OR | Logical disjunction (OR). | a: BOOL, b: BOOL | VT_DWORD |
| POW | Power x^y. | x: REAL/LREAL, y: REAL/LREAL | VT_LREAL |
| ROL | Bit rotation left. | x: ANY_INT, n: INT (bits) | VT_DWORD |
| ROR | Bit rotation right. | x: ANY_INT, n: INT (bits) | VT_DWORD |
| ROUND | Rounds to nearest integer. | x: REAL/LREAL | VT_LREAL |
| SEL | Selector: chooses a (FALSE) or b (TRUE). | sel: BOOL, a: ANY, b: ANY | VT_DINT |
| SGN | See implementation. | - | VT_DINT |
| SHL | Bit shift left. | x: ANY_INT, n: INT (bits) | VT_DWORD |
| SHR | Bit shift right. | x: ANY_INT, n: INT (bits) | VT_DWORD |
| SIN | Trigonometric function (radians). | x: REAL/LREAL (angle in rad) | VT_LREAL |
| SQRT | Square root (x ≥ 0). | x: REAL/LREAL | VT_LREAL |
| SUB | Subtraction. | a: ANY_NUM, b: ANY_NUM | VT_DINT |
| SUB_DT_TIME | See implementation. | - | VT_DT |
| SUB_TIME | Time difference. | t1: TIME, t2: TIME | VT_TIME |
| TAN | Trigonometric function (radians). | x: REAL/LREAL (angle in rad) | VT_LREAL |
| TIME_TO_INT | See implementation. | - | VT_DINT |
| TIME_TO_REAL | See implementation. | - | VT_LREAL |
| TOD_TO_DT | See implementation. | - | VT_DT |
| TO_BOOL | Type conversion to BOOL. | x: ANY | VT_BOOL |
| TO_DINT | Type conversion to DINT. | x: ANY | VT_DINT |
| TO_INT | Type conversion to INT. | x: ANY | VT_DINT |
| TO_LINT | Type conversion to LINT. | x: ANY | VT_LINT |
| TO_LREAL | Type conversion to LREAL. | x: ANY | VT_LREAL |
| TO_REAL | Type conversion to REAL. | x: ANY | VT_LREAL |
| TO_SINT | Type conversion to SINT. | x: ANY | VT_SINT |
| TO_TIME | Type conversion to TIME. | x: ANY | VT_TIME |
| TO_UDINT | Type conversion to UDINT. | x: ANY | VT_UDINT |
| TO_UINT | Type conversion to UINT. | x: ANY | VT_UDINT |
| TO_ULINT | Type conversion to ULINT. | x: ANY | VT_ULINT |
| TO_USINT | Type conversion to USINT. | x: ANY | VT_USINT |
| TRUNC | Truncates fractional part. | x: REAL/LREAL | VT_LREAL |
| XOR | Logical exclusive OR. | a: BOOL, b: BOOL | VT_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
| Name | Type | Meaning |
|---|---|---|
| CD | VT_BOOL | Count-down; rising edge decrements. |
| PV | VT_INT | Start value. |
Output
| Name | Type | Meaning |
|---|---|---|
| Q | VT_BOOL | TRUE as long as CV > 0. |
| CV | VT_INT | Current 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
| Name | Type | Meaning |
|---|---|---|
| CU | VT_BOOL | Count-up; rising edge increments. |
| PV | VT_INT | Preset threshold. |
Output
| Name | Type | Meaning |
|---|---|---|
| Q | VT_BOOL | TRUE if CV ≥ PV. |
| CV | VT_INT | Current 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
| Name | Type | Meaning |
|---|---|---|
| CU | VT_BOOL | Count-up; rising edge increments. |
| CD | VT_BOOL | Count-down; rising edge decrements. |
| PV | VT_INT | Preset/start value. |
Output
| Name | Type | Meaning |
|---|---|---|
| Q | VT_BOOL | TRUE if CV ≥ PV. |
| CV | VT_INT | Current 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
| Name | Type | Meaning |
|---|---|---|
| CLK | VT_BOOL | Signal; falling edge is detected. |
Output
| Name | Type | Meaning |
|---|---|---|
| Q | VT_BOOL | TRUE 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
| Name | Type | Meaning |
|---|---|---|
| R | VT_BOOL | Reset; TRUE clears Q (reset dominates). |
| S | VT_BOOL | Set; TRUE sets Q. |
Output
| Name | Type | Meaning |
|---|---|---|
| Q | VT_BOOL | Stored 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
| Name | Type | Meaning |
|---|---|---|
| CLK | VT_BOOL | Signal; rising edge is detected. |
Output
| Name | Type | Meaning |
|---|---|---|
| Q | VT_BOOL | TRUE for one cycle on rising edge. |
SR – SR Latch
Set/Reset latch with set-priority. Used when the set state should dominate.
Input
| Name | Type | Meaning |
|---|---|---|
| S | VT_BOOL | Set; TRUE sets Q. |
| R | VT_BOOL | Reset; TRUE clears Q. |
Output
| Name | Type | Meaning |
|---|---|---|
| Q | VT_BOOL | Stored 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
| Name | Type | Meaning |
|---|---|---|
| IN | VT_BOOL | Input; FALSE starts delay. |
| PT | VT_TIME | Preset time; delay duration. |
Output
| Name | Type | Meaning |
|---|---|---|
| Q | VT_BOOL | TRUE while IN=TRUE or delay active. |
| ET | VT_TIME | Elapsed 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
| Name | Type | Meaning |
|---|---|---|
| IN | VT_BOOL | Input; TRUE starts/continues timing. |
| PT | VT_TIME | Preset time; required duration. |
Output
| Name | Type | Meaning |
|---|---|---|
| Q | VT_BOOL | TRUE if IN ≥ PT. |
| ET | VT_TIME | Elapsed 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
| Name | Type | Meaning |
|---|---|---|
| IN | VT_BOOL | Trigger; rising edge starts pulse. |
| PT | VT_TIME | Pulse length. |
Output
| Name | Type | Meaning |
|---|---|---|
| Q | VT_BOOL | TRUE for PT after trigger. |