Searching the Help
To search for information in the Help, type a word or phrase in the Search box. When you enter a group of words, OR is inferred. You can use Boolean operators to refine your search.
Results returned are case insensitive. However, results ranking takes case into account and assigns higher scores to case matches. Therefore, a search for "cats" followed by a search for "Cats" would return the same number of Help topics, but the order in which the topics are listed would be different.
Search for | Example | Results |
---|---|---|
A single word | cat
|
Topics that contain the word "cat". You will also find its grammatical variations, such as "cats". |
A phrase. You can specify that the search results contain a specific phrase. |
"cat food" (quotation marks) |
Topics that contain the literal phrase "cat food" and all its grammatical variations. Without the quotation marks, the query is equivalent to specifying an OR operator, which finds topics with one of the individual words instead of the phrase. |
Search for | Operator | Example |
---|---|---|
Two or more words in the same topic |
|
|
Either word in a topic |
|
|
Topics that do not contain a specific word or phrase |
|
|
Topics that contain one string and do not contain another | ^ (caret) |
cat ^ mouse
|
A combination of search types | ( ) parentheses |
|
- List: JavaScript functions in the ScriptLibrary
- JavaScript function: addToGroup
- JavaScript function: checkAllowedOption
- JavaScript function: checkVersionString
- JavaScript function: isfileexist
- JavaScript function: isInGroup
- JavaScript function: removeFromGroup
- JavaScript function: returnGroupMembers
- JavaScript function: returnMyGroups
- JavaScript function: skipApproval
JavaScript function: checkVersionString
Validates a version string to ensure it adheres to Configuration Management baseline group version number requirements.
Syntax
lib.versionControl.checkVersionString( oldVersion, newVersion, maxIncrement );
Arguments
The following arguments are valid for this function:
Name | Data type | Required | Description |
---|---|---|---|
oldVersion
|
String | Yes | This argument contains the previous version number. |
newVersion
|
String | Yes | This argument contains the new version number. |
maxIncrement
|
Array | Yes | This argument contains an array of numbers representing the decimal value of the maximum number increments possible. For example, if maxIncrement equals [0,1,0] then there are ten possible increments permissible from versions 0.0.1 to 0.1.0. |
Return values
An integer value: 0
, 1
, -1
, -2
, -3
, or -4
.
Return value | Condition |
---|---|
0
|
The function returns 0 if any version level value in the newVersion argument exceeds the value in the maxIncrement argument. For example, if oldVersion equals "1.0". and maxIncrement equals "2", then the function returns a value of 0 if newVersion equals "1.3" since going from a value of zero to three exceeds the maxIncrement value of 2. |
1
|
The function returns 1 if it successfully validates the proposed change from the oldVersion to the newVersion . |
-1
|
The function returns -1 if the newVersion argument contains greater than five version levels. For example, the function returns -1 if the newVersion argument equals "1.0.0.0.0.0" as this is a version with six version levels. |
-2
|
The function returns -2 if a version level value in the newVersion argument contains anything other than the digits 0 to 9. For example the function returns -2 if the newVersion argument equals "gold" or "1.0a" because the version number contains alphabetical characters. |
-3
|
The function returns -3 if the number of version levels in the oldVersion argument do not match the number of version levels in the newVersion argument. For example, the function returns -3 if oldVersion equals "1.1" and newVersion equals "1.1.1" since the oldVersion has two version levels and the newVersion has three. |
-4
|
The function returns -4 if the value of the newVersion argument is less than the value of the oldVersion argument. For example, the function returns -4 if oldVersion equals "1.1" and newVersion equals "1.0" because the newVersion value is prior to the oldVersion value. |
Description
This function is part of a system JavaScript and should not be directly modified.
This function validates a new Configuration Management baseline group version string against an old version string to ensure it adheres to version number requirements.
Example
This example attempts to validate any given version number update from three variables.
This example requires the following sample data:
- A variable storing the old version number
- A variable storing the desired new version number
- A variable storing the maximum number of increments allowed
/* Use oldVersion to store the old version number as a string. * Use newVersion to store the new version number as a string. * Use maxIncrement to store the maximum number of increments as an array. */ var oldVersion; var newVersion; var maxIncrement = new Array(); /* Create a function to test the checkVersionString function */ function versionTest( versionOld, versionNew, increment ) { var validate = lib.versionControl.checkVersionString( versionOld, versionNew, increment ); print( "The checkVersionString return value is " + validate ); if ( validate == 1 ) { print( "Success. Updating " + versionOld + " to " + versionNew + " is a valid change.\n"); return versionNew } if ( validate == 0 ) { print( "Error. Could not update " + versionOld + " to " + versionNew + "." ); print( "The new version " + versionNew + " exceeds the maximum version increment value of " + increment + "." ); return versionOld } if ( validate == "-1" ) { print( "Error. Could not update " + versionOld + " to " + versionNew + "."); print( "The new version " + versionNew + " contains more than five version levels." ); return versionOld } if ( validate == "-2" ) { print( "Error. Could not update " + versionOld + " to " + versionNew + "."); print( "The new version " + versionNew + " contains characters other than 0 to 9." ); return versionOld } if ( validate == "-3" ) { print( "Error. Could not update " + versionOld + " to " + versionNew + "."); print( "The new version " + versionNew + " contains a different number of version levels than the old version " + versionOld ); return versionOld } if ( validate == "-4" ) { print( "Error. Could not update " + versionOld + " to " + versionNew + "."); print( "The new version " + versionNew + " is an earlier version than the old version " + versionOld ); return versionOld } else { return versionOld } } /* Test a valid version number update */ print( "Testing checkVersionString...\n" ); oldVersion = "1.0"; newVersion = "1.1"; maxIncrement = [0,2]; versionTest( oldVersion, newVersion, maxIncrement ); /* Test an invalid version number update */ print( "Testing error condition 0...\n" ); oldVersion = "1.0"; newVersion = "1.9"; maxIncrement = [0,2]; versionTest( oldVersion, newVersion, maxIncrement ); /* Test an invalid version number update */ print( "Testing error condition -1...\n" ); oldVersion = "1.0.0.0.0.0"; newVersion = "1.0.0.0.0.1"; maxIncrement = [0,0,1,1,2]; versionTest( oldVersion, newVersion, maxIncrement ); /* Test an invalid version number update */ print( "Testing error condition -2...\n" ); oldVersion = "1.0.0.0.0"; newVersion = "1.a.0.0.0"; maxIncrement = [0,0,1,1,2]; versionTest( oldVersion, newVersion, maxIncrement ); /* Test an invalid version number update */ print( "Testing error condition -3...\n" ); oldVersion = "1.0.0"; newVersion = "1.1"; maxIncrement = [0,2,2]; versionTest( oldVersion, newVersion, maxIncrement ); /* Test an invalid version number update */ print( "Testing error condition -4...\n" ); oldVersion = "1.2"; newVersion = "1.1"; maxIncrement = [0,2]; versionTest( oldVersion, newVersion, maxIncrement );