senator Posted February 7, 2009 Share Posted February 7, 2009 Hey all! So I have a .txt file and I want autoit to load the textfile and remove all the spaces and [tab] spaces (the long spaces). Thanks in advance Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 7, 2009 Moderators Share Posted February 7, 2009 senator,Look at StringStripWS in the Help file.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...
senator Posted February 7, 2009 Author Share Posted February 7, 2009 I can't seem to get it to work. Here's how my 'string' looks like: text text text text text text text ..and so on.. And this line is supposed to write the string to a .txt file FileWriteLine($path,StringStripCR($thestring)) The problem is it writes it without removing the spaces. Link to comment Share on other sites More sharing options...
cageman Posted February 7, 2009 Share Posted February 7, 2009 FileWriteLine($path,StringStripWS(StringStripCR($thestring))) That should clear everything. Then you get texttexttexttext etc. Link to comment Share on other sites More sharing options...
senator Posted February 7, 2009 Author Share Posted February 7, 2009 (edited) Thanks, before i try it out, is there any way to get it to "text,text,text,text" instead "texttexttext" ? Actually I'm sure there is a way lol Edited February 7, 2009 by senator Link to comment Share on other sites More sharing options...
FireFox Posted February 7, 2009 Share Posted February 7, 2009 (edited) @senator StringReplace('texttexttext', 'tt', 't,t') Cheers, FireFox. Edited February 7, 2009 by FireFox Link to comment Share on other sites More sharing options...
senator Posted February 7, 2009 Author Share Posted February 7, 2009 1. StringStripWS(StringStripCR($users) is not good, it needs a flag. What should i put there. 2. FireFox, that would only work if my string was full of "text"s. Its more like "text, somethingelse,anotherword..." Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 7, 2009 Moderators Share Posted February 7, 2009 senator, Get your text into an array - _FileReadToArray will do this for you. Then loop through the array:; Just to have a test array for this example $sString = "test " & @CRLF & @CRLF & "test " $aArray = StringSplit($sString, @CRLF) ; Start here if you use _FileReadToArray $sNewString = "" For $i = 1 To $aArray[0] If StringLen($aArray[$i]) > 0 Then $sNewString &= StringStripWS($aArray[$i], 8) & "," EndIf Next ConsoleWrite($sNewString & @CRLF)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...
senator Posted February 7, 2009 Author Share Posted February 7, 2009 haha, finally I've got it to work! Thanks very much to all of ya ! Link to comment Share on other sites More sharing options...
antoine Posted February 7, 2009 Share Posted February 7, 2009 Hi, I'm not certain but try something like StringReplace('texttexttext', @LF, '') followed by StringReplace('texttexttext', @LR, '') for each line of your file. regards, Antoine Link to comment Share on other sites More sharing options...
senator Posted February 7, 2009 Author Share Posted February 7, 2009 thanks for trying to help, but Melba23's method works perfectly. 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