Code: Select all
;works
MsgBox, % (A_AhkVersion < "1.1.31.01")
;doesnt work
MsgBox, % ("8.1" < "10")
Code: Select all
;works
MsgBox, % ("08.1" < "10")
just wondering if that's the only consideration, or if i'm missing some other cases
Code: Select all
;works
MsgBox, % (A_AhkVersion < "1.1.31.01")
;doesnt work
MsgBox, % ("8.1" < "10")
Code: Select all
;works
MsgBox, % ("08.1" < "10")
numeric comparison will only work for one decimal point. version strings can have endless, like 1.1.31.01
Code: Select all
if (pad("8.1") < pad("10"))
;rather than
if (VersionCompare("8.1", "10") = 2)
Code: Select all
MsgBox, % pad("8.1") < pad("10")
pad(ver) {
str := RegExReplace(ver, "(?<=\.)\d(?=\.|$)", "0$0")
Return RegExReplace(str, "(?<!^\d)(?<!^\d\d)\.")
}
no i dont think so.. but i just realized that there is no way for the function to know how many digits to pad.. how many 0's to pre-pend at the start. probably best to just stick with my existing functeadrinker wrote: ↑08 Nov 2019, 16:11@guest3456Like this?Code: Select all
MsgBox, % pad("8.1") < pad("10") pad(ver) { str := RegExReplace(ver, "(?<=\.)\d(?=\.|$)", "0$0") Return RegExReplace(str, "(?<!^\d)(?<!^\d\d)\.") }
You could pad with an excess number of zeroes:
Code: Select all
MsgBox, % pad("1.1.31.9") < pad("1.1.31.0123")
pad(ver) {
Loop, parse, ver, .
str .= (str = "" ? "" : ".") . Format("{:010}", A_LoopField)
Return str
}
nice yeah that looks like it would work. everything is 10 digits long and so string comparison would workteadrinker wrote: ↑08 Nov 2019, 20:17You could pad with an excess number of zeroes:Code: Select all
MsgBox, % pad("1.1.31.9") < pad("1.1.31.0123") pad(ver) { Loop, parse, ver, . str .= (str = "" ? "" : ".") . Format("{:010}", A_LoopField) Return str }
Code: Select all
MsgBox, % pad("1.0") = pad("1.0.0")
pad(ver) {
arr := StrSplit(ver, ".")
Loop 4
(arr[A_Index] = "" && arr[A_Index] := 0)
Return Format("{:010}.{:010}.{:010}.{:010}", arr*)
}
Users browsing this forum: Araphen, Oblomov228, uchihito and 167 guests