How to format a string in gcode?
-
I am trying to send a serial messages that includes a string and a number but can't get the desired result. Any suggestions?
I am using Duet 3 Mini 5+ 3.4.0 (2022-03-15) and would prefer a workaround rather than upgrading at this point.
Test macro
M575 P2 B115200 S2 while iterations < 10 M300 S4000 P50 ; Short beep M118 P5 S"[abc_"^iterations^"_xyz]" ; Attempt 1 M118 P5 S"[abc_{iterations}_xyz]" ; Attemp 2 G4 P1000 ; 1 sec Delay M300 S4000 P1000 ; Long beep
Desired output
[abc_2_xyz]
Actual output
-
@zapta said in How to format a string in gcode?:
M118 P5 S"[abc_"^iterations^"_xyz]"
Try this:
M118 P5 S{"[abc_"^iterations^"_xyz]"}
When an expression is used as a parameter to a GCode command the entire expression must be enclosed in { } .
-
Thanks @dc42. That worked.
-
-