a sequence-length Variable killed

new topic     » topic index » view thread      » older message » newer message

Hi Derek,
Hi Rob,

I guess you should know a bug emerging from the Deselect_ListView( ) 
routine, that Derek kindly sent to me some time ago; it easy to escape it, 
but I mention this as, dealing with the Length value of a variable 
unexpectedly set to zero, it may be a problem interesting either 
Euphoria or win32lib.

The routine was:
procedure Deselect_ListView(integer id)
-- deselect all LV items 
    object VOID, CNT, LV_ITEM

    VOID = sendMessage(id, LVM_SETHOTITEM, -1, 0)
    CNT = sendMessage(id, LVM_GETITEMCOUNT, 0, 0) - 1
    LV_ITEM = w32acquire_mem(0,  SIZEOF_LVITEM )
    w32store( LV_ITEM, LVITEM_mask, LVIF_STATE )
    w32store( LV_ITEM, LVITEM_stateMask, LVIS_SELECTED )
    for i = 0 to CNT do
       w32store( LV_ITEM, LVITEM_iItem, i)
       VOID = sendMessage(id, LVM_SETITEM, 0, LV_ITEM )
    end for
    w32release_mem(LV_ITEM)

end procedure

 
that I have adapted, adding the ( , sequence lst ) parm.
--- ========= thanks to Derek Parnell
global procedure Deselect_ListView( integer id, sequence lst)
-- deselect all items
object CNT, LV_ITEM

    VOID = sendMessage(id, LVM_SETHOTITEM, -1, 0)
    LV_ITEM = acquire_mem(0,  SIZEOF_LVITEM )
    store( LV_ITEM, LVITEM_mask, LVIF_STATE )
    store( LV_ITEM, LVITEM_stateMask, LVIS_SELECTED )

    if length( lst) then
     for i = 0 to length( lst) -1 do
        store( LV_ITEM, LVITEM_iItem, lst[i+1] -1)
        VOID = sendMessage(id, LVM_SETITEM, 0, LV_ITEM )
     end for
    else
     CNT = sendMessage(id, LVM_GETITEMCOUNT, 0, 0) - 1
     for i = 0 to CNT do
        store( LV_ITEM, LVITEM_iItem, i)
        VOID = sendMessage(id, LVM_SETITEM, 0, LV_ITEM )
     end for
    end if
    release_mem(LV_ITEM)

end procedure

I have now 153 files in list:
selFiles = getLVSelected( LV)
 VList_Files = length( selFiles)
 x = VList_Files

  Deselect_ListView( LV, selFiles)
? { x, VList_Files }

result:
{153, 0}

The VList_Files is a global variable, called LV_files  before, 
changed then for the suspect the LV_ could make it a reserved word.

However the VList_Files value is cleared by the Deselect_ListView( ).
It seems that the length( lst) used by the routine, connected with the 
 VList_Files variable although indirectly, goes to change that one somehow. 
By the Trace( ) I could observe its value = 0 after the
 for i = 0 to length( lst) -1 do .. end for.
Nothing else happens between these instructions.
Hope this can help.

Antonio

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu