Discuss Scratch
- fyromaniac1
-
100+ posts
Is Letter, Number, or Symbol Block
Ever had a project that had to use only numbers/letters/symbols? You might have to do something like this:
If you say:
This is my Idea, and please follow this Topic, and support!
when flag clickedWell, a good suggestion would be to have a block that detects if the string is a number, symbol, or letter, Like this!
forever
if <(answer) = (1)
end
if <(answer) = (2)
end
if <(answer) = (3)
end
if <(answer) = (4)
end
if <(answer) = (5)
end
if <(answer) = (6)
end
etc.
([] is [number v])Here is an example of the new block in action:
([] is [letter v])
([] is [symbol v])
When clickedSo basically, It is a Reporter block that would most likely be in the |Sensing| Section of the Block Palette.
ask [give me a number!] and wait
if <(answer) is [number v]> then
say [That's a cool number!]
else
say [Not a number :(]
end
If you say:
say ((3) is [number v)then it will come out saying “True”.
This is my Idea, and please follow this Topic, and support!
Last edited by fyromaniac1 (Nov. 16, 2013 01:20:46)
- turkey3_test
-
1000+ posts
Is Letter, Number, or Symbol Block
You can have each symbol in a list (I.e. Numbers) and check of the list contains the symbol, so I don't support.
- fyromaniac1
-
100+ posts
Is Letter, Number, or Symbol Block
Well, the list can't have every number/symbol because first of all, there are TONS of symbols and an infinite number of numbers, so that list would be pretty long. You can have each symbol in a list (I.e. Numbers) and check of the list contains the symbol, so I don't support.
- ProdigyZeta7
-
1000+ posts
Is Letter, Number, or Symbol Block
Yeah, but think about all the letters with You can have each symbol in a list (I.e. Numbers) and check of the list contains the symbol, so I don't support.diacritics…
I'm supporting because I hate using alt + #### to make symbols in lists to detect the type of string.
- mobluse
-
100+ posts
Is Letter, Number, or Symbol Block
This is already possible:
This solution comes from http://mv.ezproxy.com.ezproxyberklee.flo.org/wiki/String#String_or_Number.3F
But I used De Morgan's laws to change it from “isString” to “isNumber”.
It would be better if procedures could return a value, i.e. one should have functions. To have a lot of new boolean functions would clutter the GUI for beginners – especially when this could be solved by a general solution (i.e. functions).
No support!
if <<(answer) = [0]> or <not <((answer) + (1)) = [1]>>> then
say [is number] for (2) secs
else
say [is string] for (2) secs
end
This solution comes from http://mv.ezproxy.com.ezproxyberklee.flo.org/wiki/String#String_or_Number.3F
But I used De Morgan's laws to change it from “isString” to “isNumber”.
It would be better if procedures could return a value, i.e. one should have functions. To have a lot of new boolean functions would clutter the GUI for beginners – especially when this could be solved by a general solution (i.e. functions).
No support!
- Rumanti
-
1000+ posts
Is Letter, Number, or Symbol Block
This is already possible:if <<(answer) = [0]> or <not <((answer) + (1)) = [1]>>> then
say [is number] for (2) secs
else
say [is string] for (2) secs
end
No support!
+1 Awesome. But what he suggests is pretty handy, and simple. New Scratchers could use it pretty quickly. So I support him too. +1
- 1234abcdcba4321
-
1000+ posts
Is Letter, Number, or Symbol Block
But you can already DO it!
(nah, why not.)
As a workaround for numbers, you could do
(nah, why not.)
As a workaround for numbers, you could do
if <<(...) < [9]> or <(...) > [-9]>> then
end
- cobraguy
-
1000+ posts
Is Letter, Number, or Symbol Block
Even after looking at the workarounds, I support! It would be faster than using the workarounds.
EDIT: Hold on, what would a mixture of number, letters, and symbols count as?
EDIT: Hold on, what would a mixture of number, letters, and symbols count as?
Last edited by cobraguy (Nov. 18, 2013 00:09:57)
- fyromaniac1
-
100+ posts
Is Letter, Number, or Symbol Block
Everything: !@#$%^&*()-=_+`~,./<>?;':"\{}| (Including Alt codes such as Alt 1)
Letters: ABCDEFGHIJKLMNOPQRSTUVUXYZ
Numbers 12345678910121314151617181920 etc. etc. etc.
Letters: ABCDEFGHIJKLMNOPQRSTUVUXYZ
Numbers 12345678910121314151617181920 etc. etc. etc.
- ProdigyZeta7
-
1000+ posts
Is Letter, Number, or Symbol Block
A string, duh. Hold on, what would a mixture of number, letters, and symbols count as?
- AonymousGuy
-
1000+ posts
Is Letter, Number, or Symbol Block
I support, although I can't think right now of a place I would need to use it…
Maybe in an input situation that required a number (such as a shop in an RPG game where you specify the amount of items)
Maybe in an input situation that required a number (such as a shop in an RPG game where you specify the amount of items)
- cobraguy
-
1000+ posts
Is Letter, Number, or Symbol Block
EDIT: Nevermind, I figured out how any problems could be fixed.A string, duh. Hold on, what would a mixture of number, letters, and symbols count as?
Last edited by cobraguy (Nov. 18, 2013 14:27:44)
- liam48D
-
1000+ posts
Is Letter, Number, or Symbol Block
This is great! But, I can't remember the last time ST added a real block, since 2.0. 
+1 Support!

+1 Support!
- jTron
-
100+ posts
Is Letter, Number, or Symbol Block
For the most part, I support. Other types of characters (or even word, etc.) could be added.
Also, a better workaround - put the options in a list and use the <[… v] contains [thing]> block.
Edit: already mentioned, never mind :)
Lastly, a protip: use
to change the type of block:
Also, a better workaround - put the options in a list and use the <[… v] contains [thing]> block.
Edit: already mentioned, never mind :)
Lastly, a protip: use
([] is [number v] :: operators)
([] is [number v] :: operators)
when this sprite clicked
if <(answer) is [number v] :: operators> then
... :: more
end
Last edited by jTron (March 10, 2014 18:22:50)
- educationiskey
-
1 post
Is Letter, Number, or Symbol Block
I totally agree. I have used workarounds, but this would be better. (Before I saw some of the scripts here, I was doing If Answer = 1 or Answer = 2 etc.
)

- stickfiregames
-
1000+ posts
Is Letter, Number, or Symbol Block
I definitely support a block for testing numbers (even though there is a workaround).
The problem with the letter one is you get into technicalities about what is and isn't a letter. For example:
Same for the symbol one, since it is basically “anything that is not a letter or number”.
The problem with the letter one is you get into technicalities about what is and isn't a letter. For example:
<[A] is a [letter v]? :: operators> // yesOf course, you could have “is a Latin letter” but that wouldn't be so useful in other languages.
<[Ж] is a [letter v]? :: operators> // yes
<[ݭ] is a [letter v]? :: operators> // yes
<[ス] is a [letter v]? :: operators> // technically it isn't, but it's used in the same way as one
<[人] is a [letter v]? :: operators> // even more ambiguous, since it represents a meaning not a sound, but is still used in writing
Same for the symbol one, since it is basically “anything that is not a letter or number”.
- CodingJam
-
17 posts
Is Letter, Number, or Symbol Block
This doesn't work 

Last edited by CodingJam (Dec. 28, 2022 09:43:19)
- Griffenlover
-
100 posts
Is Letter, Number, or Symbol Block
please dont necropost, the last post was 2 years ago You could make a sprite with loads of costumes all named:
Other
as the first costume
al
bl
cl
dl
for all the letters
:s
's
#s
,s
for all the symbols.
Then you could make a block called letter, number, or symbol which looks like:define letter, number, or symbol(char)
switch costume to [other v]
switch costume to (char)
if <(costume #) = [1]> then
set [type v] to [number]
end
if <(letter (length of (char)) of (char)) = [l]> then
set [type v] to [letter]
end
if <(letter (length of (char)) of (char)) = [s]> then
set [type v] to [symbol]
end