• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Convert One Line List to Multiple Line in the Script

Enthusiast ,
Apr 10, 2021 Apr 10, 2021

Copy link to clipboard

Copied

Hi Experts

Im Wondering How do I Convert Long List in My Script to Small One?, I have a list of numbers Look like :

 

MyList = ["1", "2", "3", "4", "5", etc to----> ,"1000"]

 

So it is so long in the script , So how i can make it appear divided in Multiple Lines? My Question is How to make the multiple return automatically (it will create multiple lines of the list) ?

Thanks in Advance

Best

M.Hasanain

Best
Mohammad Hasanin
TOPICS
Scripting

Views

214

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 11, 2021 Apr 11, 2021

Maybe you could try the wrap feature of editors and define the no. of characters after which the code line has to be wrapped to the next line. You could use soft wrap if just the appearance of the line is what you need, but you don't want to insert an actual newline character. See the following

https://stackoverflow.com/questions/319925/difference-between-hard-wrap-and-soft-wrap

-Manan

Votes

Translate

Translate
Community Expert ,
Apr 10, 2021 Apr 10, 2021

Copy link to clipboard

Copied

I don't really understand but, ... a for loop?

var makeArr = function() {

var a = new Array(1000);  

for (var i = 0; i < 1000; i++) {

     a[i] = i + 1 + "";

}

return a;

}

var MyList = makeArr();

 

Otherwise, you can put as many return marks as you want in the code:

a =["1","2","3",

"4","5","6",

"7","8","9",

//Etc

];

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 11, 2021 Apr 11, 2021

Copy link to clipboard

Copied

Thanks Mr.brianp311 for your reply, yes the second answer is what i mean, so how i can put many return marks in my code autmatically ? Like you showed me here :

a =["1","2","3",
"4","5","6",
"7","8","9",
//Etc
];

Thank You again

Best
Mohammad Hasanin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2021 Apr 11, 2021

Copy link to clipboard

Copied

If it's about splitting the array definition across multiple lines then you can try the following

var MyList = [1,
2,3, 
4, 
5]
alert(MyList)

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 11, 2021 Apr 11, 2021

Copy link to clipboard

Copied

Thank You Mr.Manan But My Question is How to make the multiple return automatically ? do you think it can be done automatically?

Best
Mohammad Hasanin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2021 Apr 11, 2021

Copy link to clipboard

Copied

Maybe you could try the wrap feature of editors and define the no. of characters after which the code line has to be wrapped to the next line. You could use soft wrap if just the appearance of the line is what you need, but you don't want to insert an actual newline character. See the following

https://stackoverflow.com/questions/319925/difference-between-hard-wrap-and-soft-wrap

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 11, 2021 Apr 11, 2021

Copy link to clipboard

Copied

Thank you it Works from View Menu of the Editor (View > Word Wrap) -Shift + Ctrl + W

Word Wraps.jpg

Best
Mohammad Hasanin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 11, 2021 Apr 11, 2021

Copy link to clipboard

Copied

LATEST

Thank You @brianp311  Thank You @Manan Joshi  for your great Help

Best Regards

M.Hasanain

Best
Mohammad Hasanin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines