New topic: shell execute result not wrapping text in TextArea
<http://forums.realsoftware.com/viewtopic.php?t=46589> Page 1 of 1 [ 5 posts ] Previous topic | Next topic Author Message p0wn3d Post subject: shell execute result not wrapping text in TextAreaPosted: Thu Jan 17, 2013 8:56 am Joined: Sun Oct 28, 2012 4:54 am Posts: 80 Location: Herts, UK Hello Is there a limitation or something with the TextArea control? I am running the following code on a button click event dim sh as new shell sh.execute("wmic os get BuildNumber, BuildType, Version /format:list") TextArea1.Text = sh.Result The TextArea results in a single line "BuildNumber=7600 BuildType=Multiprocessor Free Version=6.1.7600" however if I run the command from a dos cmd prompt the the output displayed as 3 lines which is what am looking to do with the TexArea control. My TextArea control is set to multi-line but makes no difference. BuildNumber=7600 BuildType=Multiprocessor Free Version=6.1.7600 Is there a simple way to do this.? Thanks _________________ Real Studio 2012 R2 SysInfo BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD Top DaveS Post subject: Re: shell execute result not wrapping text in TextAreaPosted: Thu Jan 17, 2013 9:51 am Joined: Sun Aug 05, 2007 10:46 am Posts: 4423 Location: San Diego, CA I assume you are on WINDOWS? The shell command is probably returning a string with a different line-ending than the TEXTAREA wants.... try something like this in your shell execute result=replacelineendings(result,endofline.windows) ' you might have to try endofline.macintosh, or endofline.unix YES... even if your are on windows there are 3 EOL string CR - 0x0D - used by older Macs LF - 0x0A - used by newer Mac and Unix CRLF - 0x0A0D used by windows but it seems that the TextArea uses one not necessiarly related to your OS _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top p0wn3d Post subject: Re: shell execute result not wrapping text in TextAreaPosted: Thu Jan 17, 2013 12:15 pm Joined: Sun Oct 28, 2012 4:54 am Posts: 80 Location: Herts, UK Thanks Dave your suggestion does work. Just a small snag though with spaces being inserted. dim s As new Shell, Result as String s.Execute "wmic os get BuildNumber, BuildType, Version /format:list" Result=s.ReadAll result=replacelineendings(result,endofline.windows) TextArea1.Text = Result It seems that the only workaround other than possibly using regex to remove the spacing is with this code. Dim cr as String dim sh as new shell sh.execute("wmic os get BuildNumber") dim BuildNumber as string = sh.Result sh.execute("wmic os get BuildType") dim BuildType as string = sh.Result sh.execute("wmic os get Version") dim Version as string = sh.Result cr=EndOfLine.windows TextArea1.Text =BuildNumber +cr+BuildType+cr+Version _________________ Real Studio 2012 R2 SysInfo BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD Top charonn0 Post subject: Re: shell execute result not wrapping text in TextAreaPosted: Thu Jan 17, 2013 1:26 pm Joined: Mon Apr 02, 2007 2:08 am Posts: 1071 Location: San Francisco, CA, USA Looking at the output of the command on Win7, I can see that there are a two carriage return characters (character &h0D) before and after each line. Try this: TextArea1.Text = ReplaceAll(sh.Result, Chr(&h0D) + Chr(&h0D), Chr(&h0D)).Trim This replaces each double EOL marker with a single EOL marker and removes the whitespace before and after the text. _________________ Boredom Software Top p0wn3d Post subject: Re: shell execute result not wrapping text in TextArea(SOLVEPosted: Thu Jan 17, 2013 2:20 pm Joined: Sun Oct 28, 2012 4:54 am Posts: 80 Location: Herts, UK Thanks charonn0 your code works perfectly _________________ Real Studio 2012 R2 SysInfo BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 5 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
