Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using a dynamic array

Status
Not open for further replies.

chriscj21

Technical User
Mar 27, 2004
246
GB
Guys:

Hope someone can help - sure this is fairly obvious to an experience scripter but can someone please explain why my code will not compile:

______________________________________


Dim objFso, objFile, returnString, arrError, i

Const FOR_READING = 1
Set objFso = WScript.CreateObject("Scripting.FilesystemObject")


If objFso.FileExists ("C:\windows\setuplog.txt") Then

Set objFile = objFso_OpenTextFile("C:\windows\setuplog.txt", FOR_READING)


Do While objFile.AtEndOfStream <> True

returnString = objFile.ReadLine

If InStr (returnString, "Error") Then

For i = 0 To UBound(arrError)

arrError(i) = returnString

Wscript.echo returnstring

ReDim preserve arrError(i)

i = i + 1

Next

End If

Loop


End If



ChrisCj21
MCSE, A+, N+
 
you havent intilised arrError at the start of the script

tery something like

Dim arrError()

or

Dim arrError(1)
 
Thanks for getting back to me - have tried this also to no avail :(


chris


ChrisCj21
MCSE, A+, N+
 
Fixed it!!!
________________________________________________


Set objFso = WScript.CreateObject("Scripting.FilesystemObject")


If objFso.FileExists ("C:\windows\setuplog.txt") Then

Set objFile = objFso_OpenTextFile("C:\windows\setuplog.txt", FOR_READING)


Do While objFile.AtEndOfStream <> True
i = 0
returnString = objFile.ReadLine

If InStr(returnString, "error") Then


ReDim Preserve arrError(i)

arrError(i) = returnString

WScript.Echo (arrError(i))

End If

i = i + 1

Loop

End If



ChrisCj21
MCSE, A+, N+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top