Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 12:55:54 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
| | |-+  Possible to have 1 external button that runs previous VB script that was run?
Pages: 1   Go Down
Print
Author Topic: Possible to have 1 external button that runs previous VB script that was run?  (Read 1344 times)
0 Members and 1 Guest are viewing this topic.
Darc
Active Member

Offline Offline

Posts: 177


View Profile
« on: April 22, 2007, 04:00:01 PM »

Yep me again, is it possible to have 1 external button (much the same as a cycle start), that will run the previous VB script that was run?
I have multiple buttons that all have there own script, but I was thinking it would be nice if you could click the correct button on the screen for the first time, then after that the user could just keep pressing this external button, until a different script is needed etc.etc.
Thanks
Logged
poppabear
S S SYSTEMS, LLC
Global Moderator
*
Offline Offline

Posts: 1,707


Briceville, TN, USA


View Profile WWW
« Reply #1 on: April 22, 2007, 06:19:01 PM »

OK,  it is me again..........too.........

Do this, drop an Led next to each of your buttons on the main screen, when ever you push one of the buttons, its associated led turns on, it also turns all others off.

Then in your external button, have your Macro pump monitor it, i.e.

'Macropump.m1s

If IsActive(INPUTx) Then 'this is your external button input pin
   If GetUserLED(1001) Then  'your button fuction 1 LED
   VB Script of that button here......
   End If
       If GetUserLED(1002) Then '2cd button script Led
       VB Script for 2cd button here.....
       End If
           If GetUserLED(1003) Then '3rd button action led
           VB Script for 3rd button here........
           End If
End If

'You could also use a Case Statement if more complex....

Scott
   
Logged

Commercial Mach3: Screens (regular and flash), Wizards, Plug-ins, Brains, PLCs, Macros, ATC's, machine build, retrofit and Prototyping
http://sites.google.com/site/volunteerfablab/
Darc
Active Member

Offline Offline

Posts: 177


View Profile
« Reply #2 on: April 23, 2007, 07:51:24 PM »

You my friend are a freakin genius, it works great.
BTW in my script I have it turn OFF all LED's at the start e.g
SetUserLED (1001,0)
SetUserLED (1002,0)
etc.etc
I have it do this for 24 individual LED's is there a more efficient way of doing this?
Also how can I enter this into the MacroPump so it will turn OFF all LED's when Mach starts only, rather that making them OFF all the time?
I only ask this because if I estop the sytem when a script is running, my LED's stay on until I run the script again, and it reaches the end of it where I tell the LED's to turn OFF.
......Well my wife's always telling me I'm high maintenance.......
Logged
poppabear
S S SYSTEMS, LLC
Global Moderator
*
Offline Offline

Posts: 1,707


Briceville, TN, USA


View Profile WWW
« Reply #3 on: April 23, 2007, 11:22:15 PM »

Genius, not really, that belongs to Art and Brian, and several others here, but, try the below.

BTW: I dont know of a more effeincet way of turning off those 24 leds, other than what you are doing.

To turn them all off with the macro pump only once your going to have to lock them out.
 
Put this piece in your Macro pump some where at the top. Note you will have to also put a "Renew LED" called (1200, or what ever), some where as well.

'add to top of macro pump

x=GetUserDro(1200)

If X=0 then
'put your turn off all led stuff here
x=x+1   'this adds 1 to x, so this script only runs once (unless see below).
End If

If X>0 and GetuserLED(1200) Then   'you have pushed the renew button this will reset X to 0
SetUserDro(1200,0)
End If

'Note: the above renew/reset is really only meant to re-run the off all 24, or to set the DRO
'back to 0, for persistant dros....... The macro pump will re-hit it while running faster
'than you can reset it. It is really just to reset your DRO to Zero.
Logged

Commercial Mach3: Screens (regular and flash), Wizards, Plug-ins, Brains, PLCs, Macros, ATC's, machine build, retrofit and Prototyping
http://sites.google.com/site/volunteerfablab/
Darc
Active Member

Offline Offline

Posts: 177


View Profile
« Reply #4 on: April 24, 2007, 01:38:15 AM »

Thanks Scott, is it possible to emulate a key being pressed?
I thought it may be easier, it'd save a lot of code in my MacroPump (Lazy I know), something like:

'Macropump.m1s
If IsActive(INPUT1) Then
   If GetUserLED(1001) Then
   Emulate pressing hotkey 110 (example only)
   End If
       If GetUserLED(1002) Then
       Emulate pressing hotkey 111 (example only)       
       End If
End If

Also on another note, I might start a post where you VB guru's can offer tid bits of code e.g Set UserLED(1000,1) with a short description and example.
But mostly for the more complex equations. thoughts?
At least I wouldn't have to bug you guys as much.
« Last Edit: April 25, 2007, 03:53:57 AM by Darc » Logged
poppabear
S S SYSTEMS, LLC
Global Moderator
*
Offline Offline

Posts: 1,707


Briceville, TN, USA


View Profile WWW
« Reply #5 on: April 24, 2007, 07:43:33 AM »

Yes, look in the Mach OEM buttons codes on the wiki.

To emulate a button, put:

DoOEMButton(*********)    (Some people use "DoButton" also, so if the OEM doesnt work use that one).

There is not a range of codes for "User Buttons", you can only emulate OEM codes. NOTE, this does NOT work on Jogs.

Scott
Logged

Commercial Mach3: Screens (regular and flash), Wizards, Plug-ins, Brains, PLCs, Macros, ATC's, machine build, retrofit and Prototyping
http://sites.google.com/site/volunteerfablab/
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!