Data Sheet

dScript
dScript User Manual v2.15
Expressions
Expressions are a sequence of variables and operators. They are used to assign values to
either numeric or string variables.
Numeric expressions
X = A + B
This will add the variables A and B together and assign the result to variable X. An expression
may have any number of operations.
X = A + B * C
Expressions are always evaluated from left to right. No precedence is given to multiply and
divide as some compilers do. If A=2, B=3 and C=4 then the expression above will yield 20.
2 + 3 = 5
5 * 4 = 20
Parenthesis may be used to change the order the expression is evaluated.
X = A + (B * C)
will give the result 14
This following expression will use the raw value from the ADC (Analogue to Digital Converter)
and scale this to read temperature in degrees C.
Temperature = ((ADC2*3223)-500000)/10000
Although the parenthesis is not actually required here as we want to evaluate from left to
right, it is included for clarity. The following works just as well:
Temperature = ADC2*3223-500000/10000
X = X + 1
X += 1
The above expressions are functionally identical
Copyright © 2016, Devantech Ltd.
All rights reserved.
www.robot-electronics.co.uk
20