Hello Guest it is March 28, 2024, 09:42:17 AM

Author Topic: Amusing subroutine label bug  (Read 4870 times)

0 Members and 1 Guest are viewing this topic.

Offline rcaffin

*
  •  1,052 1,052
    • View Profile
Amusing subroutine label bug
« 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

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Amusing subroutine label bug
« 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

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Amusing subroutine label bug
« 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

Offline rcaffin

*
  •  1,052 1,052
    • View Profile
Re: Amusing subroutine label bug
« 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

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Amusing subroutine label bug
« 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 »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Amusing subroutine label bug
« 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??????  (;-) TP

Offline rcaffin

*
  •  1,052 1,052
    • View Profile
Re: Amusing subroutine label bug
« 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
« Last Edit: January 27, 2012, 07:57:18 PM by rcaffin »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Amusing subroutine label bug
« 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

Offline rcaffin

*
  •  1,052 1,052
    • View Profile
Re: Amusing subroutine label bug
« 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