Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 12:40:44 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  VB script consuming too much resources
Pages: 1   Go Down
Print
Author Topic: VB script consuming too much resources  (Read 1333 times)
0 Members and 1 Guest are viewing this topic.
fer_mayrl
Global Moderator
*
Offline Offline

Posts: 452


View Profile
« 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
Logged
Chaoticone
South Carolina, US
Administrator
*
Offline Offline

Posts: 3,598


Precision Chaos



View Profile WWW
« Reply #1 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
Logged

Grin If you could see the things I have in my head, you would be laughing too. Grin
www.precisionchaos1.com
My guard dog is not what you need to worry about!
ger21
Global Moderator
*
Offline Offline

Posts: 2,620



View Profile WWW
« Reply #2 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)
Logged

fer_mayrl
Global Moderator
*
Offline Offline

Posts: 452


View Profile
« Reply #3 on: February 19, 2007, 06:49:07 PM »

no, let me add it, and let you know
Fernando
Logged
fer_mayrl
Global Moderator
*
Offline Offline

Posts: 452


View Profile
« Reply #4 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
Logged
fer_mayrl
Global Moderator
*
Offline Offline

Posts: 452


View Profile
« Reply #5 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
Logged
ger21
Global Moderator
*
Offline Offline

Posts: 2,620



View Profile WWW
« Reply #6 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. Smiley
Logged

fer_mayrl
Global Moderator
*
Offline Offline

Posts: 452


View Profile
« Reply #7 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
Logged
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!