Jump to content
Sign in to follow this  
BigAl

Display only upto 3 lines from output

Recommended Posts

BigAl

Hello
 
I have a small app which runs some machine configuration, stops and disables taks etc and outputs the STDOUT into a variable, then using StringRegExpReplace I remove the blanks lines from the output and then display the this in an Edit control.
This works in that it will show me the entire output but I only want to display upto the first 3 lines in my Edit Control.
 
I've googled a few option but not really sure what would be the best way to go about it.
 
I've posted a snippet below which shows the task stopping and how i remove the blank lines

Local $superstop = Run(@ComSpec & " /c " & 'sc stop "' & "SysMain" & '"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
   ProcessWaitClose($superstop)
   $superout = StdoutRead($superstop)
   $superoutNBL = StringRegExpReplace(StringRegExpReplace($superout, "(\v)+", @CRLF), "\A\v|\v\Z", "")
   GUICtrlSetData($Output, GUICtrlRead($Output)& @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " " & "$superoutNBL$")

Any help would be appreciated.

 

Share this post


Link to post
Share on other sites
mikell

This should work

$superoutNBL = StringRegExp($superout, '(?m)(^.+)\s*\R?', 3)   ; skip blank lines
$3lines = $superoutNBL[0] & @crlf & $superoutNBL[1] & @crlf & $superoutNBL[2]
Msgbox(0,"", $3lines)

Share this post


Link to post
Share on other sites
mikell

jguinch, your expression doesn't remove a possible leading blank line  ;)

Share this post


Link to post
Share on other sites
BigAl

Thanks very much for the replies, mikell your solution worked a treat.

Thanks again

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.