31290 Posted October 11, 2015 Posted October 11, 2015 Hi Everyone, I'm facing a small issue while trying to remove spaces at the end of lines contained in a temp file.Indeed, I'm creating the list of uninstallable apps on my computer and display them in an edit box.Here's the result:As you can see, all lines have bunch of spaces at their end.I did try the StringStripWS function, the StringTrimLeft one... no one works... Here's the code I use:Func f_ListApps() GuiCtrlSetState ($g_AppList, $GUI_DISABLE) RunWait(@ComSpec & ' /c ' & 'wmic /node:' & @Computername &' product get name > %temp%\model.txt' ,"", @SW_HIDE) $file =(@TempDir & "/model.txt") $fileread = FileRead($file) GUICtrlCreateEdit($fileread, 5, 250, 395, 400) FileDelete(@TempDir & "/model.txt") EndFuncSurely a dumbass question but few hairs remains on my head Thanks ~~~ Doom Shall Never Die, Only The Players ~~~
water Posted October 11, 2015 Posted October 11, 2015 How did you use StringStripWS? This function should be exactly what you are looking for. 31290 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
31290 Posted October 11, 2015 Author Posted October 11, 2015 Water Indeed, this function will do the trick...I tried:$fileread= FileRead($file) $filefile = StringStripWS ( $fileread, 2 )And$filefile = StringStripWS (ChrW(160) & $fileread & ChrW(160), 2 )No successes :/ ~~~ Doom Shall Never Die, Only The Players ~~~
water Posted October 11, 2015 Posted October 11, 2015 You are reading the whole file into one variable. Using StringStripWS on this variable will only remove white space from the last line.Means:Use FileReadToArray to read the file into an array, then loop through the array and use StringStripWS on every element. 31290 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
31290 Posted October 11, 2015 Author Posted October 11, 2015 (edited) Yuk, I don't like arrays Ok, I'll try that and give you an update.Thanks water! Edited October 11, 2015 by 31290 ~~~ Doom Shall Never Die, Only The Players ~~~
water Posted October 11, 2015 Posted October 11, 2015 It's not too complex:#include <StringConstants.au3> $aFileArray = FileReadToArray($file) For $i = 0 To UBound($aFileArray, 1) - 1 $aFileArray[$i] = StringStripWs($aFileArray[$i], $STR_STRIPTRAILING) Next My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
31290 Posted October 11, 2015 Author Posted October 11, 2015 Ok, I understand the way and thanks for that.But, when I display my edit box, I got a subscript error Global $editBox = GUICtrlCreateEdit($aFileArray[$i], 5, 250, 395, 400) ~~~ Doom Shall Never Die, Only The Players ~~~
JohnOne Posted October 11, 2015 Posted October 11, 2015 Probably nothing in your array.Test it first IsArray() AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
water Posted October 11, 2015 Posted October 11, 2015 You can't add an array to the edit control. Use:Global $editBox = GUICtrlCreateEdit(_ArrayToString($aFileArray[$i], @CRLF), 5, 250, 395, 400) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
31290 Posted October 11, 2015 Author Posted October 11, 2015 johnOne, Thanks for your input.Yes, the array exists and is not empty. ~~~ Doom Shall Never Die, Only The Players ~~~
31290 Posted October 11, 2015 Author Posted October 11, 2015 (edited) water, I still have a subscript error :/When displaying the array with _ArrayDisplay:The array is not empty ^^ Edited October 11, 2015 by 31290 ~~~ Doom Shall Never Die, Only The Players ~~~
water Posted October 11, 2015 Posted October 11, 2015 My bad, should be:Global $editBox = GUICtrlCreateEdit(_ArrayToString($aFileArray, @CRLF), 5, 250, 395, 400) 31290 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
31290 Posted October 11, 2015 Author Posted October 11, 2015 Yeah water, This is now working as expected. Was looking to deal with the @error flag when I saw your answer. Thanks a lot again ~~~ Doom Shall Never Die, Only The Players ~~~
water Posted October 11, 2015 Posted October 11, 2015 31290 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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