Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Reading lines of text from (large) file?

    SDK Help
    0
    2
    340
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 07/02/2003 at 17:55, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   8.012 
      Platform:   Windows  ;   
      Language(s) :   C.O.F.F.E.E  ;

      ---------
      The code needs to read in a file and parse it, line by line.  But, there is no ReadLine() function, so I created one myself.  Let me know if this might work or if there is another approach.
      filelength is set to basefile->GetLength() right after calling basefile->Open() in another function.

          
          
          
          
          FileParser::ReadLine(basefile)  
          {  
           // Read in a line of text (until EOL) from file  
           var onechar ;  
           var line;  
           // Keep reading until EOL or EOF is reached  
           while (basefile->GetPosition() < filelength)  
           {  
             onechar = basefile->ReadString(1, GE_XBIT);  
             if (onechar != '\n')  
              line = stradd(line, onechar);  
             else  
              return TRUE;  
           }  
           // Unexpected EOF  
           return FALSE;  
          }  
          
      
      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 08/02/2003 at 02:27, xxxxxxxx wrote:

        This will fail for some combinations of LF and CR. (0x0A and 0x0D.) The three possibilities are CRLF (pc), CR (mac) and LF (unix). The easiest way is to consider CR (0x0d) as newline and always ignoring LF (0x0a). This won't work with unix files, but these aren't very common on C4D's platforms. (If you want to handle unix files as well, I guess you'll have to maintain some state variables.)

        1 Reply Last reply Reply Quote 0
        • First post
          Last post