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

    String::FindFirst()

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 295 Views
    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 Offline
      Helper
      last edited by

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

      On 28/03/2007 at 13:20, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   9.603 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Hi Guys,
      I am unable to get the FindFirst member function of the String class to operate correctly. The following code should work, but doesn't:

          
          
          
          
          LONG *charPos = NULL;  
          String name("Cube Whatever");
          
          
          
          
          if(name.FindFirst(" ", charPos, 0))  
          {  
          if(!charPos)  
          {  
          GePrint("Exiting");  
           return TRUE;  
          }  
            
          name[*charPos] = '_';  
          }  
          
      

      The charPos pointer will ALWAYS return NULL! The really confusing thing is that the console will always print "Exiting" meaning that the FindFirst() is finding the " " in the name string. So the question is: Why is the LONG *Pos parameter not returning a correct pointer? As always any help on this is always much appreciated.
      Josh

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

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

        On 28/03/2007 at 14:28, xxxxxxxx wrote:

        You have only created a NULL pointer. You have to allocate a LONG variable and pass the pointer to FindFirst. This should work:

          
        LONG charPos = 0; //create a variable on the stack  
        String name("Cube Whatever");  
          
        if(name.FindFirst(" ", &charPos;, 0)) //pass the address (pointer) of charPos  
        {  
        name[charPos] = '_';  
        }  
        

        Alternatively you can also allocate a LONG on the heap with gNew, just make sure to de-allocate it with gDelete. Note always use Cinemas own allocation methods to ensure maximum platform compatibility.

        cheers,
        Matthias

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

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

          On 28/03/2007 at 14:44, xxxxxxxx wrote:

          Thanks for the quick reply. I assumed that the pointer would be filled by the FindFirst() which is why I initially set it to NULL. But this makes sense, thanks once again.
          Josh

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