Reading in values from a text file using VBScript

Hi, I am having some logic issues here and wanted to post this to see what I need to do.  I have a text file I'm reading in, the format of the text file is as follows:

server=\\software
os=xp
model=d610

What I need to do is grab "\\software", "xp", & "d610" and put them in variables to be used later.  The script echos "\\software" so it's reading the text file just fine.  When I try to store the values in an arry, I'm getting a "Type Mismatch" error.  The loop is the part I'm having trouble with.  Here's my code, please help!  Thanks.  Need more info, let me know.

            Set FSO = CreateObject("Scripting.FileSystemObject")
            If FSO.FileExists("Z:\servers\" & SvcTagFile) Then
                Const ForReading = 1, ForWriting = 2, ForAppending = 8
                Set objFile = FSO.OpenTextFile("Z:\servers\" & SvcTagFile, ForReading)
                x = 0
                Do While Not objFile.AtEndOfStream
                    arrInfo = objFile.Readline
                    arrInfo = Split(arrInfo, "=")
                    strInfo = arrInfo(1)
                    MsgBox strInfo 'It echos "\\software" like it should
         arrInfoFinal(x) = strInfo 'This is where the error is at
                    x = x + 1
                Loop
             End If
mpenuelAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

omegaomegaDeveloperCommented:
Hello, mpenuel,

I've never used VBScript, but if it behaves a little like VB then you will need to declare arrInfoFinal as an array before using it as you are.  Perhaps you have already done this in code not shown in your post.  But if not, try inserting:

                 Dim arrInfoFinal(2) As String

before the start of the loop.  If there are more than 3 lines to parse then increase the upper bound of the array as required.  If you don't know the number of lines before reading the file, perhaps VBScript (like VB) has a "Redim Preserve" statement to allow you to increase the size dynamically.

Cheers,
Randy
0
everlaastCommented:
Solution1:
use:
Dim arrInfoFinal(2)
in the beginning of the script


Solution2:
use:
set arrInfoFinal=CreateObject("Scripting.Dictionary")
in the beginning of the script


find out more about dictionary object, it's a good replacement for array.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.