Facility Control

 View Only
  • 1.  Dropdown with File Location data

    Posted 08-29-2018 23:44
    Is it possible to create a dropdown with "names" that link to a certain file destination? I've tried using the string array in my parameters, however it returns my name and not the value of the selection. Essentially, I'm trying to create a dropdown of simple file names to replace a material in XPression which is changed via the value of the file path. I've been executing this through Excel, however I would like to move this into Dashboard for my operator.


  • 2.  RE: Dropdown with File Location data

    Posted 08-30-2018 14:18

    Here is an example that reads the a list of files within a directory and shows any *.jpg files in a dropdown list.

    <abs contexttype="opengear">
       <meta>
          <params>
             <param access="1" maxlength="0" name="Starting Directory" oid="Starting_Directory" type="STRING" value="C:\" widget="text"/>
             <param access="1" constrainttype="STRING_CHOICE" maxlength="0" name="File List" oid="File_List" type="STRING" value=" " widget="combo">
                <constraint/>
             </param>
          </params>
       </meta>
       <label height="40" left="15" name="Starting Directory: " style="txt-align:east" top="22" width="166"/>
       <param expand="true" height="48" left="182" oid="Starting_Directory" top="18" width="379"/>
       <label height="36" left="29" name="File List: " style="txt-align:east" top="77" width="150"/>
       <param expand="true" height="46" left="182" oid="File_List" showlabel="false" top="73" width="374"/>
       <button buttontype="push" height="49" left="570" name="Load" top="15" width="107">
          <task tasktype="ogscript">var file = ogscript.getFile(params.getValue('Starting_Directory', 0));
    if (file != null &amp;&amp; file.exists() &amp;&amp; file.isDirectory())
    {
       var filter = ".jpg";    //In this example, we only want jpg files
       var list = file.list();
       var filteredList = [];
    
       for (var i = 0; i &lt; list.length; i++)
       {
          if (list[i].toLowerCase().endsWith(filter))  //Check the filter
          {
             filteredList.push(list[i]);
          }
       }
    
       if (filteredList.length == 0)  //Put a blank if we have no files that match the filter
       {
          filteredList.push("");
       }
    
       var constraint = params.createStringChoiceConstraint(filteredList);
       if (constraint != null)
       {
          params.replaceConstraint('File_List', constraint);
       }
    }</task>
       </button>
    </abs>

    #DashBoard


  • 3.  RE: Dropdown with File Location data

    Posted 08-30-2018 14:26
    Awesome, thank you!
    #DashBoard