-
Line break expression is eating one character
I’m using the expression below to generate random text and I need to break every 8 characters, which it does for the first line, but then every line after that breaks at 7.
I tried changing the value to test the expression and the same happens, if I enter 10, the line breaks at 9 and so on.
I changed the font to see if I need a mono spaced font and the same happened.My text box is more than enough to cover for the length of the lines.
Can anyone tell me what’s going on?
Thanks.
D.rate=5;
totalChar=64;
lineBreak=10;
posterizeTime(rate);
selectionSet=["8","2","1","3","0","6"];
txt="";
for(i=0; i<totalChar; i++)
{
randomNumber=random(0,selectionSet.length);
txt += selectionSet[Math.floor(randomNumber)];
if (txt.length % lineBreak == 0) txt += "\r";
}
txt