Creative Communities of the World Forums

The peer to peer support community for media production professionals.

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 pm

    I 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 Ebberts
    replied 15 years, 11 months ago
    2 Members · 11 Replies
  • 11 Replies
  • Dan Ebberts

    May 17, 2010 at 4:28 pm

    Hard 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 pm

    I 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);

  • Dan Ebberts

    May 17, 2010 at 8:03 pm

    What’s in the texts.txt file?

    Dan

  • Amit Zinman

    May 17, 2010 at 8:08 pm

    Three 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 pm

    Try this:

    myPath = “/f/collager/texts.txt”;
    $.evalFile (myPath);

    Dan

  • Dan Ebberts

    May 17, 2010 at 8:17 pm

    If 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

  • Amit Zinman

    May 17, 2010 at 8:23 pm

    It still says is saying “Expected: ;”

  • Dan Ebberts

    May 17, 2010 at 8:32 pm

    I 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 pm

    Yes, 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

  • Amit Zinman

    May 17, 2010 at 8:40 pm

    Thanks! that would be most useful 🙂

Page 1 of 2

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy