I am making a school related project that requires you to make an app with a list handling complex data, however I am struggling heavily with the creation of the "delete item" button, as each item on the list is an event, containing a name, place, and time, and im not sure how to make it so the user can search for an event on the list, and delete that specific event. If someone wouldn't mind helping, that'd be great.
Post a project example, link, or screenshot:
Hi, welcome to the forums!
There are a few problems here: The first one is that the 'answer' reporter only reports the last given answer, so if you ask 3 questions and the answers are 'foo', 'bar' and 'baz', the block would only report baz. Second, the delete block takes a number as input. Instead of searching for names, it searches for whichever item number you choose. For example, in the list [2 3 5], the second item is 3, so if you told it do delete #2 of the list, the list will turn into [2 5]. In the image, you're giving it a text string as input, not a number, so it defaults to 0 and deletes the 0th item of the list, which.. doesn't change the list at all.
But then, you may be wondering, how do you get an item's number only from its name? Luckily, there's a primitive for that. It also works with lists, which will be useful for this example.
You need to put this script right before the main one:
This is done to avoid asking the same question twice and potentially messing up the script by getting different answers each time.
Then, replace all instances of the 'Ask name'/'Ask time'/'Ask place' blocks with the name, time and place variables respectively, and replace the current delete block's code with this:
Wow, a detective story. Beautifully written. I enjoyed reading your explanations and learned something new. Thank you, helicoptur.
Is there a story behind you purposefully misspelled username? If there is, I'd like to hear it.
Not really. A few years ago (before I knew Snap existed) I wanted the username "helicopter", but that was taken, so I changed around random vowels until finally it wasn't taken and I got my current default username.
One of the side effects of having a username like this is that, whenever I try to write the word "helicopter", I'll write "helicoptur" instead, having seen the spelling of the latter more often.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.