您可以使用内置的 !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");