Need help with Bash M-code

More
31 Mar 2026 16:14 #344995 by spumco
Need help with Bash M-code was created by spumco
Working on a switchable kinematics for my lathe, using the millturn example on GH.

(more here:  forum.linuxcnc.org/10-advanced-configura...r-than-x-axis#344888 )

One part of the switchkins process are a pair of M-codes: M128 and M129.  I gather these are used to change the axis max/min limits when the respective joints are swapped.

Problem is I don't understand the Bash language/terms/syntax well enough to make sure I'm modifying it appropriately for my config.

Here's the full M128:
Warning: Spoiler!


Question(s):

1.  Do I need to change (INI_FILE_NAME) to my particular ini file name, or is this some sort of 'points to the configuration's INI file regardless of name' programming thing?

2.  Under #RESTORE, there is the foreach | $coords... part.
- Does this call, or otherwise ensure, everything below applies to all values after set coords "x y z" at the top?

- Does set L [string toupper $l] somehow change the lowercase "x y z" to upper-case for use in the ::AXIS_[set L]... part?

- What is "catch"?

3.  Could this have been written more simply?
like: hal setp ini.x.min_limit [set ::AXIS_X(MIN_LIMIT)]

and repeated for desired axes?  With no "set coords" or "foreach" or "set L" needed?

Bonus Question:
- Other than to confuse non-programmers, what purpose does this complication serve?  Is the intent to make it so the end-user only has to change the coords "n n n" values and everything still works?

Please Log in or Create an account to join the conversation.

Time to create page: 0.058 seconds
Powered by Kunena Forum