# 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:** 15

<div class="post-metadata">

**Author:** ![Sineos](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/sineos/32/18_2.png) [@Sineos](https://klipper.discourse.group/u/Sineos)\
**Post date:** [October 20, 2023, 3:30pm UTC](https://klipper.discourse.group/t/help-with-macro-set-gcode-variable-doesnt-set-my-variable/11014/15 "2023-10-20T15:30:49Z")

</div>

To add to @theophile excellent answer. You can share these variable objects across different macros like

```auto
[delayed_gcode i_depend_on_test]
gcode:
    {% set vars = printer["gcode_macro TEST"] %}
    M117 {vars.my_shared_variable}

[gcode_macro TEST]
variable_my_shared_variable: -1
gcode:
    SET_GCODE_VARIABLE MACRO=TEST VARIABLE=my_shared_variable VALUE={params.MY_SHARED_VARIABLE|default(10)}
    UPDATE_DELAYED_GCODE ID=i_depend_on_test DURATION=0.01

```

So, once `TEST MY_SHARED_VARIABLE=100` is executed, then `i_depend_on_test` is called and can access the variable’s content, which then is 100.

---

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