This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-02-28 12:36:48

molkemon
New Scratcher
Registered: 2013-02-28
Posts: 5

Scratch doesn't respect upper and lowercase :/

I am trying to build an ascii-char to binary converter.

A sprite asks the user for a character to convert (currently, I only want it to convert 1 character) and I want it to accept 0-9, a-z and A-Z.

First, depending on the answer, the decimal number for that character is stored in a variable which then is later passed to the scripts that display the binary equivalent of said character/decimal. The display binary part is working without flaw, but I ran into a serious problem when I parse the answer to get the decimal number for that character:

Scratch does not care if an answer is lower or uppercase.

It looks like this:

if answer = 8 then asciidecimalvariable = 56
if answer = 9 then asciidecimalvariable = 57
if answer = A then asciidecimalvariable = 65
if answer = a then asciidecimalvariable = 97

But no matter if I answer A or a, the variable will always get filled with 97 (scratch does not check if it's uppercase or not). Is there a way I can make this work?

Offline

 

#2 2013-02-28 12:49:23

firedrake969_test
Scratcher
Registered: 2012-08-08
Posts: 500+

Re: Scratch doesn't respect upper and lowercase :/

You can ask capital of lowercase?
if capital set letter to A
else set letter to a


Alt of Firedrake969.

Offline

 

#3 2013-02-28 12:58:53

BLU_Spy
Scratcher
Registered: 2012-01-05
Posts: 1000+

Re: Scratch doesn't respect upper and lowercase :/

@firedrake You mean this?

if <(capital) = [1]>
set [letter v] to [A]
else
set [letter v] to [a]
I don't know if that would work, but... Whatever.  hmm


I HAVE SWITCHED ACCOUNTS! My new username is NoxSpooth.

Offline

 

#4 2013-02-28 13:13:04

molkemon
New Scratcher
Registered: 2013-02-28
Posts: 5

Re: Scratch doesn't respect upper and lowercase :/

I'd rather avoid to have to specificially ask the user if his answer is upper or lowercase. But I might have found something that may work in the wiki, I'm not sure though if I can implement it properly.

Offline

 

#5 2013-02-28 13:29:48

molkemon
New Scratcher
Registered: 2013-02-28
Posts: 5

Re: Scratch doesn't respect upper and lowercase :/

Ok, i got around the problem using a list for lower case letters, apparently when comparing an answer to a list, lower and uppercase DOES get respected.

So now i first add all lower case letters to a list like

add a to <lowercaselist>
add b to <lowercaselist>

etc

then, as before I have

if answer = A then asciidecimalvariable = 65
if answer = B then asciidecimalvariable = 66
...
if answer = Z then asciidecimalvariable = 90

and now I check if the answer is part of the lowercaselist which would mean that the answer actually was in lowercase.

if lowercaselist contains answer then asciidecimalvariable = asciidecimalvariable + 32

I hope this helps anyone who might run into a similar problem.

Offline

 

#6 2013-02-28 16:04:10

mathfreak231
Scratcher
Registered: 2012-10-24
Posts: 80

Re: Scratch doesn't respect upper and lowercase :/


~This sig is false~
I'm on teh wiki!

Offline

 

#7 2013-02-28 16:09:00

molkemon
New Scratcher
Registered: 2013-02-28
Posts: 5

Re: Scratch doesn't respect upper and lowercase :/

Yeah I basically implemented this. It is somewhat working now (I finnished and uploaded the project, you can check it out here: http://scratch.mit.edu/projects/molkemon/3138922

However, even with the workaround, it does NOT work with the flash player version. It does work correctly though with the java player or if you download the project. I have reported this as a bug.

Offline

 

Board footer