40X1 porta Syntax error

XLSERVICE

New Member
Im not sure if I am doing something silly but the first two lines work OK, but the second two give a syntax error. The only difference being the second two are Porta inputs.


If b6>0 and pin6 = 0 then : low portb 6 : high portc 5 : b12=1 : endif
If b7>0 and pin7 = 0 then : low portb 7 : high portc 5 : b12=1 : endif
If b8>0 and porta pin0 = 0 then : low portc 6 : high portc 5 : b12=1 : endif
If b9>0 and porta pin1 = 0 then : low portc 7 : high portc 5 : b12=1 : endif

any help is much appreciated
Alan
 

kevrus

New Member
I tried this in the sim

Code:
If b6>0 and pin6 = 0 then : low portb 6 : high portc 5 : b12=1 : endif
If b7>0 and pin7 = 0 then : low portb 7 : high portc 5 : b12=1 : endif
If porta pin0 = 0 and b8>0 then : low portc 6 : high portc 5 : b12=1 : endif
If porta pin1 = 0 and b9>0 then : low portc 7 : high portc 5 : b12=1 : endif
and it compiled ok
 

XLSERVICE

New Member
Easy when you know how. Thank you Kevrus...
I tried various combinations of syntax, but not that one

Cheers
Alan
PS It just compiled happily
 

westaust55

Moderator
If you read manual 1 page 86 you may understand better what is happening.
Note the portA command is only required once after the ‘if’ command.
It is not possible to test inputs on two different ports within the same if…then
statement.
and manual 2 page 78
IF PORTA pin ?? value {AND/OR variable ?? value ...} THEN address
note the porta test is first in the example.




Also, on the 40X1, portb is the "normal" output pins so, instead of LOW portb 6 , just use LOW 6
(mind you, it does not save any bytes to program length)

Your code is correct for portc (ie: high portc 5 )
 
Last edited:
Top