Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Repeating text on every line

  • Repeating text on every line

    Posted by Dean Gregory on July 19, 2014 at 6:24 am

    Hi there guys,

    Was just checking out some stuff on ‘for’ loops… but can’t seem get this to work.

    Wanted to see something like this:

    subject
    subject
    subject
    subject
    subject
    subject
    subject
    subject

    Basically where I can just have the text repeat line after line. I wrote an expression for Source Text that goes like this but all i get to see is one line in the output i.e. ‘subject’

    myText = “subject”;
    for(i=1; i<=8; i++){
    myText += “\r\n” ;
    }

    What am I doing wrong? Please help. Thanks!

    Cheers,

    Dean

    myText = "subject";
    for(i=1; i&lt;=8; i++){
    myText += "\r\n" ;
    }
    myText;

    Dean Gregory replied 11 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Xavier Gomez

    July 19, 2014 at 9:00 am

    You forgot to add the characters themselves in the loop.

    s = myText = “subject”;
    for(i=1; i<8; i++) s += "\r" + myText;
    s;

    Xavier

  • Dean Gregory

    July 19, 2014 at 9:22 am

    Hi Xavier,

    Thanks for your reply. Was trying at my end as well and came up with this.

    myText = “”;
    for(i=1; i<=8; i++){
    myText += “subject” + “\r\n” ;
    }

    It did the job but I’m not sure whether it is a roundabout way of handling the problem. Thanks once again!

    Cheers,

    Dean

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