TControlBar and interpreter input

From: Matt Fritts (mcfritts@accesstoledo.com)
Date: Fri Jul 16 1999 - 22:35:27 MEST


Greetings Rootfolk. I am using Root Version 2.21/08 with interpreter
version 5.13.92 on a Dell OptiPlex G1 running Windows NT. I'm having
trouble trying to create a TControlBar to use the macros I've written. When
I run a macro with the TControlBar, "scanf" fails to work properly in the
macro. The first use of scanf seems to work, but after that the interpreter
seems to ignore the first character of any keyboard input. As an example, I
used this macro:

{
   //menutest.c
   TControlBar bar("vertical");
   bar->AddButton("Test",".x inputtest.c", "For menu testing");
   bar.Show();
   gROOT.SaveContext();
}

to use this macro, named "inputtest.c":

{
   //inputtest.c

   int i;
   char s[50];
   float f;

   printf("enter an integer: ");
   scanf("%d",&i);
   printf("enter a string: ");
   scanf("%s",s);
   printf("enter a float: ");
   scanf("%f",&f);

   printf("integer: %d  string: %s  float: %f\n",i,s,f);
}

If I run menutest.c and then press the button to run inputtest.c, I get
results like this:

   root [1] enter an integer: 521
   enter a string: hello
   enter a float: 85.23
   integer: 521  string: ello  float: 5.230000
   
   Error: No symbol h8 in current scope FILE:C:\TEMP\250 LINE:1
   *** Interpreter error recovered ***
   root [2]

The error message only occurs after I hit the return key. Apparently it
then spits out the lost "h" and "8" from the second and third input. And
I've also noticed that when I'm entering "hello" above I am unable to
backspace past the "e"; the "h" cannot be removed.

I have no idea why this happens. If anyone does have a clue about this or
how I might rectify it, or avoid it, please let me know. For now the only
way I can use a TControlBar to run my macros is to enter an additional
space every time I enter keyboard data.

Thanks, 

Matt Fritts



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:35 MET