第一次用威綸通的HMI,想在屏上顯示程序行號(hào),當(dāng)LW=0,時(shí)在屏上的LB0=1,顯示為紅色,然后,當(dāng)LW=1時(shí),LB1=1,LB0變?yōu)?,也就是說(shuō),LW=n,LBN=1,共300行,寫(xiě)了一段宏代碼,能用,但是,300行那么多,有沒(méi)有更簡(jiǎn)的方法嗎?希望高人指正,謝謝。
下面是宏代碼:限于篇幅只列出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