View Single Post
Old 09-24-2008   #5 (permalink)
Tom Lavedas
Guest


 
 

Re: How to read text file

On Sep 24, 11:36*am, "henrique" <qw...@xxxxxx> wrote:
Quote:

> Hi
>
> Is possible to help me to read a text file, line by line, and place it into
> an arry?
>
> code VBScript
>
> 'Text file opened with notepad
> 25-07-2008 20:34:35 I/OManager * * Alto * Routing error1 : Low
> 25-07-2008 20:34:36 I/OManager * * Alto * Routing error7 : Low
> 25-07-2008 20:34:36 I/OManager * * Alto * Routing error2 : Low
> 25-07-2008 20:34:36 I/OManager * * Alto * Routing error2 : Low
> 25-07-2008 20:34:36 I/OManager * * Alto * Routing error3 : Low
> 25-07-2008 20:34:38 I/OManager * * Alto * Routing error6 : Low
> 25-07-2008 20:34:40 I/OManager * * Alto * Routing error 8: Low
> 25-07-2008 20:34:42 I/OManager * * Alto * Routing error1 : Low
>
> Thank you in advance
>
> H.S.
Maybe something like this ...

with CreateObject("Scripting.FileSystemObject")
.OpenTextFile("c:\list.txt", 1, true)
aLines = Split(.ReadAll, vbNewline)
End with
for i = 0 to Ubound(aLines)
aData(i) = Split(alines(i), " ")
next

Then address the data items with this syntax ...

wsh.echo "For example:", aData(nLine)(nItem_on_the_line)

This is pretty basic stuff. See the WSH documentation:

WSH 5.6 documentation download (URL all one line)
http://www.microsoft.com/downloads/d...displaylang=en

and these samples"

TechNet Script Center Sample Scripts (URL all one line)
http://www.microsoft.com/downloads/d...a-b8814fe2da5a

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
My System SpecsSystem Spec