Sensaphone SCADA 3000 Users manual User Manual
Page 191
16-5
Chapter 16: Programming in C
IF - Used to make decisions.
Example:
main ()
{
if (read_uaf(input,0,0)>100)
{
write_uaf(output,0,0,on);
}
}
ELSE - Used with IF to execute a statement when the IF condition is false.
Example:
main ()
{
if (read_uaf(input,0,0)>100)
{
write_uaf(output,0,0,on);
}
else
{
write_uaf(output,0,0,off);
}
}
FOR - Used to execute a statement (or statements) multiple times. Contains a start condi-
tion, a stop condition, and a control statement. The following example starts a counter at one,
checks that it is less than nine, and executes the output statement. Then it adds one to the
counter and checks that it is still less than nine. When the counter equals nine, the FOR loop
is finished. The output statement in this program turns outputs 0 through 8 off, on the main
board.
float count;
main ()
{
for (count=0; count<9; count=count+1)
{
write_uaf(output,0,count,off);
}
}
DO - Used to execute a list of statements while a condition is true. The statements are always
executed at least once. The following example always sets output 0 on and keeps it on as long
as input 0 is greater than 100.
Example:
main ()
{
do {
write_uaf(output,0,0,on);
} while (read_uaf(input,0,0)>100);
}