-
Expression error referencing a line of text that sometimes doesn’t exist
This has come really handy at the moment
txt = value;
if (text.sourceText.length >= 50){
for (i = 50; i > 0; i–)
if (txt[i] == ” “) break;
if (i > 0)
txt.substr(0,i) + “\r” + txt.substr(i+1)
else
txt.substring(0,61) + “\r” + txt.substring(62,999);
}else{
txt
}I use is alongside this
mySplit = thisComp.layer(“Text”).text.sourceText.split(“\r”);
mySplit[1];But I have text immediately below it, so I’ve included an additional part so it now looks like this.
mySplit = thisComp.layer(“Programme Title”).text.sourceText.split(“\r”)
mySplit[1];if (mySplit[1].length > 0) yPos = 176
else yPos = 156;xPos = 410;
[xPos,yPos]
However this only work if there is text on the line, I thought that by adding “mySplit[1].length = 0”, but the line doesn’t officially exist until the text moves down to the next line.
Would a try catch expression fix this?
At the moment I’ve cheated it and and I get an expression error, but it still works. I just want it to be clean and not bring up the error.