Activity › Forums › Adobe After Effects Expressions › including external text file in an expression
-
including external text file in an expression
Posted by Amit Zinman on May 17, 2010 at 4:05 pmI am applying the expression below to the Source Text property of a text layer.
However, for some reason I am getting a Syntax Error on this.What am I doing wrong?
#include 'file:///f:/collager/texts.txt';
try{eval(thisLayer.name)}catch(err){"not found"}Dan Ebbertsreplied 15 years, 11 months ago 2 Members · 11 Replies
-
11 Replies
-
Dan Ebberts
May 17, 2010 at 4:28 pmHard to say, but if you’re using CS4 or CS5, #include won’t work and you’ll need to switch to $.evalFile(yourPath). It also depends on what’s in your text file and what you’re trying to do. The text file can only consist of valid JavaScript statements (not just text).
Dan
-
Amit Zinman
May 17, 2010 at 7:56 pmI am trying to use *.evalFile but am getting all kind of syntax errors 🙁
For the code below it says: “Expected: ;”myPath = "file://f:\\Collager\";
myPath += "texts.txt";
$.evalFile (myPath);
eval(thisComp.name); -
Amit Zinman
May 17, 2010 at 8:08 pmThree lines of javascript code.
But it’s not even getting there. It’s just stopping on line on the path defintion.
I am trying to access a file names “texts.txt” located at “f:\collager”text001a = "Special Weddings";
text001b = "Are great";
text001c = "and Cheap!"; -
Dan Ebberts
May 17, 2010 at 8:14 pmTry this:
myPath = “/f/collager/texts.txt”;
$.evalFile (myPath);Dan
-
Dan Ebberts
May 17, 2010 at 8:17 pmIf your text file is something you want to display as a block in a text layer, you could set it up like this with the new triple quote syntax:
“””
Special Weddings\r
Are great\r
and Cheap!
“””Dan
-
Dan Ebberts
May 17, 2010 at 8:32 pmI just used this expression with on text layer using your text file (I had to substitute my s drive for your f drive):
myPath = “/s/collager/texts.txt”;
$.evalFile(myPath)The result was “and Cheap!” which is what I would expect, since that was the last result evaluated. I didn’t get any errors.
Dan
-
Amit Zinman
May 17, 2010 at 8:35 pmYes, finally cracked the problem.
It’s probably an Adobe bug just throwing the wrong error. It threw the error for the eval function because the layer name was wrong.
Howver, the error specified line 1 for some reason
Reply to this Discussion! Login or Sign Up