Machsupport Forum

Mach Discussion => Mach4 General Discussion => Mach4 Toolbox => Topic started by: FocusPaul on October 09, 2015, 07:29:16 AM

Title: Parametrized M codes (e.g. M162 A12.0 P8.0)
Post by: FocusPaul on October 09, 2015, 07:29:16 AM
Hello!

I've been looking for this feature for some time now, seems it had been impl'd in one of the more recent versions (test with v2716):

You can provide parameters to custom M code Lua scripts. Please refer to example LuaExamples/UseVarsFromMcodeLine/M162.mcs.

Code: [Select]
local pFlag = mc.mcCntlGetLocalVarFlag(inst, hParam, mc.SV_P)
... checks if parameter P is available ...
Code: [Select]
local pVal = mc.mcCntlGetLocalVar(inst, hParam, mc.SV_P)
... while this line retrieves the value as double

mc.SV_P may be replaced by any character between SV_A and SV_Z.

Small example M162 script attached, which writes values of all present parameters to log.