Feature #478

Updated by Matthieu Decorde almost 4 years ago

It is cumbersome for the user to have to set all the parameters again from scratch (from the macro default values) in case of repetitive calls, which is the most frequent use case of macros.

h3. Solution

Use a file named '<MacroName>.properties' (in the 'parameter_name=value' .properties format), stored in the same directory as the macro, to store previous values given to the parameters in the parameters dialog box; And use those values to initialize the parameters in the parameters dialog box for the next call.

When opening the parameters dialog box of a macro:
* if a file named <MacroName>.properties is present, use its content to initialize the parameters values
* otherwise set the parameters to the default values of the macro

When closing the parameters dialog box:
* store the macro parameters values before execution:
** in a file named <MacroName>.properties (hidden in the macro view)
** in the same directory as the macro file
** with a .properties structure and semantics
** each parameter value is defined by a line pattern "parameterName=value"

*Parameter value binding strategy*

The macro parameters take their value from 4 different environments:
* *def*: macro script default value, the @Field 'def' attribute (set by the Macro source code)
* *properties*: .properties parameter file, the <MacroName>.properties file (set by previous call)
* *field*: parameter field value in dialog box, the parameters dialog box (typed by the user)
* *args*: value given by the calling macro, the "args" global variable

The choice of the value is done according to the following algorithm:
* if the parameter is defined in *args* then use that value
** the *properties* value is not updated
* else:
** if all parameters are set by *args* don"t show the dialog box
*** open the parameters dialog box with all the parameters not defined in *args* (their default value comes from *properties* if available otherwise from *def*)
*** use the value given by *field*

Back