# Accessing Updated Macro Variable Values

**URL:** <https://klipper.discourse.group/t/accessing-updated-macro-variable-values/22676>\
**Category:** General Discussion\
**Created:** [March 27, 2025, 1:56am UTC](https://klipper.discourse.group/t/accessing-updated-macro-variable-values/22676 "2025-03-27T01:56:16Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![3dcoded](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/3dcoded/32/20297_2.png) [@3dcoded](https://klipper.discourse.group/u/3dcoded)\
**Post date:** [March 27, 2025, 10:41am UTC](https://klipper.discourse.group/t/accessing-updated-macro-variable-values/22676/4 "2025-03-27T10:41:42Z")

</div>

This is one of the main features of [DynamicMacros](https://github.com/3dcoded/DynamicMacros). By using three empty lines, or a [custom delimeter](https://dynamicmacros.3dcoded.xyz/features/receivingvariables/#custom-delimeters) (highly recommended), you can split the macro and receive variable updates. Note that this doesn’t work inside if statements or for loops.

DynamicMacro version of your macro:

```yaml
[gcode_macro run_increment_test_number]
gcode:
   RESPOND TYPE=command MSG="Current Test Number {printer["gcode_macro test_number"].testnumber}"
   increment_test_number

   RESPOND TYPE=command MSG="Test Number after increment {printer["gcode_macro test_number"].testnumber}"

```

> [@Updating Macros without Restarting Klipper](https://klipper.discourse.group/t/updating-macros-without-restarting-klipper/17663):
>
> I recently created [DynamicMacros](https://3dcoded.github.io/DynamicMacros/), a way to update simple macros without restarting Klipper. It works by having the “dynamic” macros in a separate file, not included in your printer.cfg. Then, a [dynamicmacros] config section references that file. Whenever a dynamic macro is reloaded with the DYNAMIC\_MACRO command, it reads the provided configuration files and executes the macro. This way, you can edit your macros without restarting Klipper. Currently, dynamic macros support the following: Upd…

---

_[View the full topic](https://klipper.discourse.group/t/accessing-updated-macro-variable-values/22676)._
