Alpha Video Training
Results 1 to 5 of 5

Thread: "If blob1 = blob2 then" always evaluates to true.. can't figure out why

  1. #1
    Member
    Real Name
    Mike Monk
    Join Date
    Feb 2005
    Posts
    114

    Default "If blob1 = blob2 then" always evaluates to true.. can't figure out why

    Here is what I am trying to accomplish.
    I am trying to handle the infamous "embedded browse cancel" issue. So whenever the user changes records on the embedded browse (aka the OnRowChange even) I read the current record into a blob variable
    Code:
    dim tbl as P
    tbl = topparent:Browse1.table_get() 
    RecNumBlob = topparent:Browse1.current_record()
    blobPrev = tbl.record_data_get(RecNumBlob)
    so the above code gets the record number and reads the record into a blob var

    Now when the user press the Cancel button on my form this is the code that excutes
    Code:
    dim tbl as P
    
    tbl = topparent:Browse1.table_get() 
    blobCurrent = tbl.record_data_get(RecNumBlob)
    
    If blobPrev == blobCurrent then
        parentform.cancel(.T.)
    Else
    	ui_msg_box("Cancel Browse","Please ")
    	parentform:Browse1.cancel()'already asked at the above cancel
    	parentform:Browse1.allow_change(.F.)
    end if
    So this 2nd section of code gets the values that are currently stored for the record in question and then compares the two blobs/records to see if they are the same. This comparison always seem to equate to True. No matter what. I have even explicitly passed the record_data_get function different record numbers ( so blobPrev would get the values from record number 14 in the able, and blobCurrent would get the values from record 64 from the same table). Even doing this the blob vars still equate to true in the above code.

    This is my first time working with blob variables so maybe I have a misunderstanding. I am not sure.

  2. #2
    Alpha Software Employee AaronBBrown's Avatar
    Real Name
    Aaron Brown
    Join Date
    Feb 2001
    Location
    Waltham, MA
    Posts
    2,836

    Default

    I'm not sure what you are trying to accomplish with this comparison, but record_data_get() is designed to be used with record_data_set() to quickly copy an entire record of data, not to be used for comparisons. There are better ways to determine if the record changed.

    Generically, blob comparison works correctly, as in the following code:

    Code:
    DIM b AS B
    DIM b2 AS B
    
    b = file.to_blob("C:\foo.txt")
    b2 = file.to_blob("c:\was_timer.txt")
    
    ? b2=b
    = .F.
    
    b = file.to_blob("C:\foo.txt")
    b2 = file.to_blob("C:\foo.txt")
    
    ? b2=b
    = .T.
    Last edited by AaronBBrown; 04-13-2006 at 01:27 PM.
    [FONT=Tahoma][SIZE=1][COLOR=Blue]Aaron Brown
    Alpha Software Development Team[/COLOR][/SIZE][/FONT]

  3. #3
    Member
    Real Name
    Mike Monk
    Join Date
    Feb 2005
    Posts
    114

    Default

    Ok. Thanks for your time. I will look into other ways to accomplish the task.


    Thanks again,
    Mike

  4. #4
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default Re: "If blob1 = blob2 then" always evaluates to true.. can't figure out why

    Hi Aaron,

    Quote Originally Posted by AaronBBrown
    Generically, blob comparison works correctly...
    That's not quite correct. It does work OK for blobs that don't have a null (ASCII 0) in them, but fails if they do. A conversion to an ASCII format like uuencode and then comparing that, will work though.
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture



  5. #5
    Alpha Software Employee AaronBBrown's Avatar
    Real Name
    Aaron Brown
    Join Date
    Feb 2001
    Location
    Waltham, MA
    Posts
    2,836

    Default Re: "If blob1 = blob2 then" always evaluates to true.. can't figure out why

    Quote Originally Posted by csda1
    Hi Aaron,

    That's not quite correct. It does work OK for blobs that don't have a null (ASCII 0) in them, but fails if they do. A conversion to an ASCII format like uuencode and then comparing that, will work though.
    Ira, if this is true, please send it as a bug report.
    [FONT=Tahoma][SIZE=1][COLOR=Blue]Aaron Brown
    Alpha Software Development Team[/COLOR][/SIZE][/FONT]

Similar Threads

  1. Duplicating a "Parent" record complete with "Children"
    By Peterg in forum Alpha Five Version 7
    Replies: 4
    Last Post: 02-23-2006, 10:40 AM
  2. Setting a logical field to "true"
    By Paul Grainger in forum Alpha Five Version 4
    Replies: 2
    Last Post: 03-08-2004, 09:27 AM
  3. Previous not "locked" to "Auto"
    By Richard Froncek in forum Alpha Five Version 5
    Replies: 2
    Last Post: 03-05-2003, 01:03 PM
  4. "Unable to add key to tag" and "hea
    By Noble Bell in forum Alpha Five Version 4
    Replies: 2
    Last Post: 05-12-2000, 09:16 AM

Bookmarks

Posting Permissions

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