图形对象从X1移位到X2水平移动,再从从X2移位到X1水平移动。自动重复移动,该怎样做?
最佳答案
定义一个内部变量position32位整数,一个移动方向flagbool,全局脚本VBS中:
dimtag(2)
tag(0)=HMIRUNtime.tags("flag").Read
tag(1)=HMIRuntime.tags("position").read
iftag(0)then
tag(1)=tag(1)+10
elsetag(1)=tag1-10
endif
iftag(1)>=5000then‘向右超过x2位置,开始左移
hmiruntime.tags("flag").write0
endif
iftag(1)<=100then’向左超过x1位置,开始右移
hmiruntime.tags("flag").write1
endif
提问者对于答案的评价:
谢谢
专家置评
已阅,最佳答案正确。