0

I'm using Indusoft Web Studio which has VBScript implementation for scripts and I have a following problem.

I need to have something like:

Do While $pozAkt<>x
Loop

However the given lines completely freeze the PC. How can I get PC to wait until myVar will reach the x value?

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
adammo
  • 171
  • 10
  • Normally you need to put some kind of "sleep" statement into loops like that, so that your script yields CPU resources to the system and doesn't consume all CPU by itself. In regular VBScript that would be a `WScript.Sleep 100`, but I'm not familiar with SCADA, so I don't know if the method is available in that environment (probably not) or what the equivalent would be. – Ansgar Wiechers Aug 26 '19 at 09:24
  • @AnsgarWiechers Wscript is not available sadly, that's the reason I'm asking – adammo Aug 26 '19 at 09:36
  • See [link](https://stackoverflow.com/questions/54487205/alternative-for-wscript-sleep-and-window-timeout) If you can't find an answer there, check [link](http://www.indusoft.com/blog/2017/12/20/how-to-make-a-multi-second-or-minute-or-hour-etc-timer-with-one-tag-in-indusoft-web-studio/) -or- [link](http://www.indusoft.com/blog/2011/08/26/running-asynchronous-scripts-in-indusoft-web-studio-v7-0sp1/) IIRC, InduSoft Web Studio sleep timers are set to never so the main program thread continuously runs/collects data. Thus, you may need timers or async scripts to periodically check your condition. – leeharvey1 Nov 12 '19 at 03:00

1 Answers1

0

Use "WEND".

While $pozAkt<>x
   
Wend

You can combine an "If" inside to avoid the overflow.

Dim flag, limit

flag=0

While flag=0
   If $pozAkt=x Then
      flag=1 
   End If

   If $pozAkt<>x Then
      limit=limit+1 
      $Wait(1)

      If  limit>1000 Then
        flag=1 
      End If 

   End If       
Wend

But, its better not make a large loop inside VBScript using Indusoft, Do it only if its needed to hold the script and create a Task. Try not to use a screen script or global screen script with loops, your PC will freeze always.

Tasks

Stan
  • 1
  • 1