Jump to content
OMRON Forums

Correct PLC syntax for AND condition


DLS_James

Recommended Posts

Hello,

 

What is the correct syntax for an AND condition inside a conditional?

 

I am trying to do the following:

 

if ((OMEGA_POSITION / OMEGA_SCALER) > OMEGA_LOW_THRESHOLD) && ((OMEGA_POSITION / OMEGA_SCALER) < OMEGA_HIGH_THRESHOLD)

{

OMEGA_POSITION_OK = 1;

}

else

{

OMEGA_POSITION_OK = 0;

}

 

Related to this, is there a way of getting the pre-processor to tell you what error it sees?

 

eg. With,

 

projpp

Error: projpp errors = 1

 

This message would be more helpful if it told you the error and which file and line number.

 

Thanks for any help,

 

James

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

You want both conditions to be inside the outer most parenthesis of the if statement.

if ((OMEGA_POSITION / OMEGA_SCALER > OMEGA_LOW_THRESHOLD) && (OMEGA_POSITION / OMEGA_SCALER < OMEGA_HIGH_THRESHOLD))
or
if (OMEGA_POSITION / OMEGA_SCALER > OMEGA_LOW_THRESHOLD && OMEGA_POSITION / OMEGA_SCALER < OMEGA_HIGH_THRESHOLD)

 

As far as the error message goes, usually if I double click on the error it puts me on the correct line of the correct file in the IDE. If double clicking doesn't work, could you give me a screenshot of the error?

Link to comment
Share on other sites

Thank you - the outer parentheses did the trick!

 

Regarding the pre-processor error, I'm not using the IDE. I'm connecting using telnet and running the pre-processor from the command line (see screenshot). Can I get any useful error messages at this level?

proj_screenshot.png.536b61bd0da55cddd62d5eb7b938a080.png

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...