News:

The purpose of these forums is to discuss TurboCAD.  Please keep the discussion of other products to compatibility issues or how the other software can be used with TurboCAD.

Main Menu
TurboCAD 2026 Platinum box
Now available

TurboCAD 2026.2

The latest update for TurboCAD 2026. It installs over any 2026 build and keeps your activation, drawings and settings. Get it from the Start Page or Help > Check for Update.

stop a Macro

Started by nikkipollard, March 31, 2021, 09:41:03 AM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

nikkipollard

Is there an easy way to stop (escape) a macro . after pressing play script (blue arrow) and before the macro finishes doing it's thing.

Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Andy H

Not sure I fully understand Nikki.  But pressing the escape key will normally exit a running macro.  Though this may not work if the macro is stuck inside a loop.   Or do you mean by using code to trigger, say an exit sub.

Tim Stewart

If stuck in a loop, repeatedly/rapidly depressing the ESC key, might get you out of trouble.   :)
Regards Tim

You can design without engineering, but you cannot engineer without design.
Windows 10 Pro (19043.1165) 64-bit, TurboCAD Designer 2017-2020 and Pro. Plat. 2018-2020 + LW (64-bit) + AnimationLab 6
Intel i5 2500@3.3GHz 8GB Ram NVIDIA Quadro K2200

nikkipollard

#3
Thanks . it is not stuck in a loop - It is just quite a long repetitive script -

sometimes when it gets halfway through I can see that it isn't drawing what I want .
I would like to cancel at that point.
I checked with another script - that does cancel when I press escape - so it must be the script.
Would an On Error Go To Next - stop the escape key from working?

Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Tim Stewart

Quote from: nikkipollard on March 31, 2021, 10:09:36 PM
Thanks . it is not stuck in a loop - It is just quite a long repetitive script -

sometimes when it gets halfway through I can see that it isn't drawing what I want .
I would like to cancel at that point.
I checked with another script - that does cancel when I press escape - so it must be the script.
Would an On Error Go To Next - stop the escape key from working?

Yes, that's possible.

"On Error Go To Next" might not be the best solution.
What error?
Better to be safe with On Error Go To Exit?
Regards Tim

You can design without engineering, but you cannot engineer without design.
Windows 10 Pro (19043.1165) 64-bit, TurboCAD Designer 2017-2020 and Pro. Plat. 2018-2020 + LW (64-bit) + AnimationLab 6
Intel i5 2500@3.3GHz 8GB Ram NVIDIA Quadro K2200

Andy H

Quote from: nikkipollard on March 31, 2021, 10:09:36 PM
Would an On Error Go To Next - stop the escape key from working?

I agree with Tim.  'On Error GoTo (or Go To) Next' is not good.  Mainly because it is not supported by VBS / macro's.  Whilst one can go to a specific place in VB/VBA.  VBS is more limited. So I'm wondering if that bit was a typo.

The 'On error go to 0'  one may see, actually doesn't go anywhere, it disable any error handler that has been set up using 'On error resume next'. which is basically the only two error statements one would use. Unless one is setting up a simple error trap. if one records a macro, the default script shows the three error statements.  Resume Next, GoTo 0, and the If Err.Number (tells one there is an error).

'On Error Resume Next' shouldn't stop escape from working,  So it may be something the code is doing / drawing.   What I normally do when something is not right, is to comment out ' (apostrophe) various bits, and see what happens.  Basically I comment out things that may cause a problem, then once I know a section is working, I'll remove some comment marks and try again.  I rarely know what I'm doing with macro's, So I use comments a lot until I know something works.

nikkipollard

No that was a Typo
But I managed to get rid of  the on errors  -  the error I was covering up which was also a silly error.

But escape is still not ending.
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h