I was just looking for a way to directly manipulate the contents of a struct.
Using getters and setters to handle multiple parameters was a bit slow in execution.
Original Message:
Sent: 12-16-2025 06:49
From: Richard Crutwell
Subject: Modify parameters based on the Choice parameter within the STRUCT
No probs, there are other ways perhaps. I've changed the other 'struct' to 'struct_array' - you can nest struct arrays within another struct array, the param at the end still gave issues until changed to a 'string_array' however.
<?xml version="1.0" encoding="UTF-8"?><abs contexttype="opengear" id="_top" keepalive="false"> <meta> <params> <param access="1" name="buttonData" oid="buttonData" type="STRUCT_ARRAY" widget="default"> <value> <subparam access="1" constrainttype="INT_CHOICE" name="selected" precision="0" suboid="selected" type="INT16" value="2" widget="checkbox"> <constraint key="0">zero</constraint> <constraint key="1">one</constraint> <constraint key="2">two</constraint> <constraint key="2">three</constraint> </subparam> <subparam access="1" maxlength="0" name="button" precision="0" suboid="button" type="STRING_ARRAY" widget="default"> <value>fed</value> <value>fed</value> <value>4gryy</value> <value>3</value> </subparam> </value> </param> <param access="1" maxlength="0" name="rename" oid="rename" type="STRING" value="4gryy" widget="text"/> </params> </meta> <param expand="true" height="449" left="108" oid="buttonData.button" showlabel="false" top="96" width="390"/> <param expand="true" height="64" left="532" oid="rename" top="109" width="255"/> <param expand="true" height="62" left="550" oid="buttonData.selected" top="193" widget="default" width="233"/> <button buttontype="push" height="59" left="546" name="do rename" top="294" width="236"> <task tasktype="ogscript">var target = params.getValue('buttonData.selected', 0);//params.setValue('buttonData.button.'+ target +'.name', 0, params.getValue('rename', 0));params.setValue('buttonData.button', target, params.getValue('rename', 0));</task> </button> <button buttontype="push" height="63" left="548" name="toJSON" top="369" width="236"> <task tasktype="ogscript">var struct = params.getAllValues("buttonData"); var json = params.valueToJson(struct); var string = JSON.stringify(json, null, 2); ogscript.debug(string);</task> </button></abs>
------------------------------
Richard Crutwell
Ross Video UK
Original Message:
Sent: 12-16-2025 05:51
From: Keisuke Nagata
Subject: Modify parameters based on the Choice parameter within the STRUCT
Thanks for the reply.
I wanted to create a sports coder usable across various sports, and thought creating root params per sport would make API creation and management easier.(Like basketball.team.1.member or soccer.team.1.member...)
After trying various approaches, I reached the same conclusion as you.
It seems that if you modify a Constraint within a structure after the Script has cached it, it doesn't work properly.
For now, I understand that's just how it is.
Thanks for testing it.
------------------------------
Keisuke Nagata
Original Message:
Sent: 12-16-2025 04:33
From: Richard Crutwell
Subject: Modify parameters based on the Choice parameter within the STRUCT
It looks like the struct is reverting to a cached value, or default value. I noticed that the Struct Array is nested inside a struct, is there a reason for this?
If not, I'd recommend separation for these two, it appears to work without the nested structure.
<?xml version="1.0" encoding="UTF-8"?><abs contexttype="opengear" id="_top" keepalive="false"> <meta> <params> <param access="1" name="buttonData" oid="buttonData" type="STRUCT" widget="default"> <value> <subparam access="1" constrainttype="INT_CHOICE" name="selected" precision="0" suboid="selected" type="INT16" value="1" widget="checkbox"> <constraint key="0">zero</constraint> <constraint key="1">one</constraint> <constraint key="2">two</constraint> <constraint key="2">three</constraint> </subparam> </value> </param> <param access="1" name="button" oid="button" type="STRUCT_ARRAY" widget="default"> <value> <subparam access="1" maxlength="-1" name="name" suboid="name" type="STRING" value="1" widget="default"/> </value> <value> <subparam suboid="name" value="2"/> </value> <value> <subparam suboid="name" value="3"/> </value> <value> <subparam suboid="name" value="4"/> </value> </param> <param access="1" maxlength="0" name="rename" oid="rename" type="STRING" value="2" widget="text"/> </params> </meta> <param expand="true" height="449" left="108" oid="button" showlabel="false" top="96" width="390"/> <param expand="true" height="64" left="532" oid="rename" top="109" width="255"/> <param expand="true" height="62" left="550" oid="buttonData.selected" top="193" widget="0" width="233"/> <button buttontype="push" height="59" left="546" name="do rename" top="294" width="236"> <task tasktype="ogscript">var target = params.getValue('buttonData.selected', 0);params.setValue('button.'+ target +'.name', 0, params.getValue('rename', 0));</task> </button></abs>
------------------------------
Richard Crutwell
Ross Video UK
Original Message:
Sent: 12-15-2025 06:08
From: Keisuke Nagata
Subject: Modify parameters based on the Choice parameter within the STRUCT
Everyone,
To simplify data management, I created a Constraint SubParam within the STRUCT attribute's parameters.
I also want to change the parameters that are overwritten based on its value.
It seems to be working fine, but for some reason, pressing F5 to refresh sometimes reverts it back to the original value.
I created a small test file to isolate the issue, but the same phenomenon occurs.
Does anyone know the cause of this?
<abs contexttype="opengear" id="_top" keepalive="false">
<meta>
<params>
<param access="1" name="buttonData" oid="buttonData" type="STRUCT" widget="default">
<value>
<subparam access="1" constrainttype="INT_CHOICE" name="selected" precision="0" suboid="selected" type="INT16" value="0" widget="checkbox">
<constraint key="0">zero</constraint>
<constraint key="1">one</constraint>
<constraint key="2">two</constraint>
<constraint key="2">three</constraint>
</subparam>
<subparam access="1" name="button" suboid="button" type="STRUCT_ARRAY" widget="default">
<value>
<subparam access="1" maxlength="-1" name="name" suboid="name" type="STRING" value="1st" widget="default"/>
</value>
<value>
<subparam suboid="name" value="2nd"/>
</value>
<value>
<subparam suboid="name" value="3rd"/>
</value>
<value>
<subparam suboid="name" value="4th"/>
</value>
</subparam>
</value>
</param>
<param access="1" maxlength="0" name="rename" oid="rename" type="STRING" value="changed" widget="text"/>
</params>
</meta>
<param expand="true" height="449" left="108" oid="buttonData.button" showlabel="false" top="96" width="390"/>
<param expand="true" height="64" left="532" oid="rename" top="109" width="255"/>
<param expand="true" height="62" left="550" oid="buttonData.selected" top="193" widget="0" width="233"/>
<button buttontype="push" height="59" left="546" name="do rename" top="294" width="236">
<task tasktype="ogscript">var target = params.getValue('buttonData.selected', 0);
params.setValue('buttonData.button.'+ target +'.name', 0, params.getValue('rename', 0));</task>
</button>
</abs>
------------------------------
Keisuke Nagata
------------------------------