Bug(?) with numbers, input, and strings

But only if you force it yourself…

3 Likes

What…

3 Likes

That’s what my mind says time to time…

3 Likes

What…

2 Likes

But I am using the length variable so yeah I don’t know if it would work

1 Like

It doesn’t. The length is automatically set right after you hit “OK”.

2 Likes

Not if you have a zero before the number because that will not work if you store it in a variable

2 Likes

That’s exactly what happens…

1 Like

why not add a letter to the start of the save input just so the 0 appears?

then disregard the letter when counting the savecode

2 Likes

Still does not work…

1 Like

link?

1 Like

1 Like

I don’t have a link… if you were asking ExplodingDucks for it, make sure you tag her first…

1 Like

then how do you know it doesn’t work?

2 Likes

I tested it in a draft…

1 Like

Try setting text to input. You could also add something before it to make it not be a number.

I believe that the webplayer (at least 1.5.4) uses this regular expression to check if it is a number, so as long as it does not match this (you can do this in hopscotch with the matches block) you don’t have a number. /^\-?[0-9]+(e\+?[0-9]+)?(\.[0-9]+(e\+?[0-9]+)?)?$/

Regular expressions are really cool, and, if you want to remove a number from a variable, but not a string, In string, replace something with something and the regular expression above would work.

2 Likes

@ExplodingDucks here is a working example. Only thing it can’t do is actually read the zeroes, it just has to assume there are leading zeroes.

3 Likes

Wish there was markdown so you can add a reverse letter…

2 Likes

That sounds so frustrating! I think your gonna just have to set the passcode to not begin in 0, though. Only way to ‘fix’ it.

2 Likes

Yep, unless you make a Hopscotch version of a keyboard, where the first letter/number tapped would automatically add a symbol to make sure the 0 got inputted…

1 Like