Hi Matt.
Here is an example that will take 'game-two.xml' or 'game-one.xml' and write them to 'game-active.xml'.
<abs contexttype="opengear" style="">
<meta>
<api>function loadFile(filePath)
{
var xmlContent = ogscript.parseXML(filePath);
if (xmlContent != null)
{
ogscript.saveToFile('game-active.xml', xmlContent);
}
}
</api>
</meta>
<simplegrid height="109" left="13" rows="1" top="14" width="383">
<button buttontype="push" name="Load Game One">
<task tasktype="ogscript">loadFile('game-one.xml');</task>
</button>
<button buttontype="push" name="Load Game Two">
<task tasktype="ogscript">loadFile('game-two.xml');</task>
</button>
</simplegrid>
</abs>
Another option, if your remote file is updated frequently, is to use a timer to update the 'active' game file every few seconds:
<abs contexttype="opengear">
<timer pattern="HH:mm:ss" rate="2000">
<timertask tasktype="ogscript">loadActiveFile();</timertask>
</timer>
<meta>
<api>function setActiveFile(fileName)
{
ogscript.putObject('active-file', fileName);
loadActiveFile();
}
function loadActiveFile()
{
var activeFile = ogscript.getObject('active-file');
if (activeFile != null)
{
loadFile(activeFile);
}
}
function loadFile(filePath)
{
var xmlContent = ogscript.parseXML(filePath);
if (xmlContent != null)
{
ogscript.saveToFile('game-active.xml', xmlContent);
}
}</api>
</meta>
<simplegrid height="109" left="13" rows="1" top="14" width="383">
<button buttontype="push" name="Load Game One">
<task tasktype="ogscript">setActiveFile('game-one.xml');</task>
</button>
<button buttontype="push" name="Load Game Two">
<task tasktype="ogscript">setActiveFile('game-two.xml');</task>
</button>
</simplegrid>
</abs>
#DashBoard