beautypg.com

B&B Electronics VFG3000 - Manual User Manual

Page 164

background image

P

ROGRAMMING

T

IPS

V

LINX

F

IELDBUS

G

ATEWAY

M

ANAGER

U

SER

M

ANUAL

P

AGE

148

The example below shows an

if

statement with two actions…

if( TankEmpty ) {

StartPump := 0;

OpenValue := 1;

}

The example below shows an

if

statement with an

else

clause…

if( MotorHot )

StartFan := 1;

else

StartFan := 0;

Note that it is very important to remember to place the curly-brackets around groups of
actions to be executed in the

if

or

else

portion of the statement. If you omit the brackets,

Fieldbus Gateway Manager will most likely misunderstand exactly which actions you want to
be dependent upon the

if

condition. Although line breaks are recommend between actions,

they are not used to figure out what is and is not included within the conditional statement.

S

WITCH

S

TATEMENTS

A

switch

statement is used to compare an integer value against a number of possible

constants, and to perform an action based upon which value is matched. The exact syntax
supports a number of options beyond those shown in the example below, but for the vast
majority of applications, this simple form will be acceptable.

The architecture of the

switch

statement is as follow…

switch ( int var) {

case 1:

action1;

break;

case 2:

action2;

default:

action3;

break;

}