Help regarding inserting multiple spaces

Post your questions and help other users.

Moderator: Martin

Post Reply
akhileshg1988
Posts: 109
Joined: 16 Apr 2014 04:57

Help regarding inserting multiple spaces

Post by akhileshg1988 » 19 Sep 2017 05:56

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=

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Help regarding inserting multiple spaces

Post by Desmanto » 19 Sep 2017 06:22

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Help regarding inserting multiple spaces

Post by Desmanto » 21 Sep 2017 01:53

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply