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 && file.exists() && file.isDirectory())
{
var filter = ".jpg"; //In this example, we only want jpg files
var list = file.list();
var filteredList = [];
for (var i = 0; i < 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