chataigne
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| chataigne [2023/02/17 14:23] – ssm2017 | chataigne [2023/02/17 17:54] (current) – [Values in script] ssm2017 | ||
|---|---|---|---|
| Line 18: | Line 18: | ||
| <sxh js> | <sxh js> | ||
| var mycontainer = local.values.addContainer(" | var mycontainer = local.values.addContainer(" | ||
| - | var myint1 = mycontainer.addIntParameter(" | + | var myint1 = mycontainer.addIntParameter(" |
| myint1.setAttribute(" | myint1.setAttribute(" | ||
| + | </ | ||
| + | ===== Custom variables ===== | ||
| + | <sxh js> | ||
| + | function getCustomVariablesGroup(name, | ||
| + | var my_group = root.customVariables.getItemWithName(shortname); | ||
| + | if (my_group.name != shortname) { | ||
| + | // build a new group | ||
| + | my_group = root.customVariables.addItem(shortname); | ||
| + | my_group.setName(name); | ||
| + | } | ||
| + | return my_group; | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Set or create then set the custom variable value | ||
| + | * @param {int} page_id | ||
| + | * @param {int} exec_id | ||
| + | * @param {int} value | ||
| + | * @param {string} type | ||
| + | * @param {string} item_nice_name | ||
| + | */ | ||
| + | function setCustomVariablesValue(page_id, | ||
| + | // build names | ||
| + | var shortname = " | ||
| + | var name = "Exec "+ page_id+ " | ||
| + | // get the group | ||
| + | var my_group = getCustomVariablesGroup(name, | ||
| + | // define the item type | ||
| + | var item_name = type; | ||
| + | var item_type = " | ||
| + | var int_max = 100; | ||
| + | |||
| + | if ([" | ||
| + | item_type = " | ||
| + | } | ||
| + | // build some names | ||
| + | var my_value = {}; | ||
| + | var my_value_name = " | ||
| + | var my_value_nice_name = "Exec "+ page_id+ " | ||
| + | |||
| + | var my_value_item = my_group.variables.getItemWithName(my_value_name); | ||
| + | if (my_value_item.name != my_value_name) { | ||
| + | // create if not exist | ||
| + | my_value_item = my_group.variables.addItem(item_type+ " Parameter" | ||
| + | my_value = my_value_item.getChild(my_value_item.name); | ||
| + | my_value.setName(my_value_nice_name); | ||
| + | |||
| + | if ([" | ||
| + | int_max = 999; | ||
| + | } | ||
| + | if ([" | ||
| + | int_max = 60; | ||
| + | } | ||
| + | if (