sub removeData { my ($client,$dbh,$dlg,$list,$label,$err) = @_; #Get a list of tapeID values for a client my @tapes = getTapes($client,$dbh); #Create a DialogBox $dlg->configure(-title=>"Delete tape for: ".$$client); #small values just to test; $list->configure(-height=>5,-width=>5); #Configure the button text $dlg->Subwidget('B_1')->configure(-text=>'Delete'); $dlg->Subwidget('B_0')->configure(-text=>'Cancel'); #Insert the tape numbers $list->insert('end',$_) for @tapes; $list->pack(); #Show the remove dialog and save the return value my $show_value = $dlg->Show(); #If the user chose Delete and selected an item from the listbox if($show_value && ($list->curselection())) { #Retrieve the item selected my $num = $list->get($list->curselection()); #reinit the listbox initList($list); #Reconfigure the dialog title $dlg->configure(-title=>'Delete Confirmation!'); #Reconfigure the dialog button text $dlg->Subwidget('B_1')->configure(-text=>'Yes'); $dlg->Subwidget('B_0')->configure(-text=>'No'); #Configure and pack the label $label->configure(-text=>"Tape:".$num." will be deleted. Are you sure?"); $label->pack(); #On Yes if($dlg->Show()) { #Attempt a tape delete and store the success value in $success my $success = deleteTape($client,\$num,$dbh); #Reconfigure the title of the dialog $dlg->configure(-title=>'Removal Status'); #Reconfigure the label's text based on the value of $success $label->configure(-text=>($success? 'Tape removed successfully!': 'Error during removal, tape not removed!')); #Remove the 2nd button $dlg->Subwidget('B_0')->packForget(); #Reconfigure the text on the 1st button $dlg->Subwidget('B_1')->configure(-text=>'OK'); #Show the dialog $dlg->Show(); } } #If the user chose Delete and did not select and item from the listbox elsif($show_value && !$list->curselection()) { #reinit the listbox initList($list); #Configure and pack the label $label->configure(-text=>'Select a tape number!'); $label->pack(); #Reconfigure the title of the dialog $dlg->configure(-title=>'Error!'); #Remove the 2nd button $dlg->Subwidget('B_0')->packForget(); #Reconfigure the text on the 1st button $dlg->Subwidget('B_1')->configure(-text=>'OK'); #Show the dialog $dlg->Show(); } #If the user clicks Cancel else { #reinit the listbox initList($list); #Make a new label $label->configure(-text=>'Data Removal Aborted Successfully.'); $label->pack(); #Reconfigure the title of the dialog $dlg->configure(-title=>'Abort!'); #Remove the 2nd button $dlg->Subwidget('B_0')->packForget(); #Reconfigure the text on the 1st button $dlg->Subwidget('B_1')->configure(-text=>'OK'); #Show the dialog $dlg->Show(); } initLabel($label); initDialog($dlg); return; }