CamBam
News:
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 17, 2018, 10:20:53 am


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Debugging macros in Mach3  (Read 1224 times)
Dragonfly
CNC Jedi
*****
Offline Offline

Posts: 1981



View Profile
« on: March 29, 2018, 21:15:38 pm »

Hi folks,
I have a macro for digitizing objects with my own algorithm to follow the objects relief and thus save (a lot of) time compared to the traditional 'bed of nails' approach.
I am trying to improve but it is hell and pains working with the Mach3 VB Script Editor/Debugger.
Today I lost 3 days of work just because File -> Close command while clearing the screen retains the closed file name as active and one inadvertent click on 'Save' instead of 'Load' produced a file with the same name and zero bytes length.  Kiss Undecided

First question: Do the set breakpoints work on your machines?
        They don't work for me and the only way to trace the execution is single stepping. Time and again. Took me days to get the desired results.

Second: Is there a way to stop macro execution started in the VB Editor? Other than exiting Mach3 itself or sometimes hanging the OS to the point of forced power off.
       I've implemented periodical check for pressed ESC key which stops the execution although more than one key presses are needed. And after it has been stopped this way the editor loses the color hilighting of the code. And the code needs to be reloaded.
Logged

Before asking a question do some effort and walk through all menus and options in CamBam.  Maybe the answer is there. Please.
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3517



View Profile
« Reply #1 on: March 29, 2018, 21:26:24 pm »

I use Notepad++ to write / edit scripts
Logged
Dragonfly
CNC Jedi
*****
Offline Offline

Posts: 1981



View Profile
« Reply #2 on: March 29, 2018, 22:04:11 pm »

The problem is with testing/debugging. They need to be run in Mach3 with actual machine positioning, movement and read back signals and values.
Logged

Before asking a question do some effort and walk through all menus and options in CamBam.  Maybe the answer is there. Please.
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 5110



View Profile WWW
« Reply #3 on: March 29, 2018, 22:10:06 pm »

Hello

Quote
First question: Do the set breakpoints work on your machines?

Yes


Quote
Second: Is there a way to stop macro execution started in the VB Editor?

Maybe, but never found ...

++
David

Logged
dave benson
CNC Jedi
*****
Offline Offline

Posts: 926


View Profile
« Reply #4 on: March 30, 2018, 01:44:07 am »

Hi Fly

It all depends on what you have going in the marco itself, if you are running a macro (and it's not waiting on an condition to be meet ) then you can stop execution by pressing the stop button in Mach3.
The breakpoints work for me (BTW they only work while in the vb editor itself).

Dave
edit have a look here at post six.https://www.machsupport.com/forum/index.php?topic=22042.0


* forum reply for DragonFly.PNG (42.49 KB, 873x357 - viewed 44 times.)
Logged
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 5110



View Profile WWW
« Reply #5 on: March 30, 2018, 03:28:21 am »

Hello Dave

What I'm searching for (and I assume it's the same for Dragon) is a way to stop a script that falls into an infinite loop ; as the CTRL C in older "basic" language (like GWbasic) ; in the editor, even the stop button, or the window close button of the edit window are frozen .. the only way I found is to terminate Mach3 itself ; even the "reset interpreter" button as no effect.

++
David
Logged
dave benson
CNC Jedi
*****
Offline Offline

Posts: 926


View Profile
« Reply #6 on: March 30, 2018, 11:09:30 am »

Hi David

To cancel your running script, you must use the Sleep() statement else Mach3 won't see the Key Press.
Once they are in your script you can cancel the script with the ESC key.
You can stop other statements from executing until a move is done by using the IsMoving Statement.
Hope this Helps
Dave
Logged
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 5110



View Profile WWW
« Reply #7 on: March 30, 2018, 17:15:27 pm »

Hello Dave

Yes, i tried a sleep(200) statement in the loop, but no change, the editor window stay blocked (no way to stop the script, buttons or ESC not working, and the window can't be closed or moved on the screen)

++
David
Logged
lloydsp
CNC Jedi
*****
Offline Offline

Posts: 7589



View Profile
« Reply #8 on: March 30, 2018, 18:13:55 pm »

Sleep() only works if it loops through that sleep command repeatedly.  If it's 'stuck' on a state-variable, it won't actually loop.

Lloyd
Logged

"Pyro for Fun and Profit for More Than Fifty Years"
Dragonfly
CNC Jedi
*****
Offline Offline

Posts: 1981



View Profile
« Reply #9 on: March 30, 2018, 19:16:40 pm »

David,
I've placed calls to this function in the loops to be able to stop the execution. Depending on the loop sometimes it needs several key presses until one is caught. But does its job more or less.

Code:
Option Explicit
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Const VK_SPACE = &H20
Const VK_ESCAPE = &H1B

..........
Function HaltKeyPressed() As Boolean
    HaltKeyPressed = ( GetAsyncKeyState(VK_ESCAPE) < 0)
End Function

Logged

Before asking a question do some effort and walk through all menus and options in CamBam.  Maybe the answer is there. Please.
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 5110



View Profile WWW
« Reply #10 on: March 31, 2018, 02:25:36 am »

Re

Ok, good to know  Wink

++
David
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.135 seconds with 19 queries.

Copyright © 2018 HexRay Ltd. | Sitemap