Results 1 to 10 of 14

Thread: Years later, Variant bug still there

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Posts
    131

    Angry Years later, Variant bug still there

    It's been over three years since this bug was reported, it's no doubt latently sitting there in many peoples code and still not fixed. Code can describe it better than I can:

    Code:
    Procedure TestDTBug 
        DateTime dtCurrent dtOther
        Variant vVal
        TimeSpan span
        
        Move (CurrentDateTime()) to dtCurrent
        Move dtCurrent to vVal
        
        // Ok, this looks right so far, it shows "They're the same"
        If (vVal = dtCurrent) Showln "They're the same"
        Else Showln "They're different"
        
        // Let's just move it back to a datetime
        Move vVal to dtOther
        
        // And do the comparison again, but wait, now it says "They're NOT the same"
        If (dtOther = dtCurrent) Showln "They're still the same"
        Else Showln "They're NOT the same"
        
        // Why is that? Ah yes, many years later a variant STILL loses precision 
        // even though it's trivial to fix.
        Move (dtCurrent-dtOther) to span
        Showln "Here's why: " span " original: " dtCurrent " after move to variant: " dtOther
        inkey windowindex
    End_Procedure
    
    Send TestDTBug


    The fact that a comparison shows they're the same, but a simple showln shows them not to be the same is tough to swallow. Now, you may be tricked into thinking things work better than that if you have code like this:

    Code:
    Procedure TestVal Variant vParam
        shown vParam
    end_procedure
    
    Send TestVal (CurrentDateTime())

    That actually does work and shows a Datetime with millisecond precision because in fact, Dataflex is passing a DateTime in this case, NOT a Variant. But if you were to move that value to another variant it will actually become a true variant:

    Code:
    Procedure TestVal Variant vParam
        Variant vOther
    
        showln vParam
        move vParam to vOther
        showln vOther
    
        if (vParam = vOther) showln "But they're the same according to DF"
    end_procedure
    
    Send TestVal (CurrentDateTime())


    Now you can see that the value has changed. The showln's are different, but DF says they're the same. This breaks stuff in all kinds of weird places that are hard to track down. Will we ever see a fix for this?

    OLIVER

    Last edited by flxkid; 23-Aug-2021 at 05:49 PM. Reason: code cleanup

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •