ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Returning the same text from an old layer, on a new layer, minus the final line

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Thom Johnson
Returning the same text from an old layer, on a new layer, minus the final line
on Feb 26, 2020 at 6:05:28 pm

Hi!

I'm fairly new to expressions and I'm not exactly sure how to proceed with this.

I'd like my new text layer to contain the exact same text as another layer in the same comp, but without the last line.

Here is the error message:

Object of type TextProperty found where Number, Array or Property is needed

I was under the impression that tex.split() turns text into an array? Maybe I'm mistaken.

Any help is much appreciated :)

s = thisComp.layer("Same text, But without The final line"); //original layer
o = thisLayer // new layer
sourceTxt = s.text.sourceText; // original text
newTxt = o.text.sourceText; // new text
lineSplitTxt = sourceTxt.split("\r"); // splits the original text by line
lastLine = lineSplitTxt[lineSplitTxt.length-1]; // returns the last line of original text

newTxt = sourceTxt -= lastLine // I want new text layer to be same as original WITHOUT the last line



Return to posts index

Dan Ebberts
Re: Returning the same text from an old layer, on a new layer, minus the final line
on Feb 26, 2020 at 7:18:03 pm

This should work:


inText = thisComp.layer("Same text, But without The final line").text.sourceText;
splitText = inText.split("\r");
outText = "";
for (i = 0; i < splitText.length-1;i++){
outText += (i == 0 ? "" : "\r") + splitText[i];
}
outText



Dan



Return to posts index

Andrei Popa
Re: Returning the same text from an old layer, on a new layer, minus the final line
on Feb 27, 2020 at 7:43:14 am

Sholdn't this be faster and easier?

sourceText= thisComp.layer("Same text, But without The final line").text.sourceText;
sourceText.split("\r").slice(0,-1).join("\r")


Andrei
My Envato portfolio.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]