you assign to it on the left-hand side, which probably causes it to be treated as a local variable in the whole scope, so it doesn’t exist yet when you want to use it as a function argument. At least that’s my guess.
Like this, it loads the new data but does not display it, as it remains local. I cannot seem to find a simple way to update the global variables with the new data. Enabling the commented lines trigger the same error in the line before, where the function is called. I also tried a form of lma_load_data! without success. What would be the right way to do it?
Update! It works just by using:
global lma,lmaheader,lmafolder,lmafile,tim,xy,tz = load_lma_data(lmafolder,lmafile,-1)