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
diff -urNaX /tmp/gambas-patch-ignore a/.src/FMain.class b/.src/FMain.class
--- a/.src/FMain.class 2013-12-10 21:41:54.000000000 +0100
+++ b/.src/FMain.class 2013-12-11 12:22:56.000000000 +0100
@@ -7,7 +7,7 @@
End
Public Sub btnStop_Click()
- If Not $hFfmpeg Or Not $hFfmpeg.State = Process.Running Then Return
+ If Not $hFfmpeg Or If $hFfmpeg.State <> Process.Running Then Return
Print #$hFfmpeg, "q"
' Open vlc with the video
Shell "vlc /tmp/out.mpg"
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user