Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: gtoguy on November 22, 2007, 11:20:22 AM
-
How do you write a user macro that takes more than 1 parameter on the command line?
I know how to do it with 1 parameter ......Param1 ()......but how do you allow the user to enter 2 or more parameters?
Thanks,
Pat
-
M666 P7 Q5 S3
param1() is P i.e. 7 in this case as you know, param2() returns Q i.e. 5 and param3() returns S i.e. 3
-
Thank you. Thats what I needed. Is there some place that this is documented? Are there more than 3 parameters you can input?
Pat
-
glad to help. As far as I'm aware you're limited to the three. see the customization UG http://www.machsupport.com/documentation/Customizing.pdf and in the wiki http://www.machsupport.com/MachCustomizeWiki/index.php?title=Mach_specific_Subroutines/Functions_grouped_by_purpose#Arguments_of_macro_call
if you need more inputs to your macro, then depending on what you need to do you could use the gcode param block and pick them up in your macro with GetVar.
Cheers
Ian
-
I have a different question relating to parameters.
I have a macro that takes one or two parameters. Can I detect whether there was a Q word on the line?
So, for instance, I need to allow and be able to distinguish between
M1000 P123 Q0 'and...
M1000 P123 'and finally...
M1000 Q123
The reason is that P and Q are actually X and Y values that I manipulate before spewing them out in G1 commands, so they need to be 'sticky'. My Gcode is generated by LazyCam with G1 commands that I edit to be M1000 commands, replacing X and Y by P and Q. But LazyCam only puts the X and Y words out if they are different from the previous value. In the macro, if, say, the Q word is missing it is treated the same as Q0, which is not what I want, though I could artificially make it that 0 is an illegal value, so detect the omission that way.
Thanks
Chris
-
Since posting, I've experimented and find that Param1() returns -1 if there is no P parameter, so it is -1, not 0 as I had thought, that you must avoid as a legal value if you wish to detect whether there is a P word. Same for Q and S.
So, the code I am now using looks like:
PVal=Param(1)
If PVal=-1 Then PVal=GetVar(nnn) Else SetVar(nnn, PVal) End If
This picks up the previous value, so acting 'sticky' like the X,Y,Z values in G0, for instance.
This behaviour of Param1() etc doesn't seem to be documented.
If anyone is interested, my code bends and skews text characters so they fit correctly around a sundial. I convert every G0 and G1 to an Mmmmm.
Chris Lusby Taylor