Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: fer_mayrl on February 19, 2007, 05:24:49 PM

Title: VB script consuming too much resources
Post by: fer_mayrl on February 19, 2007, 05:24:49 PM
Ok, I have a VB script running in the macro pump, and it uses 99% of my computers resources, so sometimes it slows down, It may be my way of coding or something. Anyone here sees something wrong with the code?


BB=0
CC=0
DD=0
EE=0
FF=0

Do While GetUserLed(1020)=1

Code "G01 A36"
While IsMoving()
Sleep 100
Wend

If IsActive(Input1)=TRUE Then
BB=1
Else
BB=0
End If

If BB=0 And DD=0 And FF=0 Then
DeActivateSignal(OUTPUT1)
DeActivateSignal(OUTPUT2)
DeActivateSignal(OUTPUT3)
ElseIf BB=1 And DD=0 And FF=0 Then
ActivateSignal(OUTPUT1)
DeActivateSignal(OUTPUT2)
DeActivateSignal(OUTPUT3)
ElseIf BB=0 And DD=1 And FF=0 Then
DeActivateSignal(OUTPUT1)
ActivateSignal(OUTPUT2)
DeActivateSignal(OUTPUT3)
ElseIf BB=0 And DD=0 And FF=1 Then
DeActivateSignal(OUTPUT1)
DeActivateSignal(OUTPUT2)
ActivateSignal(OUTPUT3)
ElseIf BB=1 And DD=1 And FF=1 Then
ActivateSignal(OUTPUT1)
ActivateSignal(OUTPUT2)
ActivateSignal(OUTPUT3)
ElseIf BB=1 And DD=0 And FF=1 Then
ActivateSignal(OUTPUT1)
DeActivateSignal(OUTPUT2)
ActivateSignal(OUTPUT3)
ElseIf BB=1 And DD=1 And FF=0 Then
ActivateSignal(OUTPUT1)
ActivateSignal(OUTPUT2)
DeActivateSignal(OUTPUT3)
ElseIf BB=0 And DD=1 And FF=1 Then
DeActivateSignal(OUTPUT1)
ActivateSignal(OUTPUT2)
ActivateSignal(OUTPUT3)
End If

CODE "G04 P375"
While IsMoving()
Sleep 100
WEnd

DeActivateSignal(OUTPUT1)
DeActivateSignal(OUTPUT2)
DeActivateSignal(OUTPUT3)

CODE "G04 P375"
While IsMoving()
Sleep 100
WEnd

FF=EE
EE=DD
DD=CC
CC=BB

Loop   

End
Title: Re: VB script consuming too much resources
Post by: Chaoticone on February 19, 2007, 05:37:50 PM
Hey Fer,
   I remember seeing something about this a while back. I can't remember for the life of me what it was for sure. I think it may have been the While if statements.


Brett
Title: Re: VB script consuming too much resources
Post by: ger21 on February 19, 2007, 06:38:07 PM
Do you have this line at the start of your code?

Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Title: Re: VB script consuming too much resources
Post by: fer_mayrl on February 19, 2007, 06:49:07 PM
no, let me add it, and let you know
Fernando
Title: Re: VB script consuming too much resources
Post by: fer_mayrl on February 19, 2007, 07:02:59 PM
Is there a VB command, that acts as a dwell? i dont know, like:

DWELL 100
or
PAUSE 100

where the 100 is in milliseconds?

Regards
Fernando
Title: Re: VB script consuming too much resources
Post by: fer_mayrl on February 19, 2007, 07:15:40 PM
Thanks a lot Ger,
That did it, CPU load less than 1%

Still, Is there a DWELL or PAUSE command?

Regards
Fernando
Title: Re: VB script consuming too much resources
Post by: ger21 on February 19, 2007, 08:30:16 PM
the code"G4" doesn't work for you? I don't know of a "pause", but I'm not a programmer either. :)
Title: Re: VB script consuming too much resources
Post by: fer_mayrl on February 19, 2007, 08:32:39 PM
It delays, but its not as precise As I would like it to be... I could try lowering the argument on the sleep command to make it better
Thanks
Fernando