Blue_Drache Posted January 24, 2005 Share Posted January 24, 2005 (edited) ;~ $location = StringMid(ClipGet(), "CURRENT", 53) ; Actual code is above. Examples of line in clipboard follows. ; ; CURRENT 08 000 01/24/05 000 12345 205205H 00012345678901 ; CURRENT 00 000 01/15/05 000 B12345 205205H 00012345678901 $location = "CURRENT 08 000 01/24/05 000 12345 205205H 00012345678901" $location = StringSplit($location," ") Dim $count = 0, $q = 0 Dim $newlocation[$location[0]] For $q = 1 to $location[0] step 1 If not $location[$q] = "" Then $count = $count + 1 $newlocation[$count] = $location[$q] $newlocation[0] = $count EndIf Next ;~For $test = 1 to $newlocation[0] ;~MsgBox(0, $test , $newlocation[$test] & " " & $count) ;~Next ;~Exit If StringLeft($newlocation[$count], 3) = "205" Or StringLeft($newlocation[$count], 3) = "204" Then ; Or StringLeft($location2, 3) = "205" Or StringLeft($location2, 3) = "204" Then MsgBox(0, "", "Found unit!") Else MsgBox(0, "error", "oops") EndIf Ok, as you can see, I'm splitting the line with the space as the delimiter. The problem is, it is only returning numbers or the areas that start with numbers, not full strings or areas that start with an alpha character. To complicate matters, everything but the field 205205H will contain random data. And even that field can be "2052050", "2052052", or "2042040". Fields 1 2 3 4 and 7 are numeric. Field 3 is always a date Fields 5 and 6 are alpha+numeric. I don't scrape field 7 from the screen, I truncate shortly after field 6 ends. In theroy, it should return 6 fields after the word "CURRENT". In practice it's returning 3 or 4 fields. No big problem, because I always want the LAST field to be checked later on in my program and it works as it stands, but I am wondering what am I missing? Will this break at some later point? I also may want to look for alpha values at some point later on. Will I need to pre-initialize the array to hold some string value (i.e. the letter "a"), or use StringFormat() to force them into string containers not numeric or is that just for C++? Edited January 24, 2005 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
phillip123adams Posted January 24, 2005 Share Posted January 24, 2005 The problem is, it is only returning numbers or the areas that start with numbers, not full strings or areas that start with an alpha character. The problem is because StringSplit is not working the way you are thinking it should work (because of consecutive spaces). Try the following which correctly splits each of the 8 fields into the $location variable with no need for $newlocation.$location = "CURRENT 08 000 01/24/05 000 a12345 205205H 00012345678901" $location = StringSplit(StringStripWS($location, 4)," ") MsgBox(4096, $location[0], $location[1] & @lf & $location[2] & @lf & $location[3] & @lf & $location[4] & @lf & $location[5] & @lf & $location[6] & @lf & $location[7] & @lf & $location[8]) Phillip Link to comment Share on other sites More sharing options...
Blue_Drache Posted January 24, 2005 Author Share Posted January 24, 2005 The problem is because StringSplit is not working the way you are thinking it should work (because of consecutive spaces). Try the following which correctly splits each of the 8 fields into the $location variable with no need for $newlocation.$location = "CURRENT 08 000 01/24/05 000 a12345 205205H 00012345678901" $location = StringSplit(StringStripWS($location, 4)," ") MsgBox(4096, $location[0], $location[1] & @lf & $location[2] & @lf & $location[3] & @lf & $location[4] & @lf & $location[5] & @lf & $location[6] & @lf & $location[7] & @lf & $location[8])<{POST_SNAPBACK}>*smacks forehead* StringStripWS....oy vey..... OK, thanks! I'm just used to using the stripper with flag 8. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
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