Sensaphone SCADA 3000 Users manual User Manual
Page 189
16-3
Chapter 16: Programming in C
In many of the examples in the chapter we use x and y as variable names. The variable names
can be up to 15 characters long. Numbers can also be used as long as the name does not begin
with a number. In addition to letters and numbers, the underscore character may also be used
in a variable name, but it cannot be the first character of the variable name. You cannot have
spaces in the middle of a variable name.
The following are valid variable names:
float average;
float outside_temp;
float condition1;
float contact12;
The following are not valid variable names:
float 3temp;
float average_result_per_day;
float inside room;
float _timer;
4) The SCADA 3000 C language has other tools available to construct your C program. One
of the most important tools is the “if” statement. The “if” statement is used to make a decision
whether or not to execute a sequence of statements.
Example: The following program will turn on output 0 only if x is greater than
100, which in this case is true. When the condition in the “if” statement is true,
the program continues through the statements inside the “if” braces. If the con-
dition was not true, the program skips the block of statements.
float x;
main ()
{
x=120;
if (x>100)
{
write_uaf(output,0,0,on);
}
}
The “else” statement can be used with the “if” statement and gives instructions on what to do
when the “if” statement is false.
Example: In the following program, if x is greater than 100, then output 0 on the main board
will be turned on. If x is not greater than 100, then output 0 on the main board will be turned
off. In either case, output 3 on the main board will always be turned on.
float x;
main ()
{
x=75
if (x>100)
{
write_uaf(output,0,0,on);
}
else
{
write_uaf(output,0,0,off);
}
write_uaf(output,0,3,on);
}