Sign in to follow this  
Followers 0
andyswarbs

Various extensions to _Run

6 posts in this topic

#1 ·  Posted (edited)

PopG_Run.au3

#region Doc:

#region Doc: Notes

; Extends functionality for running external programs.

;

; RunErrorsFatal needed to avoid Au3 collapse!

#endregion Doc: Notes

#region Doc: Requirements

; Requires Au3 build 3.1.1.109 or better.

; Also uses include libraries array and constants.

#endregion Doc: Requirements

#region Doc: FunctionList

; _RunWaitOutErr Runs a (dos) command until completion, returning output & error lines into two arrays

; _RunWaitSys Does a RunWait for a command in the system folder

; _RunWaitSysOutErr Does a RunWaitOutErr in Sys folder

#endregion Doc: FunctionList

#region Doc: History

; 20-Feb-06 Als Updated _RunWaitOutErr Debugged further proceessing to ensure line breaks are processed properly.

; 19-Feb-06 Als _RunWaitOutErr updated to separate out data collection from parsing into arrays.

; 13-Feb-06 Als Commented out RegExpReplace on request of two Au3 users.

#endregion Doc: History

#endregion Doc:

Edited by andyswarbs

Share this post


Link to post
Share on other sites



I know some people have been asking for something like this _RunWaitOutErr for some time. If it does what you say it does which is returning output & error lines into two arrays. That will be huge if you can read the output from a cmd prompt. I havent tested these out yet but if it does what it says then, dude cool program.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

It indeed does do what it says "on the box". I would appreciate someone helping debug the code regarding StringLen.

If StringLen($TmpVal)>1 Then _ArrayAdd($rwoeOutArr,$TmpVal);should be >0 but some bug there! ****************************

What the hell is going on there is a mystery to me. I tried to see if there were any control chars, and there weren't. So I do not know, and that's the truth.

Edited by andyswarbs

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Is a CR/LF a character? :o A "blank line" of output is a single character, the "return" at the end...

Too much wine, let me try again: you're splitting the read data on LF characters, which leaves the CR character in the "empty line" strings, so you get a StringLen of 1 on those lines.

I had sent you a PM earlier,

$TmpVal=StringRegExpReplace($TmpArr[$TmpIdx],'^:\A', '')

doesn't do what I think you want it to, it just eats the first two characters from a line if it starts with a colon and an alphanumeric character. I'm guessing that you intend it to supress "blank" (whitespace only) lines? You might provide that as an option to the function, but I wouldn't do it as the default; provide the user with the simple functionality and let them sort out the details...

[Edit: Clarification. Don't drink and post.]

Edited by DaveF

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

Yep, I was trying to get rid of whatever was causing that glitch, and probably the answer I came up with is not correct. Time for another play. But it still does not solve the core problem of why the stringlen>0 does not work and why stringlen>1 does. At the time I felt that it was a bug in Au3, but it could be my ignorance elsewhere.

Share this post


Link to post
Share on other sites

Have a look at this, if you would:

Dim $ourProcess, $ourOutput

$ourProcess = Run(@ScriptDir & "\blankline.exe", @ScriptDir, @SW_HIDE, 2)
;# Blankline.exe writes the output:
;Blank line follows...
;
;The End.
;# Read the output
While 1
    $ourOutput &= StdoutRead($ourProcess)
    If @error = -1 Then ExitLoop
WEnd

; Split on linefeed
$ourOutput = StringSplit($ourOutput, @LF)

; Step over resulting array
For $step = 1 To $ourOutput[0]
    If $step = 2 Then
        If StringLen($ourOutput[$step]) > 0 Then
            MsgBox(0, "Debug", 'The first character has of the "blank" line has ASCII code: ' & Asc(StringLeft($ourOutput[$step], 1)))
        Else
            MsgBox(0, "Debug", "The blank line had zero length.")
        EndIf
    EndIf
Next

blankline.exe (place in the same folder and compile before running):

ConsoleWrite("Blank line follows..." & @CRLF & @CRLF & "The End.")

Microsoft newlines are CR/LF pairs, splitting on LF only leaves behind the CR (ASCII code 13) on a "blank" line...


Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

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  
Followers 0