I got a Var like this
1
8
0
5
7
2
And i want it to reverse the order like this (num/char doesn't matter)
2
7
5
0
8
1
Researched(sort) but no answer for this , plz help , thks
Reverse the order of a Variable Topic is solved
Re: Reverse the order of a Variable
Try:
Code: Select all
str =
(
1
8
0
5
7
2
)
DllCall("msvcrt.dll\_wcsrev", "UPtr", &str, "CDecl")
MsgBox % str
Re: Reverse the order of a Variable
it work, oh yeah , thkXtra wrote: ↑29 Jan 2023, 03:45Try:Code: Select all
str = ( 1 8 0 5 7 2 ) DllCall("msvcrt.dll\_wcsrev", "UPtr", &str, "CDecl") MsgBox % str
Re: Reverse the order of a Variable
My mistake , if the var is more than one char. it will fail...Xtra wrote: ↑29 Jan 2023, 03:45Try:Code: Select all
str = ( 1 8 0 5 7 2 ) DllCall("msvcrt.dll\_wcsrev", "UPtr", &str, "CDecl") MsgBox % str
215
900
155
144
0
0
441 (should be keeping it like 144 and so on)
551 (155)
009 (900)
512 (215)
Re: Reverse the order of a Variable Topic is solved
Try this (reverse lines, but not chars):
Code: Select all
str =
(
215
900
155
144
0
)
MsgBox, % ReverseOrderLines(str)
ReverseOrderLines(lines) {
Loop, Parse, lines, `n, `r
output := A_LoopField "`n" output
return output
}
/* Output:
0
144
155
900
215
*/
Re: Reverse the order of a Variable
https://biga-ahk.github.io/biga.ahk/#/?id=reverse
Only works with arrays, so I think for your string situation it might be something like:
Only works with arrays, so I think for your string situation it might be something like:
Code: Select all
A := new biga() ; requires https://github.com/biga-ahk/biga.ahk
str =
(
1
8
0
5
7
2
)
msgbox, % A.join(A.reverse(strSplit(str, "`n")), "`n")