Conditional Or Statement

Status
Not open for further replies.

Mity Eltu

Member
I am trying to write basic code that looks like this:

If PORTB.0 Or flags.1 Then
While PORTB.0 or flags.1
Wend
Endif

This is, in fact part of the code I'm trying to compile using pic18 simulator basic compiler. This code fails to compile and gives me the following error:
"Error in line 52: Invalid test expression". Line 52 is the If statement. How do I code this so I can have either portb.0 or flags.1 set to 1 and the code within the IF statement run? I've tried multiple different methods, but nothing has worked. I can't find an example that uses this sort of conditional statement. Can anyone help?
 
This should work for the while - wend expression
Code:
Dim x As Bit
Dim a As Bit
Dim b As Bit
a = 1
b = 0
x = 1
While x
    x = a Or b
Wend
 

Try this:

If PORTB.0 = 1 Or flags.1 = 1 Then
While PORTB.0 = 1 Or flags.1 = 1
Wend
Endif
 
ericgibbs: That did it. I'll swear I had tried that already! I even remember putting all kinds of parentheses around them trying to get it to work. I really hate computers... and they hate me right back. Anyway. That did the trick. Thank you.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…