# Help with Macro: SET\_GCODE\_VARIABLE doesnt set my variable

**URL:** <https://klipper.discourse.group/t/help-with-macro-set-gcode-variable-doesnt-set-my-variable/11014>\
**Category:** General Discussion\
**Created:** [October 16, 2023, 6:16pm UTC](https://klipper.discourse.group/t/help-with-macro-set-gcode-variable-doesnt-set-my-variable/11014 "2023-10-16T18:16:59Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![theophile](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/theophile/32/31_2.png) [@theophile](https://klipper.discourse.group/u/theophile)\
**Post date:** [October 17, 2023, 6:24pm UTC](https://klipper.discourse.group/t/help-with-macro-set-gcode-variable-doesnt-set-my-variable/11014/10 "2023-10-17T18:24:17Z")

</div>

That’s because macros are evaluated before they are run. All the variables are “translated” before the macro is executed so if the macro itself changes the value of a variable, that change won’t be reflected during the same execution of the macro. To work around this, create a second macro called something like TEST\_RESPOND, have that macro do the `RESPOND TYPE=error MSG=‘{test}’` line, and call TEST\_RESPOND at the end of TEST. Keep in mind that TEST\_RESPOND will need to lookup the value of the test variable from the TEST macro.

---

_[View the full topic](https://klipper.discourse.group/t/help-with-macro-set-gcode-variable-doesnt-set-my-variable/11014)._
