Re: Comparing version strings
Re: Comparing version strings
- Subject: Re: Comparing version strings
- From: "Mark J. Reed" <email@hidden>
- Date: Thu, 11 Dec 2008 10:58:29 -0500
set v12 to "1.2"
set v125 to "1.2.5"
set v127 to "1.2.7"
set v13 to "1.3"
set match to v125 > v12 (* returns true *)
log match
set match to v127 > v125 (* returns true *)
log match
set match to v13 > v127 (* returns true *)
log match
set v1_10 to "1.10"
set match to v1_10 > v13 (* returns false *)
log match
Try this:
to compareVersions(v1, v2)
set oldTID to AppleScript's text item delimiters
set text item delimiters to "."
set l1 to text items of v1
set l2 to text items of v2
set AppleScript's text item deilmiters to oldTID
repeat with i from 1 to count(l1)
set n1 to item i of l1 as integer
set n2 to item i of l2 as integer
if n1 < n2 then
return -1
else if n1 > n2 then
return 1
end if
end repeat
return 0
end compareVersions
--
Mark J. Reed <
email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden