Discuss Scratch

Lataliat
Scratcher
100+ posts

Is Letter, Number, or Symbol Block

No support. I've used a workaround for this many times:

Do this
add [1] to [list v]

And then use
<[list v] contains [answer] ?>

All it requires,,, is being creative
Sheep_maker
Scratcher
1000+ posts

Is Letter, Number, or Symbol Block

Lataliat wrote:

No support. I've used a workaround for this many times:

Do this
add [1] to [list v]

And then use
<[list v] contains [answer] ?>

All it requires,,, is being creative
In case you haven't read the rest of the discussion:

fyromaniac1 wrote:

turkey3 wrote:

You can have each symbol in a list (I.e. Numbers) and check of the list contains the symbol, so I don't support.
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.
Lataliat
Scratcher
100+ posts

Is Letter, Number, or Symbol Block

fyromaniac1 wrote:

turkey3 wrote:

You can have each symbol in a list (I.e. Numbers) and check of the list contains the symbol, so I don't support.
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 copy and paste the symbols as a string, and ‘extract’ them from that.

Yes, but we use a finite amount of symbols to represent an infinite amount of combinations aka numbers, lol:
<[list v] contains (letter (1) of [number]) ?>
You would need to, of course, add - and . to the list as well, if you wish to account for negatives and decimals.

(EDITED for typos. OH and I realize, this got necroposted!! )

Last edited by Lataliat (Nov. 17, 2016 02:58:55)

CodingJam
Scratcher
17 posts

Is Letter, Number, or Symbol Block

Griffenlover wrote:

CodingJam wrote:

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
please dont necropost, the last post was 2 years ago
Sorry!

Last edited by CodingJam (Dec. 28, 2022 09:43:49)

dude341
Scratcher
1000+ posts

Is Letter, Number, or Symbol Block

CodingJam wrote:

Griffenlover wrote:

CodingJam wrote:

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
please dont necropost, the last post was 2 years ago
Sorry!
Necroposting is allowed in the Suggestions forum.
aaronsacks2006
Scratcher
65 posts

Is Letter, Number, or Symbol Block

Griffenlover wrote:

CodingJam wrote:

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
please dont necropost, the last post was 2 years ago
I don't care I still suport!
Flipped_
Scratcher
500+ posts

Is Letter, Number, or Symbol Block

Griffenlover wrote:

please dont necropost, the last post was 2 years ago

I don't think there is necroposting in Suggestions, really.
StrangeMagic32
Scratcher
1000+ posts

Is Letter, Number, or Symbol Block

Flipped_ wrote:

Griffenlover wrote:

please dont necropost, the last post was 2 years ago

I don't think there is necroposting in Suggestions, really.
Unless said suggestion is Rejected, or a Duplicate

OP,
if <((answer) * (1)) = (answer)> then 
is number::grey
else
is letter or symbol::grey
end

Last edited by StrangeMagic32 (Feb. 22, 2019 00:32:19)

dude341
Scratcher
1000+ posts

Is Letter, Number, or Symbol Block

StrangeMagic32 wrote:

Flipped_ wrote:

Griffenlover wrote:

please dont necropost, the last post was 2 years ago

I don't think there is necroposting in Suggestions, really.
Unless said suggestion is Rejected, or a Duplicate

OP,
if <((answer) * (1)) = (answer)> then 
is number::grey
else
is letter or symbol::grey
end
You still can't find out whether something is a symbol or a letter though.
Plus, this workaround is not intuitive - a new scratcher would never guess this, as it relies on the way Scratch internally works and interprets strings and numbers. That behaviour could also easily change within an update, so the workaround is unreliable.
StrangeMagic32
Scratcher
1000+ posts

Is Letter, Number, or Symbol Block

dude341 wrote:

StrangeMagic32 wrote:

OP,
if <((answer) * (1)) = (answer)> then 
is number::grey
else
is letter or symbol::grey
end
You still can't find out whether something is a symbol or a letter though.
Plus, this workaround is not intuitive - a new scratcher would never guess this, as it relies on the way Scratch internally works and interprets strings and numbers. That behaviour could also easily change within an update, so the workaround is unreliable.
True that.
ninjaMAR
Scratcher
1000+ posts

Is Letter, Number, or Symbol Block

support could use this a lot
this is not a necropost because this is the suggestions forum
-Exphire-
Scratcher
1000+ posts

Is Letter, Number, or Symbol Block

support! this is because it would be hard for many new scratchers to understand how to detect numbers, and how do I detect symbols or letters? Here is one more use: you want to make an OS with a keyboard on the screen, and to bring up each category the player has to type a symbol in the category.
MyRioName
Scratcher
100+ posts

