Question: I want to be able to reference the iMacros folder from my javascrip script in order to write:

```
retcode = iimPlay(folder + "/macro1.iim");
retcode = iimPlay(folder + "/macro2.iim");

```

instead of

```
retcode = iimPlay("test/macro1.iim");
retcode = iimPlay("test/macro2.iim");

```

I know [it is possible in vbs](http://forum.iopus.com/viewtopic.php?f=6&t=12790) but I don't know if that is the case in javascript.

Answer: 
it works in a similar way with javascript, here is example of the code:

```
var folder="c:\\data\\"
iimPlay(folder+"1.iim");

```

this code will run the 1.iim script from c:\data folder
You can make use of inbuilt !FOLDER\_DATASOURCE variable to get folder of current javascript macro.

```
//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);

```

Performing above steps in single command.

```
//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);

```

Another possible approach is to replace 'Datasources' with 'Macros' in folder path.

```
//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);

```

However it may create problem if folder path contains 'Datasources' anywhere else. You may use any of above methods as per your choice.

Once you get folder path of 'Macros' folder, you can use it like.

```
retcode = iimPlay(folderPath + "macro1.iim");

```