第一次用威纶通的HMI,想在屏上显示程序行号,当LW=0,时在屏上的LB0=1,显示为红色,然后,当LW=1时,LB1=1,LB0变为0,也就是说,LW=n,LBN=1,共300行,写了一段宏代码,能用,但是,300行那么多,有没有更简的方法吗?希望高人指正,谢谢。
下面是宏代码:限于篇幅只列出0到4步
macro_command main()
short a
bool on=1,off=0
GetData(a,"Local HMI",lw,0,1)
if a==0 then
SetData(on,"Local HMI",lb,0,1)
else
SetData(off,"Local HMI",lb,0,1)
end if
if a==1 then
SetData(on,"Local HMI",lb,1,1)
else
SetData(off,"Local HMI",lb,1,1)
end if
if a==2 then
SetData(on,"Local HMI",lb,2,1)
else
SetData(off,"Local HMI",lb,2,1)
end if
if a==3 then
SetData(on,"Local HMI",lb,3,1)
else
SetData(off,"Local HMI",lb,3,1)
end if
if a==4 then
SetData(on,"Local HMI",lb,4,1)
else
SetData(off,"Local HMI",lb,4,1)
end if
end macro_command