Re: Need A Quick Fix
- Posted by Senator Nov 04, 2019
- 1396 views
Icy_Viking said...
Hey Guys,
Every time I try to remove a selected item from a listbox, my program crashes.
sequence nesgames = {"Contra","Ducktales","Super Mario Bros.","Super Mario Bros. 2","Super Mario Bros. 3", "Zelda 2: Link's Adventure"} procedure Add_Game(integer self,integer event, sequence parm) addItem(Game_List,nesgames) end procedure setHandler(Game_List_Add,w32HClick,routine_id("Add_Game")) procedure Remove_Game(integer self, integer event, sequence parm) for i = 0 to length(nesgames) do if i >= 0 then deleteItem(Game_List,nesgames[i]) --somewhere here causes it to crash end if end for end procedure setHandler(Game_List_Remove,w32HClick,routine_id("Remove_Game"))
I'll take a stab at this:
If i = 0 then there is no element in the sequence nesgames to delete from Game_List.
If your click/selection routine returns a value based on the first item in the selection list having an index value 0f 0, then you will need to add 1 to that value to reference the index the item in the nesgames sequence you want to delete. Not sure why you would need a loop or a special DeleteItem routine to do that though, it seems Game_List = remove_item(Game_List,nesgames[i+ClickValue]) should suffice.
I probably shouldn't have tried to offer a solution, since I do not know how the Windows GUI works.