Clay Posted April 11, 2008 Posted April 11, 2008 I am using the StringSplit funtion and I am encounting issues with the result and would like some direction. The funtion is simple, read each line of a file and then split the line by @CRLF - that is a space .... I also tried " ". The funtion looks ok however in Array[1] I get the full line and when I try to output in Array[2] an exception is thrown. Does anyone know what I should use to represent a SPACE other than @CRLF or "". This is a sample of the text file TT_Sample 7.3 X_Sample 7.2 TT_Sample 7.8 X_Sample 7.5 This is the Funtion Dim $ProductArrayList Dim $ArrayCount = 0 Dim $XAxis = 0 Dim $YAxis = 0 $filecompare = FileOpen("read.txt", 0) ; **********************************************Check if Compare file opened for reading OK If $filecompare = -1 Then MsgBox(0, "Error", "Unable to open Exclusion File, please verify that file exists.") Exit EndIf While 1 $line = FileReadLine($filecompare) $ProductArrayList = StringSplit($line, @CRLF, 1) If @error = -1 Then ExitLoop MsgBox(0,"DevCentral Result equals: ", $ProductArrayList[1]) MsgBox(0,"DevCentral Result equals: ", $ProductArrayList[2]) Wend The output should be $ProductArrayList[1]) = TT_Sample $ProductArrayList[2] = 7.3 ...etc Any ideas ?
PsaltyDS Posted April 11, 2008 Posted April 11, 2008 Look in the help file at the "flag" parameter: [optional] If flag is 0 (the default), then each character in the delimiter string will mark where to split the string. If flag is 1, then the entire delimiter string is needed to mark the split. By default each character is a delimiter, so if you use @CRLF & " ", you actually get three delimiters: @CR, @LF, and {SPACE}. Having said all that, there won't be any @CRLF in the line with your code because $line came from FileReadLine(), so it's just a single line to begin with. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now