On Thu, Apr 02, 2009 at 08:13:42PM +0100, alan battersby wrote:
> My question is, are variables #1 etc also global in the sense that if I
> set #1= 99 before the call is its value pushed on some stack and
> retrieved again after the call or is the value just overwritten by the
> parameter value of zero?
> So
> #1 = 99
> O1000 call [0] ...
> what is the value of #1 here after the sub 0 or 99 ?
It is the old value. Otherwise, the flowsnake recursion example
wouldn't work. This also gets specific mention in the documentation:
http://linuxcnc.org/docs/devel/html/gcode_main.html#r3_1
> Also if I set the value of #1 before the call and then make the call
> with no parameters will the subroutine see the value I set?
>
> #1 = 99
> O1000 call
> ...
> ..
> O1000 (this is the sub)
> is the value of #1 99 here or is it undefined?
> O1000 endsub
I would treat the value as undefined. I don't see that the
documentation specifies one way or another.
I looked at the implementation, and I see that local parameters that are
not specified on O-call are set to zero.
> So do gcode variables behave exactly like variables in a programming
> language such as C# etc or is there some difference?
I would be wary of drawing too many inferences about gcode parameters
from the behavior of other programming languages.
Jeff
------------------------------------------------------------------------------
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users