[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2831.0. "Confusion/Problem with DwtListBoxItemExists" by NITMOI::WITHERS (Another Hallmark Moment. -Al Bundy) Tue May 29 1990 12:03

    Hello.  I am trying to code a simple List Box that can be added to,
    deleted from and is finally accepted and processed.  Problem is that
    my logic for AddItem and DeleteItem rely on using the routine,
    DwtListBoxItemExists as below...
    
    	text_value = DwtSTextGetString (txtwid);
    	list_entry = DwtLatin1String (text_value);
    	item_exists = DwtListBoxItemExists (listwid,list_entry);
    	if (item_exists == TRUE)
    		DwtListBoxDeleteItem (listwid,list_entry);
    	else
    		Panic ("Item doesn't exist in list");
    
    The problem is that only the first item in the list ever returns as
    true to allow itself to be deleted.  The same logic inverted to see
    if an item already exists to disallow duplicates works fine.  Am I 
    doing something wrong and, if so what?
    
    Thanks for any help,
    George
    
    
T.RTitleUserPersonal
Name
DateLines
2831.1DwtListBoxItemExists returns the position, not a booleanR2ME2::VANGILDERJim V., DECwindows ToolkitsTue May 29 1990 20:0016
>
>    	item_exists = DwtListBoxItemExists (listwid,list_entry);
>    	if (item_exists == TRUE)
>    		DwtListBoxDeleteItem (listwid,list_entry);
>    	else
>    		Panic ("Item doesn't exist in list");


DwtListBoxItemExists returns the position of the item in the list
(or 0 if not found).  You are then comparing that position to TRUE
(whose value is 1), so you'll only get a match on the first item.
Change the if to:

	if (item_exists > 0)