Facility Control

 View Only
  • 1.  Dashboard array how many item in

    Posted 01-07-2019 19:14
    I have build a string array where I will read out how many item there are in so I can do a for loop to
    Handle them..
    but when I use .length I only get the lengt of the string in Frist item..
    Is there a way to get the total length???


  • 2.  RE: Dashboard array how many item in

    Posted 01-07-2019 19:27

    You can do something like the following:

    var p = params.getParam("myArray",0);
    ogscript.debug(p.getElementCount());

    getElementCount returns how many elements in the parameter.


    #DashBoard


  • 3.  RE: Dashboard array how many item in

    Posted 01-08-2019 08:46
    Thanks I have tried but get an error "cannot find function getelementcount in object"
    #DashBoard


  • 4.  RE: Dashboard array how many item in

    Posted 01-08-2019 15:09

    Weird. Are you sure you gave it the right parameter oid (not name) for getParam? Here is a very minimal panel where that code works for me (I've also attached it):

    <abs contexttype="opengear" id="_top" style="">
    <meta>
    <params>
    <param access="1" maxlength="0" name="myArray" oid="myArray" precision="0" type="STRING_ARRAY" widget="default">
    <value>one</value>
    <value>two</value>
    <value>three</value>
    <value>four</value>
    <value>five</value>
    <value>six</value>
    </param>
    </params>
    </meta>
    <param expand="true" height="482" left="89" oid="myArray" showlabel="false" top="46" width="264"/>
    <button buttontype="push" height="83" left="592" top="156" width="286">
    <task tasktype="ogscript">var p = params.getParam("myArray",0);
    ogscript.debug(p.getElementCount());</task>
    </button>
    <button buttontype="push" left="502" top="401"/>
    </abs>

    When I click on the button, it prints "6" which, is the number of elements in the array.

    If this still does not work for you, post your parameter definition and the task code, and I can help you debug it a bit.

    ArrayCount.grid


    #DashBoard


  • 5.  RE: Dashboard array how many item in

    Posted 01-08-2019 19:02
    Thanks your panel work so I will start on a new to get it work with my array
    #DashBoard