Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects AE Scripting: Getting info from a text file

  • AE Scripting: Getting info from a text file

    Posted by Øyvind Veberg on June 7, 2005 at 6:26 pm

    Hi!

    I’ve been reading about scripting on Dan Ebberts VERY informative site http://www.motionscript.com. Particularly I found the article about creating text layers from a file very useful. However, I’m having some trouble getting AE to “behave” when there is a line break (and no text) in the file it is reading. What I want to do is make AE “skip” the “empty” line, and continue reading the file.

    An example of text to be read:

    Hello, world!

    This is a test!

    The line between “Hello, world!” and “This is a test!” is empty… If I replaced the line break with “-“, I got it working somehow with this code:

    var text;
    while (!myFile.eof){
    text = myFile.readln();

    if(text==”-“)
    myFile.readln();

    else

    myComp.layers.addText(text);

    But this not very efficient, since I would have to replace every line break with “-“…

    As you guys might have figured out, I’m not a scripting expert, but I know some of you are… Hope you can help me out (It’s probably very basic…).

    Cheers!

    Øyvind Veberg replied 20 years, 11 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    June 7, 2005 at 6:57 pm

    Try it this way:

    
    var text;
    while (!myFile.eof){
      text = myFile.readln();
      if(text.length != 0) myComp.layers.addText(text);
    }
    
    

    That should detect the line breaks.

    Dan

  • Øyvind Veberg Create COW Profile Image

    Øyvind Veberg

    June 7, 2005 at 7:06 pm

    Hi!

    Thanks, Dan! It did the trick!

    Cheers!

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