Spending lot of time, and finding old syntax examples which does not work made my do hard way, to make it simple.
Simple and fast solution for concatenating directory spliced into strings array:
Loop, % folder_path_array.MaxIndex() ; concat string array
{
folder_path .= folder_path_array[A_Index]"\"
}
More advanced version, in case you have ending backslash in path field:
Loop, % folder_path_array.MaxIndex() ; concat array
{ if folder_path_array[A_Index] ; if [last] element of array is empty, skip it
folder_path .= folder_path_array[A_Index]"\"
}
In more deep details.
I needed to copy directory path from input field, change the root directory, paste it back to input field and save it.
So I ended up with this script:
SendInput, ^a ; select all input field text
SendInput, ^c ; copy current selection to clipboard
ClipWait, 30
folder_path_array := StrSplit(Clipboard, "\") ; split folder path into strings of array
folder_path_array[2] .= "_backup" ; prepend string to root folder, first element is "C:"
Loop, % folder_path_array.MaxIndex() ; concat string array
{ if folder_path_array[A_Index] ; if [last] element of array is empty, skip it
folder_path .= folder_path_array[A_Index]"\"
}
Clipboard := folder_path ; load the new string to clipboard
SendInput, ^v ; paste the new string into input field
Hope it will help somebody also.