Page 1 of 1

Resolving the location of a script

Posted: October 19th, 2010, 12:25 pm
by mercwnz
If you run alert(Folder.current) it shows you the location of the program that is currently executing the script.
What I rather see is the location of the script that has been executed.
Because if I want to include a XMLfile, I would like to use ../'s instead of the absoluteURI
my system wrote: Current Folderlayout

jsx (folder)
-thescript.jsx

php (folder)
-somescript.php
config.xml
so my problem is with php I can include the xml using include("../config.xml"),
but if I want to include something in jsx I have to use file.open("/c/full/path/to/config.xml")

I know how to generate a jsx file with php so the fullpath is hard-coded in there, but I rather not.
Is there a way to resolve the location of the script based on the location of the script instead of the program running it?

Re: Resolving the location of a script

Posted: October 19th, 2010, 1:17 pm
by Paul Tuersley
$.fileName gives you the name and path of the running script. Here's some code to get the parent folder for the script:

Code: Select all

parentFolder = Folder(File($.fileName).parent)

Re: Resolving the location of a script

Posted: October 20th, 2010, 6:13 am
by mercwnz
wow thanks, it was breaking my brain at some point!