威纶通官方论坛

有关宏指令数据比较问题

[复制链接]
发表于 2012-12-3 13:38:43 | 显示全部楼层 |阅读模式
macro_command main()
short a
GetData(a, "Local HMI", LW_BCD, 1, 1)
short f[16]
if a==1 then
f[0]=1
f[1]=2
f[2]=3
f[3]=4
f[4]=5
f[5]=6
f[6]=7
f[7]=8
f[8]=9
f[9]=10
f[10]=11
f[11]=12
f[12]=13
f[13]=14
f[14]=15
f[15]=16
SetData(f[0], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 128, 1)
SetData(f[1], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 129, 1)
SetData(f[2], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 130, 1)
SetData(f[3], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 131, 1)
SetData(f[4], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 132, 1)
SetData(f[5], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 133, 1)
SetData(f[6], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 134, 1)
SetData(f[7], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 135, 1)
SetData(f[8], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 136, 1)
SetData(f[9], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 137, 1)
SetData(f[10], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 138, 1)
SetData(f[11], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 139, 1)
SetData(f[12], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 140, 1)
SetData(f[13], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 141, 1)
SetData(f[14], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 142, 1)
SetData(f[15], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 143, 1)
else if a==10 then
f[0]=2
f[1]=0
f[2]=0
f[3]=0
f[4]=0
f[5]=0
f[6]=0
f[7]=0
f[8]=0
f[9]=0
f[10]=11
f[11]=12
f[12]=13
f[13]=14
f[14]=15
f[15]=16
SetData(f[0], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 128, 1)
SetData(f[1], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 129, 1)
SetData(f[2], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 130, 1)
SetData(f[3], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 131, 1)
SetData(f[4], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 132, 1)
SetData(f[5], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 133, 1)
SetData(f[6], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 134, 1)
SetData(f[7], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 135, 1)
SetData(f[8], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 136, 1)
SetData(f[9], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 137, 1)
SetData(f[10], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 138, 1)
SetData(f[11], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 139, 1)
SetData(f[12], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 140, 1)
SetData(f[13], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 141, 1)
SetData(f[14], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 142, 1)
SetData(f[15], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 143, 1)
end if
end macro_command
       求高手指导:为什么当等于10或者大于10的时候不能传输数据,1~9都能传输数据?谢谢
发表于 2012-12-5 16:29:06 | 显示全部楼层
GetData(a, "Local HMI", LW_BCD, 1, 1)
你看下LW 1是不是定义的格式为BCD码;
还有,SetData(f[0], "Mitsubishi FX0s/FX0n/FX1s/FX1n/FX2", D, 128, 16)
写成这样就好了,没有必要写一大串。
 楼主| 发表于 2012-12-6 16:17:33 | 显示全部楼层
嗯 解决了十分谢谢!不能相等的原因为数据格式不是同类的,应该把10写成3031
您需要登录后才可以发帖 登录 | 注册

本版积分规则

回复帖子

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

GMT+8, 2024-11-23 23:19

Powered by Discuz! X3.4

© 2001-2023 Comsenz Inc.

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