Forum Discussion

marck's avatar
marck
Occasional Contributor
10 years ago
Solved

Can't read the tab spaces from a file.

I'm trying to read from a log file stored on my PC. The log contains tab spaces and I want to read those as well. I use the ReadLine() method to read the line that I want, but it doesn't read the tab spaces. Anyone knows how to solve this?

  • The file is read correctly. What you see is the log viewer stripping the whitespace - this is how it works. But if you check the individual characters in a string, you'll see the tabs (code 9) are there:

     

    s = F.ReadLine();
    Log.Message(s);

    for (var i = 0; i < s.length; i++)
    Log.Message(s.charAt(i) + " (code " + s.charCodeAt(i) + ")");

4 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Can you show the code you're using, and attach a sample file?

    • marck's avatar
      marck
      Occasional Contributor

      ...

      F = aqFile.OpenTextFile(fileArray.pop(), aqFile.FaRead, aqFile.ctANSI);

      while(!F.IsEndOfFile())

      {

         s = F.ReadLine();

         ...

         Log.Message(s);

      }

       

      I tried Log.Message(F.ReadLine()); to see if for some reason the variable can't hold the tabs, but it seams that the method is not reading the tab spaces. I tryed all 3 TextCodingType, still same result.

       

      > 20150227-16:03:20:0161875	4	StatusLogging	writing short term status

       

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        The file is read correctly. What you see is the log viewer stripping the whitespace - this is how it works. But if you check the individual characters in a string, you'll see the tabs (code 9) are there:

         

        s = F.ReadLine();
        Log.Message(s);

        for (var i = 0; i < s.length; i++)
        Log.Message(s.charAt(i) + " (code " + s.charCodeAt(i) + ")");