PDA

View Full Version : Apparent bug in Listbox



Blypht
08-05-2004, 11:34 PM
I came across what appears to be a bug with listboxes. If I'm just doing a dumb, somebody please let me know how to fix this.

My intention is to keep the user in the requester if he/she clicks on the Ok button while settings on the requester are incomplete.

This involves returning from the reqpost() function, checking to see if processing should proceed, or if the requester should be repost()-ed.

Each time the requester is reposted, the entries in the listbox replicate, though the source array remains correct.

Below is a sample program to demonstrate the problem (click on Ok to see the repost-related replication in the listbox).

Thanks in advance for any help.

// Listbox Bug Demo
//
// Created: 2004-08-05, Bruce F. Thatcher

@version 2.2
@warnings
@script generic
@name "Listbox Bug Demo"

// Constants
@define ID_VER "Listbox Bug Demo v1.00"

// Global variables
arrList_name;

generic
{
// Initialize
arrList_name = @ "A","B","C","D","E","F" @;

reqbegin(ID_VER);

clsList = ctllistbox("List (A-F)",200,200,"clsList_count","clsList_name");

// Loop until cancel is pressed
booDone = false;
while (!booDone)
{
if (reqpost())
{
warn("Check for duplicates in listbox. Press Cancel to see actual counts & content.");
}
else
booDone = true;
}

// Output final count in listbox
info("clsList_count() = ",clsList_count());

// Output final content of listbox array
strFinal = format("arrList_name: count = $1",arrList_name.count());
for (i = 1; i <= arrList_name.count(); i++)
strFinal = format("$1; $2",strFinal,arrList_name[i]);
info(strFinal);

reqend();
}

clsList_count
{
return(arrList_name.count());
}

clsList_name: Index
{
return(arrList_name[Index]);
}

#lwrs_web
08-07-2004, 04:17 PM
confirmed (LW8.0)

I did a quick hack that seems to work:

see lines with //!!



// Listbox Bug Demo
//
// Created: 2004-08-05, Bruce F. Thatcher

@version 2.2
@warnings
@script generic
@name "Listbox Bug Demo"

// Constants
@define ID_VER "Listbox Bug Demo v1.00"

// Global variables
arrList_name;

generic
{
// Initialize
reqbegin(ID_VER);

arrList_name = @ "A","B","C","D","E","F" @;

clsList = ctllistbox("List (A-F)",200,200,"clsList_count","clsList_name");
clsPopup = ctlpopup("List (A-F)", 1, "popup_expr_list");


// Loop until cancel is pressed
booDone = false;
while (!booDone)
{
if (reqpost())
{
arrList_name = nil; //!!
requpdate(); //!!
warn("Check for duplicates in listbox. Press Cancel to see actual counts & content.");
}
else
booDone = true;

arrList_name = @ "A","B","C","D","E","F" @; //!!

}
// Output final count in listbox
info("clsList_count() = ",clsList_count());

// Output final content of listbox array
strFinal = format("arrList_name: count = $1",arrList_name.count());
for (i = 1; i <= arrList_name.count(); i++)
strFinal = format("$1; $2",strFinal,arrList_name[i]);
info(strFinal);

reqend();
}

clsList_count
{
return(arrList_name.count());
}

clsList_name: Index
{
return(arrList_name[Index]);
}

popup_expr_list
{
return(arrList_name);
}