我希望能够从我的javascrip脚本中引用iMacros文件夹,以便编写:
retcode = iimPlay(folder + "/macro1.iim");
retcode = iimPlay(folder + "/macro2.iim");
而不是
retcode = iimPlay("test/macro1.iim");
retcode = iimPlay("test/macro2.iim");
我知道it is possible in vbs但我不知道javascript是否就是这种情况。
答案 0 :(得分:2)
它以与javascript类似的方式工作,这是代码示例:
var folder="c:\\data\\"
iimPlay(folder+"1.iim");
此代码将从c:\ data文件夹
运行1.iim脚本答案 1 :(得分:0)
您可以使用内置的!FOLDER_DATASOURCE变量来获取当前javascript宏的文件夹。
//Extract folder path of 'Datasources' folder (located inside 'iMacros' folder)
iimPlayCode("SET !EXTRACT {{!FOLDER_DATASOURCE}}");
var folderPath = iimGetExtract();
//Remove 'Datasources' from end of folder path string
folderPath = folderPath.slice(0,-11);
//Append 'Macros' to end of above path
folderPath = folderPath+"Macros\\";
alert(folderPath);
在单个命令中执行上述步骤。
//Extract folder path of 'Datasources' folder (located inside 'iMacros' folder)
iimPlayCode("SET !EXTRACT {{!FOLDER_DATASOURCE}}");
//Remove 'Datasources' from end of folder path string and append 'Macros'
var folderPath = iimGetExtract().slice(0,-11)+"Macros\\";
alert(folderPath);
另一种可能的方法是在文件夹路径中将“数据源”替换为“宏”。
//Extract folder path of 'Datasources' folder (located inside 'iMacros' folder)
iimPlayCode("SET !EXTRACT {{!FOLDER_DATASOURCE}}");
//Replace 'Datasources' with 'Macros' in folder path string
var folderPath = iimGetExtract().replace("Datasources","Macros\\");
alert(folderPath);
但是,如果文件夹路径在其他任何地方包含“数据源”,则可能会产生问题。您可以根据自己的选择使用上述任何一种方法。
一旦获得“宏”文件夹的文件夹路径,就可以使用它。
retcode = iimPlay(folderPath + "macro1.iim");