Hi,
I am trying to implement a small bit of code in the VBScript within Indusoft Web Studio. Basically I have a selector switch that sets a variable within a Beckhoff PLC, to enable functions within a function block.
Initially I just used an IF..Then statement in the script, which works fine if the PLC is running when the switch is changed, however if the PLC is started after the switch is selected, the variable won't get written.
I have tried a Do..Loop but it seems to hog processing time, as I need to repeat the code continuosly to make sure that the variables get written regardless.
Below is the code I have used as a test. I am still trying to pick up bits of VB and VBScript whilst trying to arrange training.
Sub Multiple_Switch()
Dim A
Do While $iCounter < 9
For A = 0 To 9 Step 1
$iCounter = $iCounter + 1
Next
Loop
If $iCounter => 10 And $IGatesOn > 0 Then
$bTest1 = True
$bTest2 = True
End If
If $iCounter => 10 Then
$iCounter = 0
End If
End Sub
I would be grateful for any pointers. Would I be better doing a compare based ontime that executes an IF..Then statement every second or so? Is this possible?
Jon.
I am trying to implement a small bit of code in the VBScript within Indusoft Web Studio. Basically I have a selector switch that sets a variable within a Beckhoff PLC, to enable functions within a function block.
Initially I just used an IF..Then statement in the script, which works fine if the PLC is running when the switch is changed, however if the PLC is started after the switch is selected, the variable won't get written.
I have tried a Do..Loop but it seems to hog processing time, as I need to repeat the code continuosly to make sure that the variables get written regardless.
Below is the code I have used as a test. I am still trying to pick up bits of VB and VBScript whilst trying to arrange training.
Sub Multiple_Switch()
Dim A
Do While $iCounter < 9
For A = 0 To 9 Step 1
$iCounter = $iCounter + 1
Next
Loop
If $iCounter => 10 And $IGatesOn > 0 Then
$bTest1 = True
$bTest2 = True
End If
If $iCounter => 10 Then
$iCounter = 0
End If
End Sub
I would be grateful for any pointers. Would I be better doing a compare based ontime that executes an IF..Then statement every second or so? Is this possible?
Jon.