Hi James,
From the above code, I think the issue is with the usage of params.getValue() method.
The syntax of params.getValue() should be params.getValue (OID, Index);
In the above example, you successfully provide the OID but the index is missing. Since Ticker_text is not an array, you can use the value of the index as '0'.
Also, there is a typo at the end of the getValue() method. Instead of using a semicolon, there is a comma.
Your code should look something similar to this:
<task tasktype="ogscript">/*! block id=1009!*/
var fileContent += params.getValue("Ticker_Text", 0);
var filePath = "localhost/C$/Users/me/Documents/text-test.txt";
ogscript.saveToFile(filePath, fileContent, true); // SAVE TO THE FILE</task>
I hope this helps. Please reach out if this doesn't work for you.
---------------------------------------------------------------
Here is an example grid panel for your reference:
<abs contexttype="opengear" style="">
<meta>
<params>
<param access="1" maxlength="0" name="Text to write" oid="params.text" type="STRING" value="This is a test. sge" widget="multiline-text"/>
<param access="1" maxlength="0" name="File Name" oid="params.file" type="STRING" value="text.txt" widget="file-picker"/>
<param access="1" constrainttype="INT_CHOICE" name="Mode" oid="params.mode" precision="0" type="INT16" value="0" widget="default">
<constraint key="0">Overwrite</constraint>
<constraint key="1">Append</constraint>
</param>
</params>
</meta>
<param expand="true" height="42" left="20" oid="params.file" showlabel="false" top="19" width="457"/>
<param expand="true" height="212" left="16" oid="params.text" showlabel="false" top="74" width="456"/>
<param expand="true" height="43" left="16" oid="params.mode" showlabel="false" top="298" width="333"/>
<button buttontype="push" height="51" left="354" name="Write" top="295" width="120">
<task tasktype="ogscript">var filePath = params.getValue("params.file", 0);
var fileContent = "";
if (params.getValue("params.mode", 0) == 1) //IF WE ARE IN "APPEND MODE"
{
fileContent = ogscript.post(filePath, null); //READ THE CURRENT FILE
if (fileContent == null)
{
fileContent = "";
}
fileContent += "\n"; //ADD A NEW LINE
}
fileContent += params.getValue("params.text", 0); //GET THE VALUE TO WRITE TO THE FILE
ogscript.saveToFile(filePath, fileContent, true); // SAVE TO THE FILE</task>
</button>
</abs>
---------------------------------------------------------------
Best Regards,
------------------------------
Altaz Daruwala
Ross Video
------------------------------
Original Message:
Sent: 09-12-2023 18:42
From: James Moyer
Subject: Dashboard - Write Text Input to a File
Hi,
I'm trying to have a text entry field in Dashboard write the text to a file when a button is pushed. Here is the ogscript line I've written for the button. The paramater for the text is called "Ticker_Text":
<task tasktype="ogscript">/*! block id=1009!*/
ogscript.saveToFile('localhost/C$/Users/me/Documents/text-test.txt','(params.getValue('Ticker_Text'))', true),</task>
But it returns errors. Any recommendation? Thank you.
------------------------------
James Moyer
------------------------------