Coffee: NULL == 0?



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

    On 22/10/2007 at 07:06, xxxxxxxx wrote:

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

    ---------
    I want to check if specific fields in a three-dimensional array are already set (the third dimension has only two fields). Although the term

    if(edges[minPoint][maxPoint][0] == NULL)
          edges[minPoint][maxPoint][0] = value;
    else
          edges[minPoint][maxPoint][1] = value;

    seems to be valid, COFFEE treats 0 like NULL. Thus, if the field is filled with 0, the value gets overwritten.

    How can i distinguish between 0 (zero) and NULL (emtpy field)?

    Regards
    Christoph Lauterbach



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

    On 22/10/2007 at 10:27, xxxxxxxx wrote:

    COFFEE doesn't have pointers being typeless. NULL is usually 0 - historically it represents an invalid memory address 0x00000000F assigned to pointers (Assem/C/C++/Java/...). Go to this link for more info:

    http://en.wikipedia.org/wiki/Null_(computer)

    There is no way to distinguish between 0 and NULL. All variable settings boil to numbers anyway - including pointers.

    Do elements in edges[][][] represent pointers to something or the actual something itself?



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

    On 23/10/2007 at 01:11, xxxxxxxx wrote:

    Thank you Robert. As far as I know, NULL is usually not 0 - while 0 is a value, NULL indicates a non-value.

    Anyway, I solved it with

    if(typeof(edges[minPoint][maxPoint][0]) == DT_NIL)
    [...]

    The elements in edges[][][] represent point indices (thus integers).

    Regards
    Christoph


Log in to reply