Facility Control

 View Only
Expand all | Collapse all

Uhm, getElementCount not returning number of elements in IntegerArray?

  • 1.  Uhm, getElementCount not returning number of elements in IntegerArray?

    Posted 01-09-2023 07:01

    Below is the source code for a very simple DashBoard I thought I'd slap together fairly easy... But appreantly not?
    I've use the params.getElementCount so many times in previous DashBoards, but that was mainly for Struct Tables, but I figured since the description in the help documentation says "Get the number of elements in a parameter array" it should be no different... But appereantly I was wrong.

    If you take the code below, and then use the button that says "How many presets", you will get 1 in the debug field... Not the expected 60...
    Anyone that could share some insight into why?

    Edit: I've gotten as far as to know that it works with a simple array, but not a choice constraint array... So how would it work with a choice constraint array?

    <abs contexttype="opengear" dblinqport="2255" gridsize="10" id="_top" keepalive="false"><meta><params><param access="1" maxlength="0" name="superJoyIP" oid="superJoyIP" type="STRING" value="127.0.0.1" widget="text"/><param access="1" constrainttype="INT_CHOICE" name="mode" oid="mode" precision="0" type="INT32" value="0" widget="radio-toggle"><constraint key="0">Recall</constraint><constraint key="1">Rename</constraint></param><param access="1" constrainttype="INT_CHOICE" name="camerapresets" oid="cameraPresets1" precision="0" type="INT16_ARRAY" value="-1" widget="radio-toggle"><constraint key="1">test1</constraint><constraint key="2">test2</constraint><constraint key="3">test3</constraint><constraint key="4">test4</constraint><constraint key="5">test5</constraint><constraint key="6">test6</constraint><constraint key="7">test7</constraint><constraint key="8">test8</constraint><constraint key="9">test9</constraint><constraint key="10">test10</constraint><constraint key="11">test11</constraint><constraint key="12">test12</constraint><constraint key="13">test13</constraint><constraint key="14">test14</constraint><constraint key="15">test15</constraint><constraint key="16">test16</constraint><constraint key="17">test17</constraint><constraint key="18">test18</constraint><constraint key="19">test19</constraint><constraint key="20">test20</constraint><constraint key="21">test21</constraint><constraint key="22">test22</constraint><constraint key="23">test23</constraint><constraint key="24">test24</constraint><constraint key="25">test25</constraint><constraint key="26">test26</constraint><constraint key="27">test27</constraint><constraint key="28">test28</constraint><constraint key="29">test29</constraint><constraint key="30">test30</constraint><constraint key="31">test31</constraint><constraint key="32">test32</constraint><constraint key="33">test33</constraint><constraint key="34">test34</constraint><constraint key="35">test35</constraint><constraint key="36">test36</constraint><constraint key="37">test37</constraint><constraint key="38">test38</constraint><constraint key="39">test39</constraint><constraint key="40">test40</constraint><constraint key="41">test41</constraint><constraint key="42">test42</constraint><constraint key="43">test43</constraint><constraint key="44">test44</constraint><constraint key="45">test45</constraint><constraint key="46">test46</constraint><constraint key="47">test47</constraint><constraint key="48">test48</constraint><constraint key="49">test49</constraint><constraint key="50">test50</constraint><constraint key="50">test51</constraint><constraint key="50">test52</constraint><constraint key="50">test53</constraint><constraint key="50">test54</constraint><constraint key="50">test55</constraint><constraint key="50">test56</constraint><constraint key="50">test57</constraint><constraint key="50">test58</constraint><constraint key="50">test59</constraint><constraint key="50">test60</constraint></param></params></meta><simplegrid cols="6" height="760" hspace="2" left="100" rows="10" top="160" vspace="2" width="810"><param expand="true" oid="cameraPresets1" style="style:toggleButton;" widget="radio-toggle"><task tasktype="ogscript">function presetRecall(group, camId, preset) {var ip = params.getValue('superJoyIP', 0);var url = 'http://' + ip + '/cgi-bin/joyctrl.cgi?f=directpresets&amp;action=recall&amp;group=' + group + '&amp;camid=' + camId + '&amp;preset=' + preset + '&amp;presetspeed=24'ogscript.debug(url);}var x = params.getValue('cameraPresets1', 0);var mode = params.getValueAsString('mode', 0);if(x != -1) {if(mode == 'Recall') {//If set to recall, do this...var x = params.getValue('cameraPresets1', 0);var text = params.getValueAsString('cameraPresets1', 0);var camId = 1;var group = 1;presetRecall(group, camId, x);params.setValue('cameraPresets1', 0, -1);} else if (mode == 'Rename') {//If set to rename, do this function somehow...}//IF SET TO RENAME}</task></param></simplegrid><param expand="true" height="40" left="450" oid="superJoyIP" top="30" width="270"/><param expand="true" height="30" left="760" oid="mode" style="style:toggleButton" top="40" width="240"/><simplegrid cols="6" hspace="2" left="950" rows="10" top="490" vspace="2"/><button buttontype="push" height="60" left="980" name="How many presets?" top="360" width="190"><task tasktype="ogscript">ogscript.debug(params.getElementCount('cameraPresets1'));</task></button></abs>


    ------------------------------
    Aleksander Stalsberg
    Inland Norway University of Applied Sciences/Lillehammer Icehockey Club
    Norway
    ------------------------------


  • 2.  RE: Uhm, getElementCount not returning number of elements in IntegerArray?

    Posted 01-09-2023 10:31

    Ok, so this is an issue with choice constraints arrays appereantly. Seeing as the value selected it only 1, therefor it returns as 1. Makes sense that way.

    So follow up question... Can I find out how many options there are in a choice constraint list, and can I pull each value out somehow?



    ------------------------------
    Aleksander Stalsberg
    Inland Norway University of Applied Sciences/Lillehammer Icehockey Club
    Norway
    ------------------------------