简体   繁体   English

错误4024结构化文本编程

[英]Error 4024 structured Text programming

IF  IP_emo:=FALSE THEN
    State:= OFF_Mode;
ELSE
    State :=OFF AND  IP_emo:=TRUE AND start_Btn:=TRUE OR start_Btn:=False;
    State:= Monitor_Mode;
END_IF

I am not sure why I am getting error 4024 on this code requiring a := before "THEN" . 我不确定为什么在此代码上出现错误4024,要求a := before "THEN" Can someone help me? 有人能帮我吗?

Disclaimer: Not sure what plc you are using or what error 4024 means but I can comment on the format of your code if you use a typcicaly IEC 61131 plc language (which most plcs are). 免责声明:不确定您使用的是什么plc或4024表示什么错误,但是如果您使用典型的IEC 61131 plc语言(大多数plcs是),我可以对代码的格式进行注释。

First, the := i an assignment operator. 首先, := i是赋值运算符。 The = is a comparison operator. =是比较运算符。 So in your if statment you would use 因此,在您的if陈述中,您将使用

IF IP_emo = FALSE THEN

or alternatively (depending on which plc you use. typically all IEC 61131 languages are the same though) 或替代(取决于您使用的plc。尽管如此,通常所有IEC 61131语言都是相同的)

IF NOT IP_emo THEN

Secondly, AND and OR are for comparison so you can't have them with an assingment operator. 其次, ANDOR用于比较,因此您不能使用分配运算符。 You can do something like 你可以做类似的事情

ELSE
   State :=OFF;
   IP_emo:=TRUE; 
   start_Btn:=TRUE; 
   start_Btn:=FALSE;
   State:= Monitor_Mode;
END_IF

or maybe 或者可能

 ELSE
   State :=OFF;
      IF IP_emo=TRUE AND start_Btn=TRUE AND (start_Btn=TRUE OR start_Btn=FALSE) THEN
          State:= Monitor_Mode;
      END_IF
END_IF

not exactly sure what you are trying to do. 不确定您要做什么。

You don't mention what PLC or tool you are using, what the error 4024 means and which line it comes from. 您无需提及所使用的PLC或工具,错误4024的含义以及错误来自何行。 That makes it a little hard to answer your question. 这使得回答您的问题有些困难。 Some would probably say that the question qualifies for a down-wote on that account. 有人可能会说,该问题符合该帐户的低价要求。

I'm a little confused by the formatting of your example. 您的示例格式让我有些困惑。 Please format as code (done automatically, if you use 4 spaces indent) and it will be easier to read and answer. 请格式化为代码(如果使用4个空格缩进,则自动完成),这样更易​​于阅读和回答。

I made an attempt at formatting below, and have some comments to that. 我尝试在下面进行格式化,对此有一些评论。

  • Line 1: Normally you wouldn't use := but only = before THEN (might depend on the compiler, but I doubt it) 第1行:通常,您不会使用:=,而是仅在THEN之前使用=(可能取决于编译器,但我对此表示怀疑)
  • Line 4: There's too many :='s. 第4行::=太多。 Should this line and the following maybe have been split into some ELSIF's or another nested IF? 应该将这一行及以下代码拆分为某些ELSIF或另一个嵌套的IF吗?

I hope that helps. 希望对您有所帮助。 :-) :-)

IF IP_emo:=FALSE THEN
  State:= OFF_Mode;
ELSE
  State :=OFF AND IP_emo:=TRUE AND start_Btn:=TRUE OR start_Btn:=FALSE;
  State:= Monitor_Mode;
END_IF

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM