dist_tools/
mg_cmp_version.pro
Routines
top mg_cmp_version
result = mg_cmp_version(version1, version2)
Compares two version numbers for the more updated number. Returns 0
for
equal versions, 1
if version1
is later than version2
, and -1 if
version1
is earlier than version2
. Strings such as 'alpha' and 'beta'
may be tacked on to the end of a version, but are compared alphabetically.
Return value
-1, 0, or 1
Parameters
- version1 in required type=string
first version number
- version2 in required type=string
second version number
Examples
For example, 1.2 is later than 1.1.2:
IDL> print, mg_cmp_version('1.2', '1.1.2')
1
IDL> print, mg_cmp_version('1.2', '1.3')
-1
IDL> print, mg_cmp_version('1.2', '1.2')
0
IDL> .run mg_cmp_version
1.2 1.1.2 1.1 1.1alpha 1.1beta
1.2 > 0 1 1 1 1
1.1.2 > -1 0 1 1 1
1.1 > -1 -1 0 1 1
1.1alpha > -1 -1 -1 0 -1
1.1beta > -1 -1 -1 1 0
File attributes
Modification date: | Wed May 14 15:07:14 2014 |
Lines: | 40 |
Docformat: | rst rst |
Contact me if you have enhancement requests or bug fixes.