Hi Isabell,
Parameter values are static, we can not change them at run-time (including startup / shutdown process) unfortunately.
I think that using global variables could be a workaround.
See also this Q&A:
Python Shutdown Best Practise - Global Variables + Published Parameters http://fmepedia.safe.com/AnswersQuestionDetail?id=906a0000000cgTZAAY
Takashi
Hey Takashi,
thank you very much for your answer and your examples.
I used the scripted parameter and it works!
Regards,
Isabell
I'm currently working on a script that loads a lot of user parameters from a csv or json, and also wanted this to work.
It doesn't appear to be possible in the startup script, as it is executed after the parameters are resolved.
However, there is a workaround using scripted parameters. Scripted parameters are resolved from top to bottom (it appears), so a scripted parameter can use values from parameters above it.
You can create a parameter at the top named PARAM, which can return arbitrary data using python.
For example:
return {'BUFFER_DISTANCE': 2, 'RETICULATE_SPLINES': True}
Then, in the parameter BUFFER_DISTANCE, I can add the following code to retrieve the value:
import fme
params = eval(fme.macroValuese'PARAMS'])
return paramsv'BUFFER_DISTANCE']
Note that a parameter is always a string, so to be able to use it as dictionary we need to call eval() on it.
Warning: eval() can execute arbitrary python code. Make sure you NEVER call it directly on user input. If you want to use user input, use import json with json.loads()