- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Looping over a List and concatenating a string
Hi, I have a "List" and I want to concatenate each item with the suffix "_2020" and Insert it into a new list.
I have tried this code but I am missing something. I will appreciate your input.
Thanks!
Names Default To Here( 1 );
FullNames ={};
todaysList = {"August", "July", "June", "May"};
TotalMs = N Items (todaysList);
For (i = todaysList, i <= TotalMs, i++,
newName = (todaysList[i] ||"_2020");
Insert Into (FullNames, newName),
);
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Looping over a List and concatenating a string
Your For() loop starting index was invalid. Here is your code with a slight modification to make it work
Names Default To Here( 1 );
FullNames ={};
todaysList = {"August", "July", "June", "May"};
TotalMs = N Items (todaysList);
For (i = 1, i <= TotalMs, i++,
newName = todaysList[i] ||"_2020";
Insert Into (FullNames, newName),
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Looping over a List and concatenating a string
Your For() loop starting index was invalid. Here is your code with a slight modification to make it work
Names Default To Here( 1 );
FullNames ={};
todaysList = {"August", "July", "June", "May"};
TotalMs = N Items (todaysList);
For (i = 1, i <= TotalMs, i++,
newName = todaysList[i] ||"_2020";
Insert Into (FullNames, newName),
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Looping over a List and concatenating a string
Yes, I can see my Index error, darn so obvious (after you mentioned). What I still do not understand is the lack of parenthesis around the concatenation expression. I will do some more reading.
Thank you very much.
Best regards,
Alfredo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Looping over a List and concatenating a string
Hi,
Searching the Concat function in the JMP Scripting Index (Help->Scripting Index), it can be seen that use of the double bar operator doesn't require parentheses. In case you weren't aware of it, the Scripting Index is a very powerful resource.