Skip to main content
Inspiring
July 14, 2018
Answered

Get path of current .jsx file?

  • July 14, 2018
  • 2 replies
  • 2496 views

Hello,

All is in the title: is there a way to get full path of the current .jsx file being executed?

(an equivalent to PHP $_SERVER[SCRIPT_FILENAME] )

Thank you.

This topic has been closed for replies.
Correct answer r-bin

In which situation do you need a script file name?

$.fileName is not suitable?

2 replies

r-binCorrect answer
Legend
July 14, 2018

In which situation do you need a script file name?

$.fileName is not suitable?

frmorelAuthor
Inspiring
July 15, 2018

Thank you r-bin, I just didn't know $.fileName

JJMack
Community Expert
Community Expert
July 14, 2018

You could through and error and catch where.

// Find the location where this script resides

function findScript() {

   var where = "";

   try {

      FORCEERROR = FORCERRROR;

   }

   catch(err) {

      // alert(err.fileName);

      // alert(File(err.fileName).exists);

     where = File(err.fileName);

   }

   return where ;

}

JJMack
Kukurykus
Legend
July 14, 2018

$.level = 0, arr = []; try{whatever} catch(err) {for(i in err) arr.push(i)} arr

Does anyone know how to access content of err without try catch...statemnt? I mean how to check all err object items?

Legend
July 14, 2018

alert(Error().fileName)

?