Stringsplit nicely creates an array (pseudo or real) from a string.
Is there a way to create a string from an array WITHOUT USING A LOOP? I believe the array would have to be an object (not a "pseudo" array).
Put more simply: Does Stringsplit have a converse?
I'm using Stringsplit to create an array from an .INI file entry. Then use the array's values in my script. And then store any changes back to the .INI file (not that the .INI part has anything to do with this question).
Create a string from an array without looping
Re: Create a string from an array without looping
No, there is no StrJoin - but its very easy to write one - wishlist + discussion https://autohotkey.com/boards/viewtopic.php?t=25918
Re: Create a string from an array without looping
Well, if the number of elements in your array is static/known, no big deal ...Is there a way to create a string from an array WITHOUT USING A LOOP? I believe the array would have to be an object (not a "pseudo" array).
Code: Select all
array := StrSplit("bla blu blo bli", " ")
MsgBox % string := array[3] "`n" array[1] "`n" array[2] "`n" array[4]
Beware. Loops ahead!
Spoiler
Re: Create a string from an array without looping
@Bobo oooh, is that ugly.... But, thanks, and, no my array varies. I think that's the point. I'm no loopaphobe... just thought it would be much more than it works out to be.
it's so easy, I don't even think it would be worth having a command. I just learned FOR, so the loop is not ugly and probably as fast as any builtin command.
it's so easy, I don't even think it would be worth having a command. I just learned FOR, so the loop is not ugly and probably as fast as any builtin command.
Code: Select all
for kk,value in myarray ; loop, getting each KKth item, storing in VALUE
mystring .= "," . value
mystring := substr(mystring,2)
Re: Create a string from an array without looping
For loops are easily my favorite loop since I found out about them. Another dead simple for loop that is really handy when dealing with arrays:
Spent a while wondering why AutoStar has no native Object.Contains() function until I realized writing one is literally three lines of code.
Code: Select all
for index, value in haystack
if (value = needle)
return index
return 0
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], scriptor2016, Xtra and 140 guests