Variable assignment in macro doesn't work

I have a simple macro redefining PAUSE to introduce parking:

[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
gcode:
{% set x_park = printer.toolhead.axis_minimum.x|float %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
{% set retract = 10 %}     
    SAVE_GCODE_STATE NAME=PAUSE_state
    BASE_PAUSE
    G91
    G1 E-{retract} F2100
    G90
    G1 X{x_park} Y{y_park} F6000

Other users have similar macros using x_park and set y_park, I searched the forums.

However in my case I get the error

Option '{% set x_park' is not valid in section 'gcode_macro pause'

I don’t get where I can have made a mistale. I copied and pasted from similar lines from the forums and I still get the error.

By placing “gcode:” at the beginning and adding indentation, it seems to work now.

Isn’t it so weird this still need to be done?

Wrong instructions in mainsail.cfg in 2023…

CORRECTION: This ^^ statement is not true. If you look further down in the gcode macro (like all the way down, there’s a “gcode:” line there…

Here’s an example that works, here I’ve set my desired x and y positions (it’s in printer.cfg):

You noticed that?

grafik

Not sure what you are on about? See my correction.

@ironprinter727 I think what @EddyMI3D is on about about is that your profile says you just joined an hour before you posted. He was welcoming you as a new member. I don’t think he was commenting on the veracity of your actual comment.

ps. It might be nice to put some info in your profile about yourself. Click on some of the avatars to get an idea of what others put. Click on the “I” in a blue dot top right of the screen (next to the search icon) to see your own stuff including a guided tour for new members.

Welcome from me too. I was a noob just a week ago.

I actually meant that the thread is 2 years old and a lot of things can happen in that time.