Maxon Developers
    • Downloads
      • All Downloads
      • Cinema 4D Python SDK
      • Cinema 4D C++ SDK
      • Cineware SDK
      • ZBrush GoZ SDK
      • Cinema 4D Python Examples
      • Cinema 4D C++ Examples
      • Project Tool
      • SDK Database
    • Documentation
      • Cinema 4D Python SDK
      • Cinema 4D C++ SDK
      • Cineware SDK
      • ZBrush GoZ SDK
    • Forum
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Forums
      • Overview
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • News & Information
      • Downloads
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Register
    • Login

    Work with filestrings read by BaseFile

    SDK Help
    0
    4
    71
    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 01/12/2005 at 06:03, xxxxxxxx wrote:

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

      ---------
      Hello out there,
      I am quite new on coding C.O.F.F.E.E. To start my lessions on filescripting, I am coding a menuplugin to import OBJ-files.
      Unfortunately C.O.F.F.E.E, thus plattform independent, is horrible slow (I think because it is an interpreter, although compiling did not make it faster).
      Here is the way the file is read:
      I read the file into a long string with BaseFile->Readstring. Then I am trying to splitt this string linewise and access data in the line.
      Therefore I am searching CRLF-signs in te string with the strstr-function. I got some tipps from other users, that this function is very slow. (Hello Maxon: Is it like this and if, why?)
      Does anybody have a tuning-trick to speed up string-operations like these in C.O.F.F.E.E., perhaps using other functions than strstr/strchr?
      Or does anybody have a tipp for me, how reading a file could be done quicker?
      As I am not very familiar with VC++ and because it would no longer be plattform-idependent I would prefer not to recode in C++-SDK (even if it runs much faster then).
      Thanks for help everybody,
      COFFEJUNKIE
      Ps: Sorry for my English, I did not speak or write it for longer now...

      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 10/12/2005 at 04:57, xxxxxxxx wrote:

        I don't know about the performance, but this is a function that I have used to extract a line in C.O.F.F.E.E.:

            
            
            // Remove a line from data and return it  
            // Must be called by reference: getline(&data)  
            getline(data)  
            {  
              var pos = strstr(data, "\n");  
              var line = strmid(data, 0, pos-1);  
              data = strmid(data, pos+1, sizeof(data));  
              return line;  
            }
        

        This is an example of how it's used:

            
            
            main()  
            {  
              // Open file for reading  
              var f = new(BaseFile);  
              f->Open(file);
            
            
            
            
              // Read the whole file  
              var data = f->ReadString(f->GetLength());  
                 
              // Read the number of objects  
              var max_index = evaluate(getline(&data));  
                
              // Loop through objects  
              var i;  
              for (i = 0; i < max_index; ++i)  
              {  
                var obj = getline(&data);  
                if (i == index)  
                {  
                  // Output the name of obj number 'index'  
                  name = obj;  
                }  
              }  
              ...  
            }
        
        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 16/12/2005 at 06:48, xxxxxxxx wrote:

          Hello Mikael,
           
          first of all, thanks for your answer. There is only one question I have and do not understand in your code:
          Your code to remove the extracted line from the datastring is
          data = strmid(data, pos+1, sizeof(data));

          but I think you have to reduce sizeof(data) by the amount of removed characters like
          data = strmid(data, pos+1, sizeof(data)-pos);
          or is this wrong? And if so, why (perhaps because of possible unicode?)
          Best greetings,
          COFFEJUNKIE

          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 17/12/2005 at 10:27, xxxxxxxx wrote:

            That's just me being lazy. The docs said that strmid ignored the size going beyond the length of the string, so I didn't bother thinking of what to subtract (pos, pos+1 or pos-1). Your version is better, at least if you've chosen the right amount to subtract... 🙂

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