Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: jdmaya on November 21, 2012, 10:36:12 AM
-
Hello group.
I have the following code attached to a button:
If getuserled(1000)=0 Then
setuserled(1000,1)
avance = getuserdro(1000)
If avance < 5 Then
avance = 5
End If
If avance > 500 Then
avance = 500
End If
porcentaje = avance/14
setoemdro(3,porcentaje)
setuserdro(1001,avance)
jogon(0,1)
Else
setuserled(1000,0)
setuserled(1001,0)
setuserdro(1001,getuserdro(1000))
jogoff(0)
End If
when I run it step by step from the Vb Script editor the program works perfectly.
when I run the program from the button does not work.
which may be the problem?
thanks for the help.
-
I would think you need to let the screen update, so you need some way to pause the program like a Sleep(1000) command between set commands. That's why it works in single step, it has time to keep up with your keyboard.
or try a series of lines like this before the next set command.
While IsMoving ()
Sleep 100
Wend
-
insert the code after the jogon(0,1) command, the program still does not work.
jogon(0,1)
while ismoving()
sleep 1000
wend.
Pressing the button lights the led, it updates the job slow, the jogon(0,1) command is not executed.
-
just try the sleep command there leave out the ...... while ismoving() wend
-
For User LED's, you need to use GetOEMLED() instead of GetUserLED(). SetUserLED() is correct.
I'd try it like this:
If Not GetOEMLED(1000) Then
SetUserLED(1000,1)
avance = getuserdro(1000)
If avance < 5 Then
avance = 5
End If
If avance > 500 Then
avance = 500
End If
porcentaje = avance/14
setoemdro(3,porcentaje)
Sleep(125)
setuserdro(1001,avance)
Sleep(125)
jogon(0,1)
Else
setuserled(1000,0)
setuserled(1001,0)
setuserdro(1001,getuserdro(1000))
Sleep(125)
jogoff(0)
End If