Combining any and all Statements Together Example

In this example program we combine any and all statements to make more complex decisions possible in Octagon.

Program


---

Combining any and all statements example program

---

prog_vars =

d/pin1 0

d/pin2 1

d/pin_no 0

prog_vars.


prog_start =

print " -------------- "

print "any and all combination example program"

prog_start.


prog_loop =


-- Test 1 Should be FALSE ie /pin_no < 1

/pin1 0

/pin2 1

/pin_no 0

all /pin_no >= 1 /pin_no <= 5 any /pin1 = 0 /pin2 = 1 ->

print "Test 1 TRUE WRONG"

else

print "Test 1 FALSE CORRECT"

exitprog

enda.

-- Test 2 Should be FALSE ie /pin_no > 5

/pin1 0

/pin2 1

/pin_no 10

all /pin_no >= 1 /pin_no <= 5 any /pin1 = 0 /pin2 = 1 ->

print "Test 2 TRUE WRONG"

else

print "Test 2 FALSE CORRECT"

exitprog

enda.



-- Test 3 Should be FALSE ie all anys are false

/pin1 1

/pin2 0

/pin_no 3

all /pin_no >= 1 /pin_no <= 5 any /pin1 = 0 /pin2 = 1 ->

print "Test 3 TRUE WRONG"

else

print "Test 3 FALSE CORRECT"

exitprog

enda.



-- Test 4 Should be TRUE ie all is ok and 1 any is true

/pin1 0

/pin2 0

/pin_no 3

all /pin_no >= 1 /pin_no <= 5 any /pin1 = 0 /pin2 = 1 ->

print "Test 4 TRUE CORRECT"

else

print "Test 3 FALSE WRONG"

exitprog

enda.



-- Test 5 Should be TRUE ie all is ok and 1 any is true

/pin1 1

/pin2 1

/pin_no 3

all /pin_no >= 1 /pin_no <= 5 any /pin1 = 0 /pin2 = 1 ->

print "Test 5 TRUE CORRECT"

else

print "Test 5 FALSE WRONG"

exitprog

enda.


prog_loop.


prog_stop =

print "Bye"

prog_stop.