RE: [ROOT] Getchar vs wait - asynchronous cin/stdin read.

From: Philippe Canal (pcanal@fnal.gov)
Date: Thu Feb 07 2002 - 01:53:27 MET


Hi Elena, Sascha,

Under ROOT the best way to handle this is to use an asynchronous timer.
I included a small code sample that should how to implement this feature:


#include "TTimer.h"
#include "Getline.h"
#include "TSystem.h"
#include <iostream>

void my_exec() {
    char    *input;
    Bool_t done = kFALSE;

    // The interactivity is enable by the first parameter of the
    // TTimer.  Instead of a CINT command, we could also pass it 
    // the address a object which implements HandleTimer.
    TTimer  *timer = new TTimer("gSystem->ProcessEvents();", 50, kFALSE);

    do {
       timer->TurnOn();
       timer->Reset();
       // Now let's read the input, we can use here any
       // stdio or iostream reading methods. like std::cin >> myinputl;
       input = Getline("Type <return> to exit: "); 
       timer->TurnOff();

       // Now usefull stuff with the input!
       // ....
	 // here were are always done as soon as we get some input!
	 if (input) done = kTRUE;
    } while (!done);

 }


Cheers,
Philippe.


-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Elena Vataga
Sent: Wednesday, February 06, 2002 6:36 AM
To: Rene Brun
Cc: roottalk@pcroot.cern.ch
Subject: [ROOT] Getchar vs wait



Hello!

One simple question:

in old PAW there was a command <wait> which allowed to
	1. continue kumac from stop point
	2. quit kumac

Getchar in ROOT macro is smth equivalent, but
looks like it is possible only to continue from stop point - correct?
Is there a way to quit macro?

	Regards,
			Elena

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of sascha.zelzer@gmx.net
Sent: Tuesday, February 05, 2002 6:19 PM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] standalone program and terminal input?

Hi everyone!

I am writing a small standalone ROOT program and want to be able to read
data from the user after the call to gApplication->Run(). I don't wont to make
exhaustive use of the GUI facilities because of the coding time compared with
a simple input through the terminal via cin (from which the program has been
started). But calling cin from a callback inside the root application just
blocks the whole X-Windows and I have to kill it from another console.

So, what would be the best way to get simple input done through a terminal
window for a GUI program ?

I would appreciate any hints on this.

Thanks,

Sascha

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:41 MET