Here is an example, assuming your text file was created like this:
0,Name 1
1, Name 2
2, Name 3
4, Name 4
etc.
Basically a comma-delimited file with each record on its own line.
You could read it with a function like this:
function readTextFile(path, oid)
{
var textFile = ogscript.createFileInput(path);
var allText = textFile.readString(textFile.getSize());
textFile.close();
var entries = [];
var allLines = allText.split("\n");
for (var i = 0; i < allLines.length; i++)
{
ogscript.debug(allLines[i]);
var record = allLines[i].split(",");
entries.push({"value": record[1], "key": record[0]});
}
var newConstraint = params.createStringStringChoiceConstraint(entries);
params.replaceConstraint(oid, newConstraint);
}
Assuming your parameter is defined like this:
<param access="1" constraintstrict="false" constrainttype="STRING_STRING_CHOICE" maxlength="0" name="Entries" oid="players" stateless="true" type="STRING" value="0" widget="default">
<constraint key="0">Player</constraint>
</param>
Then you would just call it like this:
readTextFile("pathtofile.txt", "players"); // where "players" is the oid of the param#DashBoard