Data Sheet
dScript
dScript User Manual v2.15
Constant declarations
const Minus17 -17
const LogArraySize 24
var TemperatureLog[LogArraySize]
var StartTemp
Declaring numbers that can be used many times in your program as const can save time if
you need to change it. Use the const anywhere in your program where you would otherwise
use the number.
main: StartTemp = Minus17
...
Constants can also have an expression as the parameter. All elements of the expression must
themselves be constant, which means you cannot use variables.
const FILTCTRL 4
const FILTREF 1<<(FILTCTRL-1)
const FILTMOD 1<<FILTCTRL
All expressions are evaluated from left to right, there is no operator precedence. If you need to
change the order of evaluation then enclose that section in parenthesis. In the example above
(FILTCTRL-1) is evaluated first and the result used to shift the 1 left by that many places. Any
named constants used in the expression must have already been declared.
Note that all constant expressions are evaluated by the compiler when the program is
compiled, not on the board at runtime.
Copyright © 2016, Devantech Ltd.
All rights reserved.
www.robot-electronics.co.uk
9