Hello Guest it is March 29, 2024, 05:40:19 AM

Author Topic: A Simple Macro  (Read 2737 times)

0 Members and 1 Guest are viewing this topic.

A Simple Macro
« on: March 02, 2013, 05:00:46 PM »
At least I thought it would be a simple macro.

All I want to do is pause the program until the operator activates a switch connected to input #2.
I'll need a second macro that pauses the program until the operator activates two switches connected to input #1 and input #2 but I figured I'd start with just the one switch macro.  I've tried two different methods and all I've gotten so far is "scripter compile error" on both.

I first tried:
While IsActive(INPUT2) = False
Message “Press Right Button to Continue”
'Wend

That didn't work so I went with:
Do                                       
Message “Press Right Button to Continue”
If IsActive(INPUT2) Then Exit Do
sleep 10         
Loop

Suggestions please?
Re: A Simple Macro
« Reply #1 on: March 02, 2013, 05:16:44 PM »
You should be able to do just:

Message "Press Right Button To Continue"
While (IsActive(INPUT2))
    Sleep 10

Both of your methods will flood the GUI with messages, which is never good.

Regards,
Ray L.
Regards,
Ray L.
Re: A Simple Macro
« Reply #2 on: March 02, 2013, 07:44:57 PM »
Well, I found the problem.  I've been writing the macros with Notepad and Mach didn't like the quotation marks around the message.

I opened the files in the VB Script Editor in Mach and the quotes were little squares.  Once I changed the squares to ", both of my routines worked fine.

Never heard of having a problem with Notepad before.
Re: A Simple Macro
« Reply #3 on: March 03, 2013, 01:59:47 PM »
So, if anyone ever needs code for safety buttons, this is what I ended up with.
Here are the macros in a bit of sample code:

g1
M103      (Test that buttons aren't held/taped down)
M102     (Wait for both buttons to be pushed)
x0.195 y0.195 f20
z.5 f60
M103        (Test that buttons aren't held/taped down)
M101      (Wait for right button to be pushed)
x0.2 y0.2 f10
z1 f80
g0
z0
x0y0
m30

Here's the code for M103:

If IsLoading() Then
Else
Message "Please Release the Button"
While IsActive(INPUT1)
While IsActive(INPUT2)
Wend
Wend
DoOEMButton(172)
End If

M101:

If IsLoading() Then
Else
Message "Press Right Button to Continue"
While IsActive(INPUT2) = False
Wend
DoOEMButton(172)
End If

M102:

If IsLoading() Then
Else
Message "Press Both Buttons to Continue"
While IsActive(INPUT1) = False
While IsActive(INPUT2) = False
Wend
Wend
DoOEMButton(172)
End If