Error checker thing that i made in my quest

So basically, in my ultimate quest to make a login user interface and what not, I had to jump a hurdle in which I needed to check to see if a variable was already taken up, ie. a user is making a username but that username has already been taken. The funny thing, is, that Snap! throws an error if it can’t find a variable, or if it doesn’t exist (as it should), so I had to make a work-around:
image

This creation of mine will compare input A and B, and as you can tell, if that throws an error for whatever reason, it will return true, and that will be compared to false.

My use of this was:
name checker script pic (8)

This will take the answer from a previous subject, and essentially check to see if it is set to a variable (which follows the previous formatting that I use for my vars) and if that variable already exists, it will tell an if statement to execute whats in the if body. If that variable does not exist, or the username has not been used yet, it will let the else body run, letting the username be created.

My whole project looks a little something like this:

If you need/want too, feel free to use this however you want!

Instead of doing <(safely try reporting <(answer)=(var(join[USERNAME ](answer))::variables)>then if (error) report <<true>>::control)=<<false>>>, you could just do <not(safely try reporting <(answer)=(var(join[USERNAME ](answer))::variables)>then if (error) report <<true>>::control)>.

Or even better, you could do Even better script

You should be able to drag the last image into the editor to get the blocks

lwky forgot does var exist

By the way you should also post the link to your project so we can see when you update it or anything

how

You share the project. Btw, just sharing creates a shareable link, but publishing allows people to find it on the snap website.

To share a project, click file image > open then search for your project, click on it, then click on share. The url should be updated, so just copy and paste that.


On your code, I suggest you avoid using the create variables library (where the (var [ v] :: variables) block came from), because it can mess with things. You should instead create a variable and set it to something like this

untitled script pic

This will allow you to get the user data like this
untitled script pic (1)

And checking if a username exists is very easy, because if a username doesn’t exist, it just returns an empty string

untitled script pic (2)

Using lists/maps is just generally better because you can do more stuff with them, and they’re designed for purposes like this.

Ty for telling me how to share

I know that using lists would probably be better, but tbh the concept of a list is for some reason foreign to my mind. It’s hard for me to not have everything defined, I guess because to me it just makes more sense to have something stored as a var, probably because I never really liked using arrays in js. Ty for telling me tho.

Don’t worry, lists seemed scary to me too at first! The more you experiment with lists, the more you will get used to them and the better you will get!

I mean you can just do setting a variable to a list and store the list inside a variable

Why don’t you practice about lists?

Off-topic!

Make sure you wrap in the [details][/details] tag when you post contents which are far from this topic.

  1. Click on the edit button after you click the three dots located at the bottom right of the post.

  2. Switch to Markdown mode at the top left of the post contents editor. This will make you format with Markdown.

    There is also a rich text control toolbar, so you can edit contents of the post without learning the Markdown syntax.

  3. Wrap your entire contents of your entire contents by the [details][/details] tag. The steps are:

    1. Insert [details="Off-topic"] and a new line at the start of your post.
    2. Append a new line and [/details] at the end of your post.
    3. The resulting content would look like this:
      [details="Off-topic"]
      ...
      [/details]
      
  4. Press ‘Save changes’. This will edit your posts directly.

I wouldn’t really call his emoji far from the topic because he is reacting to something that is on topic

I’ll probably just wait for my teach to cover it so I can get a better understanding of it

I have finally made an alpha/beta/sigma/omega version of that thing i was doing for fun earlier, but I’ve run into a bit of an artist’s block and I need some big brain ideas.
This is what I have so far: Snap! Build Your Own Blocks

Really just give me anything, particularly things that would be harder for me to do. I did make a data-storage thing, so more app-like things would be interesting. I considered making a built-in mp3 player but my browser started to croak when I added a gig of files into it.