Solved

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

Posted on 2013-12-29
3
269 Views
Last Modified: 2013-12-29
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.
0
Comment
Question by:josephh610
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Expert Comment

by:John Easton
ID: 39745147
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).
0
 

Author Comment

by:josephh610
ID: 39745159
Cool that works, how do i assign it to a variable that I can now use externally?
0
 
LVL 11

Accepted Solution

by:
John Easton earned 350 total points
ID: 39745168
On line 2, replace WScript.Echo with 'variablename = '

E.g.
VersionArr = Split(Wscript.Arguments.Item(0),".")
versionpart = VersionArr(Wscript.Arguments.Item(1)-1)

Open in new window


You can then use that variable as you please.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question