Subject says it all really, how can I replace the current data stream via Run Script?
It references it in the following sample, but no example: http://content.objectiflune.com/content/files/planetpress/script_db%20to%20xml.zip
Thanks
Liam
Subject says it all really, how can I replace the current data stream via Run Script?
It references it in the following sample, but no example: http://content.objectiflune.com/content/files/planetpress/script_db%20to%20xml.zip
Thanks
Liam
Hi Liam,
Essentially, in order to replace the current data file, you just write to the Watch.GetCurrentJobFile location.
Here’s a basic script that reads the job file line by line (you can skip that part if you don’t need it), and then writes a single line back to the data file which overwrites it:
var fso = new ActiveXObject("Scripting.FileSystemObject");
var source_file = fso.OpenTextFile(Watch.GetJobFilename(), 1);
var source_contents = source_file.ReadAll();
while (!source_file.atEndOfSTream) {
text = source_file.ReadLine();
// Do something with the line?
}
source_file.Close();
var output_file = fso.OpenTextFile(Watch.GetJobFilename(), 2);
output_file.WriteLine("This is a line of text that appears in the new data file");
output_file.Close();
Hope this helps!
~Evie