![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How to read text file 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. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How to read text file "henrique" <qwqwq@xxxxxx> wrote in message news:94C154D2-0BBC-41AD-B89E-043BCA49CE75@xxxxxx 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. CRLF = Chr(13) & Chr(10) sFileName = "d:\temp\test.txt" Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFile = oFSO.OpenTextFile(sFileName) aFileArray = Split(oFile.ReadAll, CRLF) |
My System Specs![]() |
| | #3 (permalink) |
| | Re: How to read text file Hi Thankyou for the replay but dont work fine. CRLF = Chr(13) & Chr(10) sFileName = "c:\testes\teste.ual" Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFile = oFSO.OpenTextFile(sFileName) aFileArray = Split(oFile.ReadAll, CRLF) Text1.Text = aFileArray(0) Text2.Text = UBound(aFileArray) The Text1 display "ÿþ2" The Text2 display "0" When I open "c:\testes\teste.ual" With NotePad" display exactli 23-09-2008 14:23: Alarme de teste Medium Alarm 23-09-2008 14:23: Alarme de teste Automatically Acknowledged 23-09-2008 14:23: Alarme de teste Cleared 23-09-2008 14:23: Alarme de teste Medium Alarm 23-09-2008 14:23: Alarme de teste Automatically Acknowledged 23-09-2008 14:23: Alarme de teste Cleared 23-09-2008 14:23: Alarme de teste Medium Alarm 23-09-2008 14:23: Alarme de teste Automatically Acknowledged 23-09-2008 14:23: Alarme de teste Cleared 23-09-2008 14:23: Alarme de teste Medium Alarm 23-09-2008 14:23: Alarme de teste Automatically Acknowledged 23-09-2008 14:23: Alarme de teste Cleared "Pegasus (MVP)" <I.can@xxxxxx> escreveu na mensagem news:u1H259lHJHA.4408@xxxxxx Quote: > > "henrique" <qwqwq@xxxxxx> wrote in message > news:94C154D2-0BBC-41AD-B89E-043BCA49CE75@xxxxxx 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. > There are a few ways to do this. Here is one of them: > CRLF = Chr(13) & Chr(10) > sFileName = "d:\temp\test.txt" > Set oFSO = CreateObject("Scripting.FileSystemObject") > Set oFile = oFSO.OpenTextFile(sFileName) > aFileArray = Split(oFile.ReadAll, CRLF) > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: How to read text file "teste" <wq@xxxxxx> wrote in message news:newscache$4rmp7k$az$1@xxxxxx Quote: > Hi > Thankyou for the replay but dont work fine. > > > CRLF = Chr(13) & Chr(10) > sFileName = "c:\testes\teste.ual" > Set oFSO = CreateObject("Scripting.FileSystemObject") > Set oFile = oFSO.OpenTextFile(sFileName) > aFileArray = Split(oFile.ReadAll, CRLF) > > Text1.Text = aFileArray(0) > > Text2.Text = UBound(aFileArray) > > The Text1 display "ÿþ2" > > The Text2 display "0" > > When I open "c:\testes\teste.ual" With NotePad" display exactli > > 23-09-2008 14:23: Alarme de teste Medium > Alarm > 23-09-2008 14:23: Alarme de teste Automatically Acknowledged > 23-09-2008 14:23: Alarme de teste Cleared > 23-09-2008 14:23: Alarme de teste Medium > Alarm > 23-09-2008 14:23: Alarme de teste Automatically Acknowledged > 23-09-2008 14:23: Alarme de teste Cleared > 23-09-2008 14:23: Alarme de teste Medium > Alarm > 23-09-2008 14:23: Alarme de teste Automatically Acknowledged > 23-09-2008 14:23: Alarme de teste Cleared > 23-09-2008 14:23: Alarme de teste Medium > Alarm > 23-09-2008 14:23: Alarme de teste Automatically Acknowledged > 23-09-2008 14:23: Alarme de teste Cleared file. Check the help file "script56.chm" (downloadable from the Microsoft site) for the full syntax of the OpenTextFile method and how to specify that the file should be opened in Unicode format. |
My System Specs![]() |
| | #5 (permalink) |
| | 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. 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 Specs![]() |
| | #6 (permalink) |
| | Re: How to read text file Ok. But with this code and in VB Work fine FileNumber = FreeFile Open "c:\testes\teste.ual" For Input As #1 Do While Not EOF(FileNumber) Line Input #FileNumber, DF List1.AddItem DF Loop This VB code open in ASCII code!? H.S "Pegasus (MVP)" <I.can@xxxxxx> escreveu na mensagem news:ef1eB%23mHJHA.788@xxxxxx Quote: > > "teste" <wq@xxxxxx> wrote in message > news:newscache$4rmp7k$az$1@xxxxxx Quote: >> Hi >> Thankyou for the replay but dont work fine. >> >> >> CRLF = Chr(13) & Chr(10) >> sFileName = "c:\testes\teste.ual" >> Set oFSO = CreateObject("Scripting.FileSystemObject") >> Set oFile = oFSO.OpenTextFile(sFileName) >> aFileArray = Split(oFile.ReadAll, CRLF) >> >> Text1.Text = aFileArray(0) >> >> Text2.Text = UBound(aFileArray) >> >> The Text1 display "ÿþ2" >> >> The Text2 display "0" >> >> When I open "c:\testes\teste.ual" With NotePad" display exactli >> >> 23-09-2008 14:23: Alarme de teste Medium Alarm >> 23-09-2008 14:23: Alarme de teste Automatically Acknowledged >> 23-09-2008 14:23: Alarme de teste Cleared >> 23-09-2008 14:23: Alarme de teste Medium Alarm >> 23-09-2008 14:23: Alarme de teste Automatically Acknowledged >> 23-09-2008 14:23: Alarme de teste Cleared >> 23-09-2008 14:23: Alarme de teste Medium Alarm >> 23-09-2008 14:23: Alarme de teste Automatically Acknowledged >> 23-09-2008 14:23: Alarme de teste Cleared >> 23-09-2008 14:23: Alarme de teste Medium Alarm >> 23-09-2008 14:23: Alarme de teste Automatically Acknowledged >> 23-09-2008 14:23: Alarme de teste Cleared > This is probably because your text file is not an ASCII file but a Unicode > file. Check the help file "script56.chm" (downloadable from the Microsoft > site) for the full syntax of the OpenTextFile method and how to specify > that the file should be opened in Unicode format. > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: How to read text file "Henrique" <wq@xxxxxx> wrote in message news:newscache$qgqp7k$cb3$1@xxxxxx Quote: > Ok. > > But with this code and in VB Work fine > > FileNumber = FreeFile > Open "c:\testes\teste.ual" For Input As #1 > > > Do While Not EOF(FileNumber) > Line Input #FileNumber, DF > > List1.AddItem DF > > Loop > > This VB code open in ASCII code!? > > > H.S |
My System Specs![]() |
| | #8 (permalink) |
| | Re: How to read text file No! No! Not is the solution! This alternatif code work fine in VisualBasic, but dont work in VBScript! I´m findins un solution. Thanks "Pegasus (MVP)" <I.can@xxxxxx> escreveu na mensagem news:u5jxNcnHJHA.3668@xxxxxx Quote: > > "Henrique" <wq@xxxxxx> wrote in message > news:newscache$qgqp7k$cb3$1@xxxxxx Quote: >> Ok. >> >> But with this code and in VB Work fine >> >> FileNumber = FreeFile >> Open "c:\testes\teste.ual" For Input As #1 >> >> >> Do While Not EOF(FileNumber) >> Line Input #FileNumber, DF >> >> List1.AddItem DF >> >> Loop >> >> This VB code open in ASCII code!? >> >> >> H.S > Glad to see that you found an alternative solution. > |
My System Specs![]() |
| | #9 (permalink) |
| | Re: How to read text file "Henrique" <wq@xxxxxx> wrote in message news:newscache$8xsp7k$7x4$1@xxxxxx Quote: > No! No! > > Not is the solution! > > This alternatif code work fine in VisualBasic, but dont work in VBScript! > > I´m findins un solution. > > Thanks Enjoy! |
My System Specs![]() |
| | #10 (permalink) |
| | Re: How to read text file Hi! Ok. I have two solutions but dont work in my VBScript project. If the text file is in Unicode, the NotePad open it without problems? I´m using un SCADA software, with VBScript and Im testing the script in VB6. Sory my English Thanks "Pegasus (MVP)" <I.can@xxxxxx> escreveu na mensagem news:OLxAk6nHJHA.4760@xxxxxx Quote: > > "Henrique" <wq@xxxxxx> wrote in message > news:newscache$8xsp7k$7x4$1@xxxxxx Quote: >> No! No! >> >> Not is the solution! >> >> This alternatif code work fine in VisualBasic, but dont work in VBScript! >> >> I´m findins un solution. >> >> Thanks > You now have two working solutions: One from Tom Lavedas and one from me. > Enjoy! > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Read a line from a text file, without loading the entire file inmemory | PowerShell | |||
| How to read and write a text file? | VB Script | |||
| Read a huge text file from bottom up | PowerShell | |||
| How do I read a text file and sort text by fixed positions? | PowerShell | |||
| Using ADO to read a text file | PowerShell | |||