[Gambas-user] Stopping a CLI program
John Rose
john.aaron.rose at ...626...
Wed Dec 11 10:38:51 CET 2013
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?
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.
3. I wanted to incorporate:
Public Sub ffmpegMessages_Error(sError)
Print "ffmpeg Error = "
Print sError
End
but the compiler objected. Any ideas?
--
Regards, John
More information about the User
mailing list