Describe your issue:
I would like to be able to dynamically create variables in Klipper Macros
For example, imagine something like this:
{% set filamentTypeHead1=7 %}
{% set filamentTypeHead2=42 %}
M118 {“mydynamicvar”~filamentTypeHead1}
This will print the dynamically created variable name “mydynamicvar7”.
Question: How can I get the VALUE of this dynamicvariable?
I have made some progress by doing this with Lists, as follows:
{% set data = [5, 7, 12, 72] | list %}
{% set test_0 = 1 %}
{% set test_1 = 3 %}
M118 this should give 7 { data[active_test_0] }
M118 this should give 72 { data[active_test_1] }
This works. However, I can not find any way to update an item in the “Data” list. i.e I can not go data[2]=42
etc. Without the ability to dymanically update the data in the list, this become worthless for my needs.
Can anyone please advise the best practice on how to have dynamically created variables, and read/write their contents? Thankyou.