Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 11:48:12 AM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  General Mach Discussion
| | |-+  Amusing subroutine label bug
Pages: 1   Go Down
Print
Author Topic: Amusing subroutine label bug  (Read 233 times)
0 Members and 2 Guests are viewing this topic.
rcaffin
Active Member

Offline Offline

Posts: 280


View Profile
« on: January 26, 2012, 10:22:06 PM »

I seem to be good at this ... :-)

I write my own programs in a parametric style, so there are lots of subroutines.
Sometimes I need two very similar subroutines, so I will do a copy and paste.
Sometimes ... I forget to edit the subroutine label, so(for example) I end up with two o100 subroutines.
Guess what Mach3 does for me when it encounters this?

Flag an error? Nope.
Execute just the last (or first) one? Nope.
Execute both of them sequentially from ONE call? Yep. The results can be a little unexpected. :-)

Any one else seen this?

Cheers
Logged
BR549
Active Member

Online Online

Posts: 2,559


View Profile
« Reply #1 on: January 27, 2012, 11:56:19 AM »

You are just experienceing what some of us already know when you move away from just very basic Gcode.

I have never run across that one, but I don't recall trying duplicate Subs.

(;-) TP
Logged
BR549
Active Member

Online Online

Posts: 2,559


View Profile
« Reply #2 on: January 27, 2012, 12:03:11 PM »

OK just tried it and it errors out every time with "return called with no sub in effect....looping" as it should have.

(;-) TP
Logged
rcaffin
Active Member

Offline Offline

Posts: 280


View Profile
« Reply #3 on: January 27, 2012, 03:32:30 PM »

Quote
You are just experienceing what some of us already know when you move away from just very basic Gcode.
Yeah, I know ... :-)
But ,you know, if I am careful as to what instructions I use in the nested SRs then parametric coding with deep nesting works quite well. g0, g1, g2, g3, drilling - they all work OK. Some rotation and translation also work fine. I've got a lot of working code.

Quote
OK just tried it and it errors out every time with "return called with no sub in effect....looping" as it should have.
I have had that error msg when I put an m99 into the top-level code in place of an m98 (oops!), but I don't get that with the duplicate subroutines. Anyhow, that would be the wrong error msg for this problem as the m99 at the end of the second SR is structurally correct.
Odd.

Cheers
Logged
BR549
Active Member

Online Online

Posts: 2,559


View Profile
« Reply #4 on: January 27, 2012, 06:33:18 PM »

BUT not if it did NOT have an associated M98 that called it. They come as a pair  The m98 calls and the M99 from that sub call returns.

If you try to run the sub code ONLY you get the same message.

Were the 2 subs nested 1 sub inside another I did not test that routine.

Yep I have a lot of parametric subs as well but it can be like russian roulet to get one running. The you give the program to someone and it never runs again on their setup. Been there.

Can you post teh program that runs BOTH subs from one call?? Interesting

(;-) TP
« Last Edit: January 27, 2012, 06:35:39 PM by BR549 » Logged
BR549
Active Member

Online Online

Posts: 2,559


View Profile
« Reply #5 on: January 27, 2012, 06:57:40 PM »

Weird here NOW the sub will not run without an M30

M98 P1 L1
o1
(Hello)
M99
%

Will not run, BUT

M98 P1 L1
M30
o1
(Hello)
M99
%

Will run.

Who knows?Huh??  (;-) TP

Logged
rcaffin
Active Member

Offline Offline

Posts: 280


View Profile
« Reply #6 on: January 27, 2012, 07:54:39 PM »

Quote
Yep I have a lot of parametric subs as well but it can be like russian roulet to get one running. The you give the program to someone and it never runs again on their setup. Been there.
That's not been my experience. If written correctly with the limited set of g-codes, they always run exactly as intended.

Quote
Can you post teh program that runs BOTH subs from one call?? Interesting
That one was 'fixed' to be correct, but the attached demos what happens. it's very simple.

I am of course ASSUMING that it will behave on your machine the same as on my (simulation) machine. But such programs do behave on both my sim box and on the CNC , and give the same results. Oh well, I will be interested to see how it runs on anyone else's machine.

Cheers
Roger

* Subtest1.tap (0.14 KB - downloaded 7 times.)
« Last Edit: January 27, 2012, 07:57:18 PM by rcaffin » Logged
BR549
Active Member

Online Online

Posts: 2,559


View Profile
« Reply #7 on: January 28, 2012, 12:24:50 AM »

HIYA ROger, Testing your version here the 2nd sub runs first then it runs the first sub.

Also with your version it will not run without the M30 as well.

Interesting, (;-) TP
Logged
rcaffin
Active Member

Offline Offline

Posts: 280


View Profile
« Reply #8 on: January 28, 2012, 12:32:11 AM »

Quote
Testing your version here the 2nd sub runs first then it runs the first sub.
Likewise. Makes for some very strange bugs at times!

Quote
Also with your version it will not run without the M30 as well.
Yeah, well, I don't mind that. Not sure the Standard requires the m30 (or alternatives), but it is reasonable.

Roll on V4 ! ! !

Cheers
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!