including external text file in an expression

Moderators: Disciple, zlovatt

Post Reply
amitzinman
Posts: 17
Joined: November 22nd, 2007, 4:56 am
Location: Tel Aviv
Contact:

My expression is as follows:

#include 'file:///f:/collager/texts.txt';
try{eval(thisLayer.name)}catch(err){"not found"}


and I am applying it to the Source Text property of a text layer.
However, for some reason I am getten a Syntax Error on this.

What am I doing wrong?
nab
Posts: 203
Joined: November 29th, 2005, 3:00 am
Location: Royan
Contact:

You can read a file and eval its content using evalFile, like this:

Code: Select all

$.evalFile(path_to_your_file)
This should work in both CS4 and CS5.
MazingaZ
Posts: 3
Joined: October 18th, 2011, 8:47 am

Hi there, I'm new here.
I hope there will be someone that will help me.
I need to copy a text from an external .txt file and assign it to source text. I've tried everything was possible I've find here and also the following expressions I've found over the web but no chance to work in CS5.5. Please do everybody have a solution?

1)

myPath = “file://c:\\\\Expressions\\”;
myPath += “data.txt”;
$.evalFile (myPath);
eval(thisComp.name);
}catch(err){“Not Found”}

2)

$.evalFile("c:\\\\Expressions\\text.txt"); eval(thisLayer.name);

3)

myPath = "/media/text.txt";
try{
$.evalFile (myPath);
eval(thisComp.name);
}catch (err){
"not found"
}



Thank you so much in advance,

Davide
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

Try it this way:

$.evalFile("/c/Expressions/text.txt");

I tried it with a text.txt file containing this:

"test"

and it seems to work fine.


Dan
MazingaZ
Posts: 3
Joined: October 18th, 2011, 8:47 am

Hi Dan,
thank you so much for your help!!!
It worked!!!!! Just a question how can I do if I have a text on multiple raws?
THANK YOU AGAIN!!!!!!!!!

Davide
Dan Ebberts wrote:Try it this way:

$.evalFile("/c/Expressions/text.txt");

I tried it with a text.txt file containing this:

"test"

and it seems to work fine.


Dan
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

If I understand what you're asking, you just need to separate the text lines in your file with backslash+r, like this:

"Text Line 1\rText Line 2\rText Line 3"


Dan
MazingaZ
Posts: 3
Joined: October 18th, 2011, 8:47 am

THIS IS EXACTLY WHAT I WANTED!!!!!!!!! THANK YOU SO MUCH DAN!!!!!!

Davide
Dan Ebberts wrote:If I understand what you're asking, you just need to separate the text lines in your file with backslash+r, like this:

"Text Line 1\rText Line 2\rText Line 3"


Dan
Post Reply