![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | Problem using split function Hi, When I use the split function to get data from a txt file, it always skip lines that begins with text in the second part. Lines in the txt file looks like this : Server1;tata,123,always;PROD Server2;456,never;PROD Server3;tata,789,always;TEST Here is the code I use to get the data : set objFile = CreateObject("Scripting.FileSystemObject") set TheFile = objFile.GetFile(srcFile) set objServer = objFile.OpenTextFile(TheFile, ForReading, true) strSearching = objServer.ReadLine VarArray = Split(strSearching, ";", -1, 1) I don't know why but it always skip the lines that the second part of the split begins with "tata". Thank you. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Problem using split function Your code sample seems to be incomplete. You only show reading one line. Since the Split function does not block the word "tata", the problem must be in a part of the code that you didn't post. Quote: > When I use the split function to get data from a txt file, it always skip > lines that begins with text in the second part. Lines in the txt file Quote: > like this : > > Server1;tata,123,always;PROD > Server2;456,never;PROD > Server3;tata,789,always;TEST > > Here is the code I use to get the data : Quote: > set objFile = CreateObject("Scripting.FileSystemObject") > set TheFile = objFile.GetFile(srcFile) > set objServer = objFile.OpenTextFile(TheFile, ForReading, true) > > strSearching = objServer.ReadLine > VarArray = Split(strSearching, ";", -1, 1) > > I don't know why but it always skip the lines that the second part of the > split begins with "tata". > > Thank you. > > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Problem using split function "Meat" <Meat@xxxxxx> wrote in message news:CAD384B3-4413-41CA-A8E4-788E0AC66D37@xxxxxx Quote: > Hi, > > When I use the split function to get data from a txt file, it always skip > lines that begins with text in the second part. Lines in the txt file > looks > like this : > > Server1;tata,123,always;PROD > Server2;456,never;PROD > Server3;tata,789,always;TEST > > Here is the code I use to get the data : > > set objFile = CreateObject("Scripting.FileSystemObject") > set TheFile = objFile.GetFile(srcFile) > set objServer = objFile.OpenTextFile(TheFile, ForReading, true) > > strSearching = objServer.ReadLine > VarArray = Split(strSearching, ";", -1, 1) > > I don't know why but it always skip the lines that the second part of the > split begins with "tata". > > Thank you. post the exact code that causes you a problem. Using your data lines, I ran this slightly modified version without any problems: srcfile="d:\temp\test.txt" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objServer = objFSO.OpenTextFile(srcFile, 1, True) While Not objServer.AtEndOfStream strSearching = objServer.ReadLine WScript.echo "Source=" & strSearching VarArray = Split(strSearching, ";") strLine = "" For i = 0 To UBound(VarArray) strLine = strLine & VarArray(i) & "/" Next WScript.echo "Target=" & strLine Wend |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| VBscript Array Split Function | VB Script | |||
| Keyboard second function problem | Vista hardware & devices | |||
| Split function | PowerShell | |||
| Vista Update Causing Split-Screen Problem | Vista hardware & devices | |||
| Perl split function equivalent | PowerShell | |||