Ops: Specifying default integer parameters

Hi folks,

I’m finally back to playing with ops and came across the following:

// @String(label="A string parameter", value="cow") myString
// @int(label="An integer parameter", value=1) myInt

println myString
println myInt

Yields this dialog:


I.e., the string parameter default value seems to be populated correctly, but the integer parameter is not.

Furthermore, if I set those two parameters to some values (different than either either the default or starting values), eg
A string parameter = "hippo"
An integer parameter = -5

Then press ‘Ok’. The next time I run it, the values are populated with the previous values I set (hippo, and -5).

Is this a bug? Is there a way to force fields to take particular default values?

Thanks as always!

See also:

Follow up, specifying the min and max of an int parameter seems to mess things up a little

// @int(label="An integer parameter", min=2, max=4, value=3) myInt

I observe that the value starts at zero, and cannot be changed with the up/down buttons.
Typing in a new value within the valid bounds works, and after that the buttons work.

For reference, I was looking at this:

Hi @bogovicj,

Just for your information, the recommended parameter syntax recently changed, from (language-specific) comment identifiers to the language-agnostic #@ syntax, so while your syntax works fine, we try to replace those in all documentation and examples by something like:

#@ String(label="A string parameter", value="cow") myString
#@ int(label="An integer parameter", value=1) myInt

I have observed similar behavior in the past, and found that default values worked for Integer and Double but not for primitive types int and double:

#@ int(value=3) primitive_integer
#@ Integer(value=4) integer_type
#@ double(value=2.5) primitive_double
#@ Double(value=3.4) double_type


You can avoid this using persist=false:

#@ int(value=3, persist=false) primitive_integer
#@ Integer(value=4, persist=false) integer_type
#@ double(value=2.5, persist=false) primitive_double
#@ Double(value=3.4, persist=false) double_type

Parameters should actually not be persisted across scripts, there’s an open issue for this:

This is of course related to the wrong default value initialization, but should be improved in general to jump to the respective min or max when the spinner arrows are used.

Would you care to file an issue (also for the default value problem, where no issue was created yet, as far as I know)?


Thanks @imagejan,

I’m seeing the same behaviour and don’t have a particular reason to stick with primitives. Thanks for the suggestion :slight_smile:

I will indeed file an issue.

It seemed appropriate to separate these into two issues: