From: Jeff E. <je...@un...> - 2007-08-17 12:18:05
|
On Fri, Aug 17, 2007 at 11:15:29AM +0100, wat...@fa... wrote: > Just a couple of points I'm not completely clear on - in the > above example, are line numbers needed on every line of the > subroutine or just at the ends? O-numbers are required on lines where the flow control words such as "sub", "endsub", "do", "while" are used. The interpreter uses these numbers to "match up" the beginning and end of a subroutine or a loop. O-numbers on other lines are not permitted, so this is incorrect gcode: O200 G0 X0 Y0 Z0 > Also, would it be normal to use different variable numbers > in the different subroutines, - i.e. 1-3 in subroutine o100 > and 4-8 in subroutine o200 or would it confuse the > subroutine call? I just wondered if the variables 1-3 are > forgotten after the first subroutine ends or not and how > starting at 4 might confuse the passing of variables from > the second subroutine call? Each subroutine gets its first argument in #1, its second argument in #2, and so on up to a maximum of #30. At the end of the subroutine, the former values in #1 up to #30 are restored[1]. If there are values that you want to use from one call of o100 to the next, then they need to be stored in #31 and above. > Oh, and is there an upper limit to the number of variables - > could the global variables be numbered from 100 up.. Subroutine "locals" are #1 through #30 inclusive. #31 through #5000 are for global use, because they're neither modified by "O- call" nor restored by "O- endsub". Above #5000 is reserved for internal interpreter stuff, like the result of a G38.2 probe, the origin of the coordinate systems, and so on. Jeff [1] at least, they're supposed to be, but this bug has been reported: http://sourceforge.net/tracker/index.php?func=detail&aid=1772411&group_id=6744&atid=106744 |