Discuss Scratch
- Discussion Forums
- » Suggestions
- » () includes [] ?
- AwesomeManJesse
-
Scratcher
48 posts
() includes [] ?
() includes [] ?::operators boolean
This would be really useful for something like a number input, to check whether it is a number or not. If there are multiple letters/numbers in the 2nd input, it would look for those characters next to each other, in that order. This would also be useful for something like a search function. If there's a workaround, tell me. Otherwise, Scratch Team, get on it!
Examples of uses:
Number Input:
<<(answer) includes [a] ?::operators boolean> or <(answer) includes [b] ?::operators boolean>>and so on.
Search Function:
if <(list :: list) includes (answer) ?::operators boolean> then
add (answer) to [Search Results v]
show list [Search Results v]
else
set [find-num v] to (length of (answer))
repeat (length of (answer))
if <(list :: list) includes (letter (find-num) of (answer)) ?::operators boolean> then
add (letter (find-num) of (answer)) to [Search Results v]
show list [Search Results v]
stop [this script v]
end
change [find-num v] by [-1]
end
end
This example isn't the best, cuz I haven't really put much thought into it… but you get the idea.
So, again, if there's a workaround, tell me. bai!
Last edited by AwesomeManJesse (Aug. 28, 2016 01:31:49)
- MasterJPixel
-
Scratcher
500+ posts
() includes [] ?
Triple support. It would save a lot of time when making projects.
- Candylanguagegirl
-
Scratcher
1000+ posts
() includes [] ?
Support, I think there's a workaround but this would be a ton easier.
- -SugarNSpice-
-
Scratcher
37 posts
() includes [] ?
Support. I've been looking for a block like this for a while now, the workaround (imao) is really complex. This would save time. 

Last edited by -SugarNSpice- (Aug. 27, 2016 17:18:33)
- Sheep_maker
-
Scratcher
1000+ posts
() includes [] ?
Maybe
(first occurrence of [cat] in [caterpillar]::operators) // 0 if not foundwhich reports the first character of the specified match?
- AwesomeManJesse
-
Scratcher
48 posts
() includes [] ?
MaybeWell, I would think the ‘first occurrence’ block would answer with a number which corresponds to which letter of the 2nd input is the first letter of the 1st input, So like this:(first occurrence of [cat] in [caterpillar]::operators) // 0 if not foundwhich reports the first character of the specified match?
(first occurrence of [a] in [zyxwvutsrqponmlkjihgfedcba]::operators) // 26
(first occurrence of [ab] in [ab]::operators) // 1
(first occurrence of [ab] in [super-lab]::operators) // 8
(first occurrence of [a] in [b]::operators) // 0
and, as you said, 0 if not found.
- raspykoo
-
Scratcher
1000+ posts
() includes [] ?
() includes [] ?::operators boolean
This would be really useful for something like a number input, to check whether it is a number or not. If there are multiple letters/numbers in the 2nd input, it would look for those characters next to each other, in that order. This would also be useful for something like a search function. If there's a workaround, tell me. Otherwise, Scratch Team, get on it!
Examples of uses:
Number Input:<<(answer) includes [a] ?::operators boolean> or <(answer) includes [b] ?::operators boolean>>and so on.
Search Function:if <(list :: list) includes (answer) ?::operators boolean> then
add (answer) to [Search Results v]
show list [Search Results v]
else
set [find-num v] to [1]
repeat (length of (answer))
if <(list :: list) includes (letter (find-num) of (answer)) ?::operators boolean> then
add (letter (find-num) of (answer)) to [Search Results v]
show list [Search Results v]
stop [this script v]
end
change [find-num v] by [1]
end
end
So, again, if there's a workaround, tell me. bai!
Support. This would be useful to easily program a search bar where you are looking for your username and high score on a project that has so many people that played it, like the example you just showed.
- LP_Play
-
Scratcher
1000+ posts
() includes [] ?
Support, although there is a workaround to the suggestion.
- Hypnotron
-
Scratcher
100+ posts
() includes [] ?
Semi-support, because I think there should just be a search function block that look like this:
(letter # of instance (1) of [o] in [foo] :: operators) // returns 2 (the first "o" is the 2nd letter)That way, if you were creating, let's say, a cloud game, you could search for a user by using the following script:
(letter # of instance (2) of [E] in [xxxExxxxE] :: operators) // returns 9 (the second "E" is the 9th letter)
(letter # of instance (1) of [hello] in [iewwasHELLOeudinifer] :: operators) // returns 7 (the first "HELLO" [b]STARTS[/b] at the 7th letter)
(letter # of instance (1) of [not in this text] in [this does not contain] :: operators) // returns 0
(letter # of instance (1) of (username :: sensing) in (cloud list :: list)::operators
- Hypnotron
-
Scratcher
100+ posts
() includes [] ?
Please do not quote the OP. It's considered spam.—————————————————————
Why is the first input a number?It's the number of the instance. For example, in the text “CxxxxCxxxxxxxCxxCxxxxx”, the block “letter # of instance 1 of C in text” would return 1, and the block “letter # of instance 1 of C in text” would return 6, since the 2nd "C' is the 6th litter.
- -Yugen-
-
Scratcher
56 posts
() includes [] ?
Isn't this essentially another
([] contains []::operators)block suggestion? I think it is. And that block has been disproved, so, sorry, it's not happening
- Discussion Forums
- » Suggestions
-
» () includes [] ?










