Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
279 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 1400 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

610 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