Page 1 of 1

Help regarding inserting multiple spaces

Posted: 19 Sep 2017 05:56
by akhileshg1988
Hey everyone!
I want to insert (dynamic number of) multiple spaces inside a text field. How can this be achieved using \n?
I figured out that in order to insert three spaces i need to do the following

s="\n";
s=s+s+s;

which led me to the conclusion that in order to insert say x number of spaces, I need to sum the variable 's' x number of times i.e. I need to use the mathematical function summation. Unfortunately there's no ∑ (summation function) in the action script.
Kindly help in this regard.

Thus far, I've developed the following

n="\n";
diff=10;
i=0;
while(i<=diff)
{
i=i+1;
n= ;
};

What should I write after n=

Re: Help regarding inserting multiple spaces

Posted: 19 Sep 2017 06:22
by Desmanto
Multiple spaces >> mutiple blank lines?
To "sum string", use concatenate, concat()
concat("hello", "\n") will give "hello\n"

I usually use for() loop

Code: Select all

diff = 10;
n = "";

for(i in [1 to diff])
  n = concat(n,"\n")
n now has 10 blank lines.

Re: Help regarding inserting multiple spaces

Posted: 21 Sep 2017 01:53
by Desmanto
I forgot to type the other way. For simple space or newline concatenation, you can just use inline expression.

Code: Select all

n = "{n}\n"
concat() is mostly used when you have to use some dynamic value or want to eval value first before concat them.