Discuss Scratch

RedBigz
Scratcher
30 posts

Detect if a letter is uppercase

I am writing a hex program and when i convert “paul” to hex it returns as 5041554c when it should return as 7061756c.
Converted, 5041554c outputs PAUL instead of paul because a=A is true. how do i detect if a letter is uppercase?
fdreerf
Scratcher
1000+ posts

Detect if a letter is uppercase

<[a] > [A]> 
This works for all capital letters.
Just replace the capital A with the letter in question.
nolbarry
Scratcher
100+ posts

Detect if a letter is uppercase

fdreerf wrote:

<[a] > [A]> 
This works for all capital letters.
Just replace the capital A with the letter in question.
What exactly is that supposed to do? Returns false for me no matter the order because a = A in Scratch's arithmetic.

@OP costumes are case sensitive. If you have a costume named “a”, then
switch costume to (join [A] [])
will NOT work. You can use this to detect if a letter is capital by having 26 costumes, all named a different capital letter, plus a bonus costume named anything but a letter.
switch costume to [default v]
switch costume to (letter (x) of (string))
if <(costume [name v] :: looks) = [default]> then
... // letter is lowercase
else
... // letter is uppercase
end

It's tedious but it's the best we got.

Last edited by nolbarry (May 6, 2020 06:00:06)

Maximouse
Scratcher
1000+ posts

Detect if a letter is uppercase

You can find a ready-made custom block for case-sensitive comparsion here. It's used like this:
[a] = [a] \(case sensitive\) :: custom
say (result) // true
[a] = [A] \(case sensitive\) :: custom
say (result) // false
fdreerf
Scratcher
1000+ posts

Detect if a letter is uppercase

nolbarry wrote:

fdreerf wrote:

<[a] > [A]> 
This works for all capital letters.
Just replace the capital A with the letter in question.
What exactly is that supposed to do? Returns false for me no matter the order because a = A in Scratch's arithmetic.
Huh, I tested it, but I might've gotten the results from other things.

Powered by DjangoBB