[Gambas-user] Stopping a CLI program

Tobias Boege taboege at ...626...
Wed Dec 11 12:54:13 CET 2013


On Wed, 11 Dec 2013, Tobias Boege wrote:
> On Wed, 11 Dec 2013, John Rose wrote:
> > Tobias,
> > 
> > Thanks for your example. I've now got the Exec's termination working OK. 
> > Below is an extract from my code:
> > Private aExec As String[]
> > Private sOutput As String
> > Private hffmpeg As Process
> > hffmpeg = Exec aExec Wait For Input Output As "ffmpegMessages"
> > Public Sub ffmpegMessages_Read()
> >    Dim sLine As String
> >    Read #Last, sLine, -256
> >    sOutput &= sLine
> > End
> > Public Sub ffmpegMessages_Kill()
> >    Print "ffmpeg Output = "
> >    Print sOutput
> > End
> > Public Sub ButtonStop_Click()
> >    If hffmpeg.State = Process.Running Then Print #hffmpeg, "q"
> > 
> > At run time:
> > 1. aExec was equal to ["ffmpeg", "-f x11grab",.....]. Thus, the first 
> > parameter was "-f x11grab") which was displayed by ffmpeg as 
> > unrecognised (even though running "ffmpeg -f x11grab ......." is OK.
> > The setting of the value in aExec was done by:
> > aExec = ["ffmpeg"]
> > aExec.Add("-f x11grab")
> > etc
> > I think that I've seen something like this before with Exec but I don't 
> > remember the reason or solution. Any ideas?
> > 
> 
> I'm tired of explaining this... Is the documentation really _that_ unclear?
> You have to put one argument into one field of the array, thus:
> 
> ["ffmpeg", "-f", "x11grab"]
> 
> is the correct array.
> 
> > 2. The Kill routine above was executed. At run time, there was an error 
> > caused by the last line being:
> > If hffmpeg and hffmpeg.State = Process.Running Then Print #hffmpeg, "q"
> > So I removed the first hffmpeg & it was OK at runtime.
> > 
> 
> Oh, there was an error? Your chances to not annoy people are better if you
> also write down _what_ error it was. The idea is to save us the time to
> write your code into one of our projects to see it...
> 
> The reason is that you wrote "hffmpeg and hffmpeg.State = Process.Running".
> In Gambas, the And operator "pulls stronger" than the equals operator
> because And is a binary operator in Gambas. So your code is equivalent to

I meant to say: And is a *bitwise* operator in Gambas.

> 
> Attached is also a patch to the project I sent you because I am also prone
> to this kind of error ;-)
> 

... and the attachment.

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg-print-q-0.0.1~ffmpeg-print-q-0.0.1.patch
Type: text/x-diff
Size: 467 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20131211/569c974c/attachment.patch>


More information about the User mailing list