lyonsksd Posted March 26, 2009 Share Posted March 26, 2009 Hi, I have been fighting with a script for a while now. It seems simple enough, but the problem that I am having has to do with finding a word in a clip board. I grab the text from a dos window, put it in the clip board, and then parse it for a certain word. However the word is occasionally wrapped onto a new line. I have googled for ideas on how to fix this as well as searched throughout the forum. Even help couldn't help me. DLOG,1,20090306,123340,0,17000138,1640,200,0,(1640.068) RX: #SERVINFO: 722,-77," T-Mobile","31026",70,0B9A,01,1,,"II",01,6; or DLOG,1,20090311,143108,0,72200035,260,200,0,(260.077) RX: #SERVINFO: 722,-82,"T- Mobile","31026",70,0B9A,02,1,,"II",01,6; I am not really interested in changing the dos window properties to be more than 80 characters wide, because I can't control where this script will be used. To check, copy the first DLOG line to the clip board and then run script. The first one will work. The second DLOG line will fail. This is what I have right now. CODE$String = ClipGet() ;store the cmd dump from clipboard into variable. $Capture = StringRegExpReplace($String, '([][{}()|.?+*\\^])', '\\\1') ;get rid of all special characters $result = StringInStr($Capture, "RX: #SERVINFO") ;find the start of the info needed. $result6 = StringTrimLeft($capture, $result + 25) ;add to the count found to get to the string needed $Result7 = StringStripCR($result6 & Chr(13) & Chr(10)) ;remove all carriage returns and line feeds $Result8 = Stringleft($result7, 8) ;only take the left 8 characters $Result9 = StringCompare($Result8, "T-Mobile") ;compare the results to the expected value If $Result9 = 0 Then $GSMCARRIER = $Result8 MsgBox(0, "", "'" & $GSMCARRIER & "'" & " was was the carrier detected.") Else MsgBox(0, "", "The carrier was not detected. Continue test but mark board") Endif I also tried it this way. CODE$String = ClipGet() ;store the cmd dump from clipboard into variable. $Capture = StringRegExpReplace($String, '([][{}()|.?+*\\^])', '\\\1') ;get rid of all special characters $result = StringInStr($Capture, "RX: #SERVINFO") ;find the start of the info needed. $result6 = StringTrimLeft($capture, $result + 23) $Result7 = StringStripCR($result6 & Chr(13) & Chr(10)) $Result8 = Stringleft($result7, 9) $Trythis = StringStripWS($Result8, 8) $Result9 = StringCompare($Trythis, "T-Mobile") If $Result9 = 0 Then $GSMCARRIER = $Result8 MsgBox(0, "", "'" & $GSMCARRIER & "'" & " was was the carrier detected.") Else MsgBox(0, "", "The carrier was not detected. Continue test but mark board") Endif In this method, it does see the word T-Mobile, but prints it out on two lines. Is there any way to make the "word wrapped" capture lines to be only one line so I can parse it correctly? Thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 26, 2009 Moderators Share Posted March 26, 2009 lyonsksd,Use StringReplace to get rid of any @CRLF and then use StringSplit on the quotation marks. The following works for me using both strings and also returns "not found" for anything without quotation marks:$sString = ClipGet() ;store the cmd dump from clipboard into variable. $sString = StringReplace($sString, @CRLF, "") $aResult = Stringsplit($sString, '"') If $aResult[0] > 1 Then MsgBox(0, "", "'" & $aResult[2] & "'" & " was was the carrier detected.") Else MsgBox(0, "", "The carrier was not detected. Continue test but mark board") EndIfI hope this is what you wanted.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
lyonsksd Posted March 26, 2009 Author Share Posted March 26, 2009 lyonsksd, Use StringReplace to get rid of any @CRLF and then use StringSplit on the quotation marks. The following works for me using both strings and also returns "not found" for anything without quotation marks:$sString = ClipGet() ;store the cmd dump from clipboard into variable. $sString = StringReplace($sString, @CRLF, "") $aResult = Stringsplit($sString, '"') If $aResult[0] > 1 Then MsgBox(0, "", "'" & $aResult[2] & "'" & " was was the carrier detected.") Else MsgBox(0, "", "The carrier was not detected. Continue test but mark board") EndIf I hope this is what you wanted. M23 Works great. I didn't think of trying the StringReplace. I thought that the StringStripCR would have taken care of that. Thanks 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