13 Replies Latest reply on May 12, 2017 2:57 AM by Loic.Aigon

    How to get full path of parent script that uses #include

    TᴀW Adobe Community Professional & MVP

      Script A has an #include "ScriptB" line.


      ScriptB now needs the full path of Script A -- i.e., exactly the info you get from $.fileName if you run that line in Script A.


      But the command $.fileName if it appears in Script B returns the path to Script B, not Script A. (I always thought that #include actually causes the contents of the #include statement to be copied over to that location, but this proves that it is not quite so simple.)


      Obviously, this path could be assigned to a variable in Script A and then used in Script B. But Script B is a library component, and the whole point is not to have to update the two-dozen Script A's that are calling Script B. So I would rather not have to modify all the Script A's. It would be better if Script B stays an independent module.


      So: How to get the full path of Script A, when you're inside Script B, which has been #included in Script A?


      For a moment I thought I had found an answer: The first line of the string $.stack is the file name of Script A. But it doesn't include the path, just the file name, so not good enough.


      Can anyone help?