Not supported on Windows?

Hi Rooters,

I cannot use “str.ReadLine(f, kFALSE)” under Windows because I always get the error:

root [1] Error: C++ exception caught FILE:C:\Programming\rootpaolo\spy.c LINE:101
*** Interpreter error recovered ***

But under Linux it works. How can I use the TString under Windows? Is there another ‘working’ possibility to use strings under Windows??
The program I need looks like:

ifstream f;
TString str;
f.open(“xyz.dat”, ios::in);
if (f.good()) {
while(!f.eof()) {
str.ReadLine(f, kFALSE);
cout << str << endl;
}
f.close();
}

cheers,
Gerolf

Hi Gerof,

This has been fixed in a more recent version of ROOT (well at least I think so … you have forgotten to specify the ROOT version).

To work around this problem with your version of ROOT, you’ll need to compile your code (which you can easily do with ACLiC: .L myscript.C+).

Cheers,
Philippe.

Hello folks,

I’m having trouble reading ascii text from root on Windows. I’ve tried a couple of macros, one from this thread, with little success. On the other hand, the two codes both work as they should on root under cygwin/Xwindows.

I’m running root 4.00/04 under Windows 2000Pro, with VC++ v6.0 service pack 3.

On the cygwin side, I’m running root 3.10/02, with (a recently updated) cygwin and cygwin/X.

It appears that the problem is that on windows, a call to a “read” type of function, like “get” or TString::ReadLine produces no result, but doesn’t actually fail.

My test codes and output are below. I apologize for the length of what follows. I figured it was better to be as complete as possible.

Thanks for your help.

Brian

Test codes:

The first code is:

void testio() {
  char ch;

 ifstream testinFile( "testFile.txt", ios::in);

 while( !testinFile.eof()) {
   testinFile.get( ch);
   cout << "char: ";
   cout.put( ch);
   cout << endl;
 }

 testinFile.close();

}

On windows, it produces:

whereas on cygwin, it produces:

[quote]
root [0] .L testio.C
root [1] testio()
char: T
char: h
char: i
char: s
char:
char: i
char: s
char:
char: a
char:
char: t
char: e
char: s
char: t
char:

char:

root [2]
[/quote

The second code is:

#include "iostream.h"
#include "TString.h"

void testio2() {

  ifstream f; 

  TString str; 

  f.open("testFile.txt", ios::in); 
  cout << "About to check if 'f' is good" << endl;
  if (f.good()) { 
    cout << "About to loop while !eof" << endl;
    while(!f.eof()) { 
      str.ReadLine(f, kFALSE); 
      cout << str << endl;
      cout << "Did a ReadLine" << endl;
    } 
    cout << "Done with 'while'" << endl;
    cout << "About to close input" << endl;
    f.close(); 
    cout << "Done closing input" << endl;
  } 
  cout << "Done with 'if'" << endl;

}

On windows it produces:

and on cygwin I get:

[quote]
root [2] .L testio2.C
root [3] testio2()
About to check if ‘f’ is good
About to loop while !eof
This is a test
Did a ReadLine

Did a ReadLine
Done with 'while’
About to close input
Done closing input
Done with ‘if’
[/quote][/quote]

Sorry, I accidentally posted twice.

Hi again,

Further work shows that this code:

#include <stdio.h>

void testio3() {

  char ch;
  FILE *input = fopen( "testFile.txt", "r" );

  while (!feof( input)) {
    ch = getc( input );
    printf( "char: %c\r\n", ch);
  }

}

works fine in both windows and cygwin environments.

Hmmmm…

Brian

[quote]I’m running root 4.00/04 under Windows 2000Pro, with VC++ v6.0 service pack 3.
On the cygwin side, I’m running root 3.10/02, with (a recently updated) cygwin and cygwin/X. [/quote]
A possibility is that you environment is confused between the 2 version of ROOT that you seem to have installed (4.00/04 and 3.10/02). A priori a properly installed version of ROOT 4.00/04 should not exhibit any problem.

Cheers,
Philippe

I can reproduce the testio.C output, with MSVC 7 and 4.00/04 from May 25 on win2k. It returns only one char with value 0.
Axel.

Hi all,

I wheeled my cygwin root installation out of the way and reran the testio.C program using the windows installation. I get the same result as before: one char of value zero.

bpw

Hi,

The problem comes from the fact that the value of ios::in used by CINT is incorrect. For now just use:

Cheers,
Philippe

Hi,

The solution to this problem will be uploaded shortly in the CVS repository.

Cheers,
Philippe.

Eehhhxcellent.

Thank you very much!

Brian
:smiley: