Curious about Browser->IsDir()

On 28/04/2013 at 21:10, xxxxxxxx wrote:

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

---------
Hi Folks,

I'm just curious about what the difference is between the following code snippets. The first one works, but the second one doesn't:

  
// Folder is an AutoAlloc BrowseFiles...   
  
if(Folder->IsDir())   
{   
    GePrint("This way works...!");   
}   
  
if(Folder->IsDir() == TRUE)   
{   
    GePrint("This way doesn't work...");   
}   

What's the technical/C++ difference here and why does one way work but the other not? I'm just curious because having Folder->IsDir() == FALSE works fine, but having TRUE does not..

WP.

On 29/04/2013 at 06:56, xxxxxxxx wrote:

Well Bool in C4D SDK is actually an Integer (int)  while FALSE if 0 and TRUE is 1.
The problem is that Bool can also be 5 or any other Integer value.
If IsDir() return some other value as 1 for true then if(IsDir()) will work but if(IsDir()==TRUE) will not work because if(5 == 1) is false.

Some times C4D SDK uses NOTOK = (-1)  as a Bool value too.

On 29/04/2013 at 13:28, xxxxxxxx wrote:

While it is true that Bool is an integer, it should be returning strict TRUE/FALSE values.  The docs say that it returns TRUE if this is a directory.  So, the second conditional should be working or it's a bug in the SDK (or your code).

On 29/04/2013 at 13:53, xxxxxxxx wrote:

not sure how it is in cpp, but in python and c# the lazy ass implicit notation behaves different 
than the explicit notation.

def foo(v) :
    if v: print 'imp', True
    else: print 'imp', False
    
    if v == True: print 'exp', True
    else: print 'exp', False
        
print 0
foo(0)
print -1
foo(-1)
    
\>>0
\>>imp False
\>>exp False
\>>-1
\>>imp True
\>>exp False

On 29/04/2013 at 14:19, xxxxxxxx wrote:

@littledevil: The same in example in C++ will print the same results.

http://ideone.com/JgkQcJ

Best,
-Niklas

On 29/04/2013 at 14:48, xxxxxxxx wrote:

Originally posted by xxxxxxxx

<ADDRESS>
User Information:
Cinema 4D Version:   R14 
Platform:   Windows  ;   
Language(s) :    
C++  ;

---------
</ADDRESS> Hi Folks,

I'm just curious about what the difference is between the following code snippets. The first one works, but the second one doesn't:

 
// Folder is an AutoAlloc BrowseFiles...   
 
if(Folder->IsDir())   
{   
    GePrint("This way works...!");   
}   
 
if(Folder->IsDir() == TRUE)   
{   
    GePrint("This way doesn't work...");   
}   

What's the technical/C++ difference here and why does one way work but the other not? I'm just curious because having Folder->IsDir() == FALSE works fine, but having TRUE does not..

WP.

It's a Windows specific bug (on the Mac it's fine) - the return value on Windows is the Win32 FILE_ATTRIBUTE_DIRECTORY constant (instead of TRUE). I'll file a bug for it. For the time being please use the code block of your first scope as workaround instead of comparing it with "TRUE".

Best regards,

Wilfried

On 29/04/2013 at 19:01, xxxxxxxx wrote:

Thanks again everyone.

WP.