IMPORT{} by variable name?

When importing a json file, can a variable somehow be included to indicate which file to import?

For instance as input in the value property:

This works: IMPORT{path/name.json}

This works: path/@{variableName}.json

This doesn't work: IMPORT{path/@{variableName}.json}

Also, is there a way to use the IMPORT function in the onValue script field?

This doesn't work: IMPORT{path/@{variableName}.json}

This could be added easily in next release.

Also, is there a way to use the IMPORT function in the onValue script field?

There is not, flexible programmatic file loading would be best handled using a custom module.

Thank you for so quick, clear and concise a response.

Eagerly waiting for the next release .. Much appreciated if you could add that option.

I hope to master using custom modules one day. So far I haven't succeeded.

Also, is there a way to use the IMPORT function in the onValue script field?

There is not, flexible programmatic file loading would be best handled using a custom module.

I realize that a custom module would be best. Yet I found this (ugly) solution works for me to have a single piece of code used by 160 different buttons:

comments: IMPORT{/scripts/buttonCode.json}

onValue: eval(getProp('this','comments'))

Wait, I thought you were looking for a js equivalent to IMPORT{} that could be called in a script. You can write IMPORT{} in onValue in order to define the content of the script using an external file.

My appologies for not being clear. What I would like is both reusing script code (by using an external file) and some flexibility in onValue. Ideally some combination like this:

onValue:

< here some directly written code >
< and here a call to import an external .json file >
< and here a call to another external .json file> 
< here some more directly written code >
< etc. >

What is the exact syntax for using the IMPORT{} function in onValue?

Just writing IMPORT{/scripts/buttonCode.json} or JS{IMPORT{/scripts/buttonCode.json}} doesn't work I had noticed.

Sorry, I overlooked your code and thought you were attempting to import a script (js file) to be executed, not a json file to be consumed. I think the cleanest way would be to use variable widgets with IMPORT{} statements in their value property (one per variable widget) and then retrieve the json data with a simple get('variable_widget_id').