还是6.0 顺序启动的问题

我把  zhangli0 老师的脚本在VBS全局动作里面运行了一下 发现还是有点问题,想看看哪里出的问题。
第一个就是提示语法错误   然后我在倒数第一个 else 上面加了句 end if 不知道放在这里有没有问题
第二 runtime=HMIRuntime.tags("myruntime").read”读取运行时间。
runtime=runtime+1  If runtime>=time_sp Then
        count=count+1
        runtime=0
 还有不知道为什么runtime不会随着一秒的脚本触发时间
+1 但是条件满足时count会一秒+1
 然后变0 所以我在想是不是runtime+1以后要再次写进myruntime里面去 然后它在循环脚本的时候第二次读
的时候就已经是+1的数了?不知道对不对,也不知道怎么写
Dim time_sp,start,count,runtime
time_sp=HMIRuntime.tags("timesp").read”读取设定时间
start=HMIRuntime.tags("bstart").read”按钮按下bstart置位。
count=HMIRuntime.tags("mycount").read”需要启动的灯,wincc内部变量
runtime=HMIRuntime.tags("myruntime").read”读取运行时间,wincc内部变量
If start=1 Then
     If count=0 Then
        HMIRuntime.tags("D1").write 1”D1打开
      Else If count=1 Then
                HMIRuntime.tags("D2").write 1”D2打开
      Else
               HMIRuntime.tags("D3").write 1”D3打开
      End If”根据count值打开对应的灯
    runtime=runtime+1
     If runtime>=time_sp Then
        count=count+1
        runtime=0
     End If”运行时间大于sp则count加1,runtime清零
     If count>2 Then
        count=0
    End If”count大于0说明需要从头循环,count复位
    HMIRuntime.tags("mycount").write count”保存count值
    HMIRuntime.tags("myrumtime").write runtime”保存runtime值
 End If  ‘’这个地方是在 zhangli0老师的代码前面加的
 Else
    HMIRuntime.tags("mycount").write0
    HMIRuntime.tags("myrumtime").write 0
      HMIRuntime.tags("D1").write 0”D1关闭
      HMIRuntime.tags("D2").write 0”D2关闭
      HMIRuntime.tags("D3").write 0”D3关闭
End If ”没有启动则计数和运行时间清零,关闭灯。

最佳答案

你加错了呀!我写的是满足启动条件执行那些动作,不满足则复位所有的状态。我这个是纯手动输入的,难免有错误。你的end if是肯定加错了,最后一个else下的write和0中间有一个空格的,不知道是我没有打上还是你弄错了。

提问者对于答案的评价:
太谢谢了。根据你的提示我慢慢又学了些。现在已经解决了

原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc177248.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2017年6月19日
下一篇 2017年6月19日

相关推荐