Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE AFTER EFFECTS:HomeForumBasicsExpressionsTutorialsPodcastsMotion GraphicsTrainingCinema 4DFAQ

including external text file in an expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Amit Zinmanincluding external text file in an expression
by on May 17, 2010 at 4:05:51 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"}




Return to posts index
Reply   Like  

Dan EbbertsRe: including external text file in an expression
by on May 17, 2010 at 4:28:20 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



Return to posts index
Reply   Like  

Amit ZinmanRe: including external text file in an expression
by on May 17, 2010 at 7:56:14 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);




Return to posts index
Reply   Like  


Dan EbbertsRe: including external text file in an expression
by on May 17, 2010 at 8:03:09 pm

What's in the texts.txt file?


Dan



Return to posts index
Reply   Like  

Amit ZinmanRe: including external text file in an expression
by on May 17, 2010 at 8:08:11 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!";




Return to posts index
Reply   Like  

Dan EbbertsRe: including external text file in an expression
by on May 17, 2010 at 8:14:53 pm

Try this:

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


Dan



Return to posts index
Reply   Like  


Amit ZinmanRe: including external text file in an expression
by on May 17, 2010 at 8:23:39 pm

It still says is saying "Expected: ;"



Return to posts index
Reply   Like  

Dan EbbertsRe: including external text file in an expression
by on May 17, 2010 at 8:32:25 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



Return to posts index
Reply   Like  

Amit ZinmanRe: including external text file in an expression
by on May 17, 2010 at 8:35:56 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



Return to posts index
Reply   Like  


Dan EbbertsRe: including external text file in an expression
by on May 17, 2010 at 9:01:16 pm

Ah, OK - I get in now. The variable names in your text file are supposed to match the names of the various text layers which all get the same expression and read the same file.


Dan



Return to posts index
Reply   Like  

Dan EbbertsRe: including external text file in an expression
by on May 17, 2010 at 8:17:57 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



Return to posts index
Reply   Like  

Amit ZinmanRe: including external text file in an expression
by on May 17, 2010 at 8:40:11 pm

Thanks! that would be most useful :)



Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>


FORUMSTUTORIALSMAGAZINESTOCKYARDVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2012 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]