AppleScript名:バージョン番号文字列からメジャーバージョンを取り出し数値として返す v4 |
use AppleScript version "2.5" use scripting additions use framework "Foundation" set a to "10.0.1" set b to retMajorVersionNumber(a) of me –> 10 set a to "9.10" set b to retMajorVersionNumber(a) of me –> 9 –バージョン番号文字列からメジャーバージョンを取り出し数値として返す on retMajorVersionNumber(a) set aStr to current application’s NSString’s stringWithString:a –> "10.0.1" (NSString) set aRes to (aStr’s componentsSeparatedByString:".") –> {"10","0","1"} (NSArray) set bRes to aRes’s firstObject() –> "10" (NSString) set cRes to bRes’s integerValue() –> 10 return cRes as integer end retMajorVersionNumber |
More from my site
(Visited 21 times, 1 visits today)