ok, now I was able to find something out. if i call this function, the first time it echoes test begin function 1, but then the server doesn't do anything more. it doesn't matter if i call it with or without parameter, it hangs at the if {{ defined }}. is there some limitation to this?
@func defaultSpool str
@callAndSave local.spools listSpools
@echo "test begin function 1"
@if {{ defined("local", "str") }}
@echo "test"
; defined by jobname
@echo {{ local.str }}
; @set local.name ""
; @set local.i 0
; @while {{ local.i < length(local.str) }}
; @if {{ substr(local.str, local.i, 1) == "@" }}
; @break
; @endif
; @set local.name {{ local.name + substr(local.str, local.i, 1) }}
; @set local.i {{ local.i + 1 }}
; @endwhile
; @echo {{ local.name }}
; @set local.i 0
; @while {{ local.i < get_json_array_size(local.spools, "/spools") }}
; @if {{ get_json(local.spools, "/spools/" + local.i + "/filament/vendor/external_id") + "_" + get_json(global.spools, "/spools/" + local.i + "/filament/external_id") == local.name }}
; @set perm.usespool {{ get_json(local.spools, "/spools/" + local.i) }}
; @break
; @endif
; @set local.i {{ local.i + 1 }}
; @endwhile
@return
@else
; defined by runtime
@if {{ defined("perm", "usespool") }}
; defined by last used spool
@echo {{ "current spool selected: " + perm.usespool }}
@set local.i 0
@while {{ local.i < get_json_array_size(local.spools, "/spools") }}
@if {{ get_json(local.spools, "/spools/" + local.i + "/id") == get_json(perm.usespool, "/id") }}
@echo {{ "new spool selected: " + get_json(local.spools, "/spools/" + local.i) }}
@return {{ get_json(local.spools, "/spools/" + local.i) }}
@endif
@set local.i {{ local.i + 1 }}
@endwhile
@return
@else
; defined by first spool in list
@echo {{ "new spool from none selected: " + get_json(local.spools, "/spools/0") }}
@return {{ get_json(local.spools, "/spools/0") }}
@return
@endif
@endif
@endfunc