Passing Parameters - unknown variable
-
Hello, I am trying to create a filament load macro, that gets called by the respective filament load button, or if called manually (which hotend was pressed is unknown) asks for which hotend to work with.
I can't crack one final step - when running the macro (triggered, or called manually), I get an error: when triggered by the button it returns
Error: in file macro line 4 column 23: meta command: unknown variable 'hotendselect'The sequence is first that the button triggers the trigger5.g file to pass on the value "2" :
; trigger5.g M98 P"0:/macros/filament-load" X2 ; Load Filament for T2
then, the error is in Line 4 of the filament-load macro:
;Autoload filament macro. Press button then insert filament to load if exists(param.X) ; Parameter X was passed set var.hotendselect = param.X echo "Autoload for Extruder " ^ var.hotendselect else ; Parameter X was NOT passed, display screen for selecting one of the hotends M291 R"Unload Filament" P"Request for Extruder #" S4 K{0,1,2,3} J1 set var.hotendselect = {input} endif T{var.hotendselect} ; Select Tool as passed on M300 S2000 P100 ; play beep sound M291 P"Insert filament in Tool!" S0 T3 ; display message M302 P1 ; enable cold extrusion G4 S5 ; wait for 5 seconds to insert filament G1 E15 F500 ; load filament inside the gears M109 S235 T0 ; set hotend temperature and wait G1 E100 F300 ; extrude 100mm, you may need to reduce speed for very soft TPU M104 S0 T0 ; set hotend temperature to 0 M302 P0 ; disable cold extrusion M291 P"Filament autoload complete!" S0 T3 ; display message unset var.hotendselect ; Erase variable
Apologies with what I assume is a noob question - I tried search, the GCode manual and chatGPT to no avail...
-
@phoenix hotendselect will only be available inside the if. If you want it available in the rest of the macro declare it at the top before the if
Endif also isn't valid
And unset also isn't valid
-
Before you can user a variable in the form var.some_name you have to declare it using the form var some_name = 0, or whatever initial value you want it to have. Notice there is not period character between var and some_name in the declaration.
Frederick
-
-