Is Letter, Number, or Symbol Block

There are workarounds, but lets put it in the sticky about workarounds so people don't ask this again
I am not sure of any workarounds currently.
scratch978654
Scratcher
100+ posts

Is Letter, Number, or Symbol Block

fyromaniac1 wrote:

Ever had a project that had to use only numbers/letters/symbols? You might have to do something like this:
when flag clicked
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.
Well, a good suggestion would be to have a block that detects if the string is a number, symbol, or letter, Like this!
([] is [number v])
([] is [letter v])
([] is [symbol v])
Here is an example of the new block in action:
When clicked
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
So basically, It is a Reporter block that would most likely be in the |Sensing| Section of the Block Palette.
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!
Semi support, workaround:

if <([abs v] of (answer)) > [0]> then 
Say number


else
Say string
end
Seth_Zaw
Scratcher
100+ posts

Is Letter, Number, or Symbol Block

Workaround:
<((x)+(0))= (x)> // is a number

Last edited by Seth_Zaw (June 23, 2020 19:36:50)

BosenChang
Scratcher
1000+ posts

Is Letter, Number, or Symbol Block

this is not a workaround:
when green flag clicked
number or letter::custom
define number or letter
forever
set [letter v] to [a]
set [letter v] to [b]
set [letter v] to [c]
set [letter v] to [d]
...
end
ask [type in a number.] and wait
if <(answer) = <[a] or <[b] or <[c] or <...>>>> then
say [that is not a number.]
else
say [that is a number!]
end
I see problem. Users could type in “…”

Last edited by BosenChang (June 23, 2020 19:48:38)

mlcreater
Scratcher
1000+ posts

Is Letter, Number, or Symbol Block

“Letter” is ambiguous because: is ‘å’ a letter? Is ‘θ’ a letter? They are, but many projects might only expect the letters abcdefghijklmnopqrstuvwxyz to return true in a "is [] a [letter v]“ block.

”Number“ is ambiguous because: is ‘Γ’ a number? Is ‘४’ a number? They are (representing three and four), but most projects might only expect the digits 0123456789 to return true in a ”is [] a [number v]“ block.

”Symbol" is ambiguous because: is ‘¢’ a symbol? Is ‘∂’ a symbol? They are (cent and partial differential), but in Requests, they can be used as letters (see the nougat shoppe and the nature shop).
modesties
Scratcher
100+ posts

Is Letter, Number, or Symbol Block

scratch978654 wrote:

fyromaniac1 wrote:

Ever had a project that had to use only numbers/letters/symbols? You might have to do something like this:
when flag clicked
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.
Well, a good suggestion would be to have a block that detects if the string is a number, symbol, or letter, Like this!
([] is [number v])
([] is [letter v])
([] is [symbol v])
Here is an example of the new block in action:
When clicked
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
So basically, It is a Reporter block that would most likely be in the |Sensing| Section of the Block Palette.
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!
Semi support, workaround:

if <([abs v] of (answer)) > [0]> then 
Say number


else
Say string
end
0:
why are we still here
just to suffer
every night
anyway mockups:
<is () a [number v]? ::operators>
<is () a [string v]? ::operators>
<is () a [letter/sound v]? ::operators>
<is () a [positive v] ::operators>
<is () a [negative v] ::operators>
<is () a [decimal v] ::operators>
<is () a [zero v] ::operators>
<is () a [negative integer v] ::operators>
<is () a [integer v] ::operators>
<is () a [whole v] ::operators>
<is () a [natural v] ::operators>
workaround for the number:
define is (input) a number
if <((input) * (1)) = (input)> then
set [result v] to [true]
else
set [result v] to [false]
end
workaround for string:
define is (input) a string
if <((input) * (1)) = (input)> then
set [result v] to [false]
else
set [result v] to [true]
end

workaround for letter/sound:
define is (input) a letter/sound
is (input) a string ::custom block
if <<(result) = [true]> and <(length of (input)) = [1]>> then
stop [this script v]
end
set [result v] to [false]

Last edited by modesties (Oct. 10, 2021 22:39:55)

Reev0102
Scratcher
1000+ posts

Is Letter, Number, or Symbol Block

((foo) / (1)) = (foo) // if this is true, it's a number. If it's false, it's a letter or symbol.
Multi-Coders
Scratcher
5 posts

Is Letter, Number, or Symbol Block

I definitely support this. Yes, you could add numbers to a list, and use the answer block, but that looks un-professional. I use number keys to pick choices, and that DOESN'T use the answer block.

Last edited by Multi-Coders (Dec. 7, 2022 00:24:38)

Powered by DjangoBB