威纶通官方论坛

求助,关于IF语句的问题

[复制链接]
发表于 2019-3-16 13:44:04 | 显示全部楼层 |阅读模式
macro_command main()
short m,n
bool a,b,c,d,e
unsigned short shi,fen
unsigned short shiq1,fenq1,shiq2,fenq2,dl

GetData(shi, "Local HMI", LW, 9019, 1)
GetData(fen, "Local HMI", LW, 9018, 1)
GetData(shiq1, "Local HMI", RW, 44, 1)
GetData(fenq1, "Local HMI", RW, 45, 1)

if  shi==shiq1 and fen==fenq1 and m<5 then

    m=m+1
    SetData(m, "Local HMI", LW, 6000, 1)//加1送显,看程序是否执行
   
    else if shi<>shiq1 and fen<>fenq1  then

   
    m=0
   
  
    end if
    end macro_command
当if  shi==shiq1 and fen==fenq1把m<5删了时,能加1,但当当shi<>shiq1 and fen<>fenq1时不归零,这是什么原因,各位老师帮我看看

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2019-3-23 09:59:53 | 显示全部楼层
修改如下:
macro_command main()
short m,n
bool a,b,c,d,e
unsigned short shi,fen
unsigned short shiq1,fenq1,shiq2,fenq2,dl

GetData(shi, "Local HMI", LW, 9019, 1)
GetData(fen, "Local HMI", LW, 9018, 1)
GetData(shiq1, "Local HMI", RW, 44, 1)
GetData(fenq1, "Local HMI", RW, 45, 1)

if  shi==shiq1 and fen==fenq1 and m<5 then

     m=m+1   
     else if shi<>shiq1 and fen<>fenq1  then

   
     m=0
   
   
     end if

     SetData(m, "Local HMI", LW, 6000, 1)//加1送显,看程序是否执行

     end macro_command
发表于 2019-4-17 23:02:33 | 显示全部楼层


macro_command main()
short m,n
bool a,b,c,d,e
unsigned short shi,fen
unsigned short shiq1,fenq1,shiq2,fenq2,dl

GetData(shi, "Local HMI", LW, 9019, 1)
GetData(fen, "Local HMI", LW, 9018, 1)
GetData(shiq1, "Local HMI", RW, 44, 1)
GetData(fenq1, "Local HMI", RW, 45, 1)
  GetData(m, "Local HMI", RW, 46, 1)

if  shi==shiq1 and fen==fenq1 and m<5 then

      m=m+1   
      else if shi<>shiq1 and fen<>fenq1  then

     
      m=0
     
   
      end if

      SetData(m, "Local HMI", LW, 6000, 1)//加1送显,看程序是否执行

     end macro_command
您需要登录后才可以发帖 登录 | 注册

本版积分规则

回复帖子

Archiver|小黑屋|威纶通官网 ( 粤ICP备06054553号 )

GMT+8, 2024-4-26 08:45

Powered by Discuz! X3.4

© 2001-2023 Comsenz Inc.

快速回复 返回顶部 返回列表