Hi Cole.
This is failing because you are using a browser-based ActiveX mechanism to copy your files (it is using non-standard JavaScript). You an copy a file in ogScript but you will need to use the mechanisms available to its libraries.
Here is a general-purpose file copy function you can paste into an <api/> tag in a CustomPanel:
function copyFile(src, dst)
{
var inputFileSize = ogscript.getFileSize(src); //Get the size of the file
var input = null; //Create input/output reader/writer variables
var output = null;
try
{
input = ogscript.createFileInput(src); //Create the file reader
var bytes = input.readBytes(inputFileSize); //Read the file
output = ogscript.createFileOutput(dst, false); //Create the file writer
output.writeByteArray(bytes); //Write the file
}
catch (e)
{
ogscript.debug("EXCEPTION THROWN: " + e);
}
if (input != null) //Make sure the reader is closed
{
input.close();
}
if (output != null) //Make sure the writer is closed
{
output.close();
}
}
Here is a full panel that actually makes use of the function:
<abs contexttype="opengear" id="_top" style="">
<meta>
<params>
<param access="1" maxlength="0" name="Input File" oid="Input_File" type="STRING" value="" widget="file-picker"/>
<param access="1" maxlength="0" name="Output File" oid="Output_File" type="STRING" value="" widget="file-picker">
<config key="w.save">true</config>
</param>
</params>
<api>function copyFile(src, dst)
{
var inputFileSize = ogscript.getFileSize(src); //Get the size of the file
var input = null; //Create input/output reader/writer variables
var output = null;
try
{
input = ogscript.createFileInput(src); //Create the file reader
var bytes = input.readBytes(inputFileSize); //Read the file
output = ogscript.createFileOutput(dst, false); //Create the file writer
output.writeByteArray(bytes); //Write the file
}
catch (e)
{
ogscript.debug("EXCEPTION THROWN: " + e);
}
if (input != null) //Make sure the reader is closed
{
input.close();
}
if (output != null) //Make sure the writer is closed
{
output.close();
}
}</api>
</meta>
<param expand="true" height="37" left="43" oid="Input_File" top="34" width="269"/>
<param expand="true" height="39" left="43" oid="Output_File" showlabel="false" top="87" width="271"/>
<button buttontype="push" height="92" left="319" name="Copy" top="38" width="143">
<task tasktype="ogscript">/*! block id=1000,1001,1002 !*/
copyFile(params.getValue('Input_File', 0), params.getValue('Output_File', 0))
/*!!
<block id="1000" type="function_copyFile" x="283" y="10" w="243" src="ID:1001" dst="ID:1002" />
<block id="1001" type="param__top&amp;Input File (Input_File)[0]" x="10" y="10" w="243" SET="" />
<block id="1002" type="param__top&amp;Output File (Output_File)[0]" x="10" y="72" w="243" SET="" />
!!*/
/*!!<checksum>10fcf917cf5160a2a1e605ad05095871</checksum>!!*/</task>
</button>
</abs>
#DashBoard