[Gambas-user] about process

ron ronstk at ...239...
Wed Dec 3 18:39:47 CET 2003


Hi All,

> Message: 1
> From: Benoit Minisini <gambas at ...1...>
> To: gambas-user at lists.sourceforge.net
> Subject: Re: [Gambas-user] about process
> Date: Mon, 1 Dec 2003 12:53:20 +0100
> Reply-To: gambas-user at lists.sourceforge.net
>
> On Saturday 29 November 2003 15:20, Edward Hsu wrote:
> > Dear Benoit,
> >
> > Thanks for your reply.
> >
> > I am very confused. I wrote an e-mail asking about the
> > example of movieplayer which did not work at all and
> > you said 'the READ option should be taken away'. After
> > I took it away, it works fine. I also found that you
> > took it out in the example of movieplayer for Gambas
> > 0.72.
> >
> > Now you said that EXEC  ... for READ WRITE as
> > $hProcess should work. I try the example of
> > movieplayer with READ option again on Gambas 0.72, it
> > still doesn't work. After I take READ option away, it
> > works. Is there any bug in new EXEC for music? I found
> > it works fine for others with READ option but it
> > doesn't work for music with mplayer.
> >
> > Regards,
> >
> > Edward
>
> Can you send me your project ?
>
> --
> Benoit Minisini
> mailto:gambas at ...1...
>
>
>
> --__--__--
>
> Message: 2
> From: Rob <sourceforge-raindog2 at ...94...>
> To: gambas-user at lists.sourceforge.net,
> 	Ken Schrock <schrockk at ...137...>
> Subject: Re: [Gambas-user] Event loop
> Date: Mon, 1 Dec 2003 08:21:29 -0500
> Reply-To: gambas-user at lists.sourceforge.net
>
> On Saturday 29 November 2003 15:43, Ken Schrock wrote:
> > There was a DoEvents or some such in VB
> > Sleep works in C in Linux
> > How here?
>
> You want the WAIT keyword.  It's equivalent to the C sleep()
> function in stdlib, though sleep() takes a required integer
> parameter and with WAIT it's a float so you can "WAIT 0.5" to
> sleep half a second.  (or just "WAIT" to wait only as long as
> the system needs to do the event loop....)
>
> I think I'll add some notes to the WAIT page in the wiki so
> people can more easily find it.
>
> Rob
>

Rob:
You recently mentioned the WAIT as alternative for VB's DoEvents for a wait 
process. Be carefull for the difference. As I understand from documentation 
the WAIT does a wait for Gambas, the interpreter wait the time and nothing 
else is executed in the interpreter (i.e. other events ) in the program using 
this WAIT function.

With VB DoEvents this behaviour is different, other buttons can be pressed and
those events are executed. 

VB's DoEvents let the events in the programm working but also windows 
background processes. 

VB's Sleep (or Delay, i forgot)  holds everything, events in the program and 
all other programs in windows!. Can't move Notepad window.

Gambas WAIT keeps the whole program waiting till the wait time is passed. 
Other program stay working!. Can move Kedit window.

In VB you can use

textbox.text="Check the checkbox GO to continue at the same moment"
do while checkbox_go=false
  DoEvents
  passes=passes+1
loop
textbox.text="Thank You"

and use a checbox to stop this waiting and passes has a very big value.

textbox.text="Check the checkbox GO to continue, may be a delay of 10 sec"
do while checkbox_go=false
  WAIT 10
  INC passes
loop
textbox.text="Thank You"

You must be lucky to check the GO because only at a interval of 10 seconds the 
WHILE condition is tested and the time after the WAIT till this test is a few 
miliseconds. The passes is only every 10 second incremented

You can't use WAIT 10 in a seperate form to monitor every 10 seconds changes 
somewhere as was the intention by the person asking about it and keep the 
application creating this form continue other tasks. He should use a timer 
object in that form.  

Edward Hsu:
The READ was working by me in 0.71 but during the update to 0.72 I forgot to 
save the new player example I made. You must use Process_Read() if you use 
READ to consume the data send by the aplication to stdout.
It was not clear how to use the Process_Read() at the time I did it but I 
found the way.
The problem was that the READ could be consumed with LineInput and Input 
methods. 

  LineInput #filehandle, sVariable

It wants a file handle and you dont have a file (disk file).
In this case you must use the process handle. 

  LineInput #processhandle, sVariable

This way you get the output from the player and could wait for the line with 
AV: as start to make the play window visible instead of using the WAIT 
method.
If you use READ then you must use the Process_Read() function, read the data 
from the handle and trow away or do something with it.
See below for additional comment.

Benoit:
When the mplayer program send it output to stdout it is visible in the Gambas 
console. I can scroll in the console this output so i asume there is a big 
buffer. Is it posible that programs send so many data and the console buffer 
becomes full?

Can you give an example or documentation for the Stream object used to get the 
output of the program started with EXEC in the way your intention is ?
I had some problems to find the way to get the data.
As far I know I did it this way:

A global variable MovieVisible
Use the EXEC() FOR READ WRITE AS $hProcess.
Put a rem before the WAIT.
Set variable MovieVisible=false
Made a subroutine of the part below the WAIT as showmovie.
Add a new subroutine like this one:

public process_read()
  dim txt as string

' this must always be done else the movie/program stops
  lineinput #hProcess, txt 

' test if movie is already visible
  if MovieVisible=true then return

' wait for mark of the first movie frame
  if left (txt,4) = "AV: " then
    showmovie ' calling the extra subroutine
    MovieVisible=true
  endif
end

This way the beginning dropped by the WAIT function was eliminated and the 
show started direct as the first frame is available.
With the WAIT 0.5*4 or *8 for the mpg film on a network share you miss the 
leading seconds by the WAIT function. 
The variable MovieVisible can be the visible property of the label used as 
viewport. Is more correct too.

For the rest I like Gambas, it is a good alternative for C to make simple  
programs with less overhead as using C.
I go now for 6 weeks to do a programming job on Tenerife but when I am back I  
wil take a look to remake the Mediaplayer using READ.

grts Ron.






More information about the User mailing list