Copy link to clipboard
Copied
Hi,
I want to integrate an external python script into the current extendscript I use in RoboHelp 10. Is there a way to do that?
Thanks,
Lauren
Copy link to clipboard
Copied
You can use the command line to call any kind of external application.
Personally, I use the following function to create bat files to do such
work.
I've taken these functions from my free RH Extendscript library -
http://www.wvanweelden.eu/product/robohelp-extendscript-library
function ExecuteBatchFile(command, waitforbatch) {
if(string_isEmpty(command))
return false;
if(!waitforbatch) {
if(waitforbatch != false) {
waitforbatch = true;
}
}
var path = Folder.appData.fsName + '/';
var batFileName = 'ExtendScriptBatchFile';
var batFileExtension = '.bat';
var batFile = new File(pathbatFileNamebatFileExtension);
if(batFile.exists) {
var i = 0;
while(batFile.exists) {
i++;
batFile = new File(pathbatFileNamei+batFileExtension);
}
}
command+= "\ndel /F /Q \"" + batFile.fsName + "\"";
writeFile(batFile, command, false);
if(!isFile(batFile, true))
return false;
batFile.execute();
/* Wait on batch file execution if needed */
if(waitforbatch) {
while(batFile.exists) {
msg(".");
$.sleep(100);
}
}
return true;
}
function writeFile(file, szOutput, encoding) {
var szFilePath = file.fsName;
if(!encoding || encoding == true) {
encoding = "UTF-8";
}
var fileObj = new File(szFilePath);
fileObj.encoding = encoding;
fileObj.open("w");
fileObj.write(szOutput);
fileObj.close();
}
Kind regards,
Willam
Copy link to clipboard
Copied
William,
I am not all that familiar with Javascript or extendscript. Can you provide a link to something that provides more detail about using the command-line?
Thanks,
Lauren
Copy link to clipboard
Copied
For the function mentioned above, create a string with the cmd command:
var cmd = "python -myparameters"
ExecuteBatchFile(cmd, true);
Just make sure to make the functions of my previous post available in
your script.
Kind regards,
Willam