Link to home
Start Free TrialLog in
Avatar of josephh610
josephh610

asked on

How do I read in a version text string and extract each integer into a variable using batch file or vb.

How do I read in a version text string and extract each integer into a variable using batch file along with the position.
example: 3.2.13.0, 3
Need to return 13

If i pass in the version number and the position i get the integer at that position.
Avatar of John Easton
John Easton
Flag of United Kingdom of Great Britain and Northern Ireland image

If using VBS then the following code will do what you want:

VersionArr = Split(Wscript.Arguments.Item(0),".")
WScript.Echo VersionArr(Wscript.Arguments.Item(1)-1)

Open in new window


However, you do not need the comma to separate the arguments.

Therefore:  3.2.13.0 3
Will return 13.  (i.e. only a space, no comma).
Avatar of josephh610
josephh610

ASKER

Cool that works, how do i assign it to a variable that I can now use externally?
ASKER CERTIFIED SOLUTION
Avatar of John Easton
John Easton
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial