How to use Source Text property with Scripting?
Posted: May 21st, 2013, 6:58 am
Hey guys,
i have a quick question for you that is currently slowing me down on a scripting project.
When i use the following code to alert the length of a source text string from the first layer within a comp, i just get an error:
The error says "function comp.layer(1).text.sourceText.value.text.length();" is undefined. I have tried different variations of this line but i never get a sufficient result. The only variant that actually returns something is "comp.layer(1).text.sourceText.value;" which alerts the text written in the source text property.
But i need to do various length checks to compare line lengths, amount of line breaks etc. .split() is not working either. What am I doing wrong? In expressions, this was never a problem. I must be missing just a tiny detail to make it work.
i have a quick question for you that is currently slowing me down on a scripting project.
When i use the following code to alert the length of a source text string from the first layer within a comp, i just get an error:
Code: Select all
app.beginUndoGroup("get text length");
var comp = app.project.activeItem; //selected composition
txt = comp.layer(1).text.sourceText.value.text.length(); // get selected comp's first text layer's text length (amount of characters)
alert(txt);
app.endUndoGroup();
But i need to do various length checks to compare line lengths, amount of line breaks etc. .split() is not working either. What am I doing wrong? In expressions, this was never a problem. I must be missing just a tiny detail to make it work.