
- 29 -
TESTING VALUES (IF - ELSE)
It is possible to test values and take different actions based on what was found. The
general form is as follows:
IF(test)
{
// this block is executed if the test was true
}
ELSE // The else is optional and may be left out if not needed
{
//this block is executed if the test was false
}
This can be used to selectively log data, for example. As an example, if you only
want to log turbidity values if they are greater than a certain threshold, then your
program may look like:
{
// initialization block
Thresh = 50;
// only log if turbidity > 50ntu threshold
}
EVERY 3600
// check value hourly
{
IF(Turb > Thresh)
// read turbidity and compare to threshold
{
LOG(Turb);
// was higher, so log turbidity
}
}
The tests that are allowed are as follows:
==
equal
!=
not equal
>
greater than
>=
greater than or equal
<
less than
<=
less than or equal
In addition, tests may be combined using:
&&
And
||
Or (the key used is the broken bar or "pipe", usually the shift of
\
on
most keyboards)
These are used as in:
IF((A > 5) && (B > 37))
IF - ELSE statements may be nested. Timers may not be inside them. The degree of
nesting allowed is not fixed, but depends on the available memory at compile time.
This memory is allocated to variable definitions, sensor set definitions, and compiled
program. A very large program will not allow as deep a nesting as a very simple
program, and there is no way to determine this without sending the program to the
data logger and seeing if it compiles.
Содержание HDL1
Страница 1: ...HDL1 HDL1 G5 Data Logger Operating Manual...
Страница 2: ......
Страница 8: ...iv THIS PAGE INTENTIONALLY LEFT BLANK...
Страница 12: ...4 THIS PAGE INTENTIONALLY LEFT BLANK...
Страница 20: ...12 THIS PAGE INTENTIONALLY LEFT BLANK...
Страница 42: ...34 THIS PAGE INTENTIONALLY LEFT BLANK...