From: Peter on 7 May 2010 09:51 Hello I've got a config file for doing different types of builds, and I was wondering how I parse it with a VB script. The file configfile.txt is in the format [BUILDTYPE1] swmodule1=123-4567 swmodule2=123-4568 swmodule3=123-4569 swmodule4=123-4570 [BUILDTYPE2] swmodule1=125-4567 swmodule2=125-4568 swmodule3=125-4569 swmodule4=125-4570 So the thought is if I'm doing a build of BUILDTYPE2 how do I get just that section and the part numbers of the individual modules with in it?
From: Pegasus [MVP] on 7 May 2010 12:02 "Peter" <noMorespam(a)MSUK.com> wrote in message news:ee3Byxe7KHA.1424(a)TK2MSFTNGP04.phx.gbl... > Hello > > I've got a config file for doing different types of builds, and I was > wondering how I parse it with a VB script. > > The file configfile.txt is in the format > > [BUILDTYPE1] > swmodule1=123-4567 > swmodule2=123-4568 > swmodule3=123-4569 > swmodule4=123-4570 > > [BUILDTYPE2] > swmodule1=125-4567 > swmodule2=125-4568 > swmodule3=125-4569 > swmodule4=125-4570 > > So the thought is if I'm doing a build of BUILDTYPE2 how do I get just > that section and the part numbers of the individual modules with in it? > Perhaps a simple solution like the one below will do the trick. Note that it employs no error checking. sConfig = "d:\temp\test.txt" sBuild = "[BUILDTYPE2]" Set oFSO = CreateObject("Scripting.FileSystemObject") aConfig = Split(oFSO.OpenTextFile(sConfig).ReadAll, VbCrLf) For i = 0 To UBound(aConfig) If aConfig(i) = sBuild Then For j = 1 To 4 WScript.Echo Split(aConfig(i+j), "=")(1) Next Exit For End If Next
From: Mayayana on 7 May 2010 14:33 You can use string manipulation functions. The file is just a string. Another option is here: http://www.jsware.net/jsware/scripts.php5#classpk There's an INI class in the download. You paste the class into your script and use it as an object. It encapsulates full INI functionality for convenience. | | I've got a config file for doing different types of builds, and I was | wondering how I parse it with a VB script. | | The file configfile.txt is in the format | | [BUILDTYPE1] | swmodule1=123-4567 | swmodule2=123-4568 | swmodule3=123-4569 | swmodule4=123-4570 | | [BUILDTYPE2] | swmodule1=125-4567 | swmodule2=125-4568 | swmodule3=125-4569 | swmodule4=125-4570 | | So the thought is if I'm doing a build of BUILDTYPE2 how do I get just that | section and the part numbers of the individual modules with in it? | | |
|
Pages: 1 Prev: Using Multidimensional Array Next: VBscript problem with Windows 7 |