Discuss Scratch
- Discussion Forums
- » Suggestions
- » [ ] contains [ ]?
- AwesomePerson238243
-
Scratcher
100+ posts
[ ] contains [ ]?
I have a suggestion for a new block.
name: contains ?
category: sensing
type: Boolean
function: it would scan the first string to see if it contained the second strings input. if it did, it would come out true
block:
people who support (14):
Lythium
DownsGameClub
DaSpudLord
SpongyGames
pvz_pro
theonlygusti
Zekrom01
BurnedCrystal
sheep_maker
alexphan
Bookowl
Prscr
JonathanSchaffer
A-no-meep
Gooballs
people who don't support (0):
name: contains ?
category: sensing
type: Boolean
function: it would scan the first string to see if it contained the second strings input. if it did, it would come out true
block:
< [ ] contains [ ] ? :: sensing Boolean >
people who support (14):
Lythium
DownsGameClub
DaSpudLord
SpongyGames
pvz_pro
theonlygusti
Zekrom01
BurnedCrystal
sheep_maker
alexphan
Bookowl
Prscr
JonathanSchaffer
A-no-meep
Gooballs
people who don't support (0):
Last edited by AwesomePerson238243 (April 22, 2016 19:56:55)
- Lythium
-
Scratcher
1000+ posts
[ ] contains [ ]?
I actually support now, because I can't seem to find a valid workaround.
Last edited by Lythium (April 9, 2016 13:45:33)
- AwesomePerson238243
-
Scratcher
100+ posts
[ ] contains [ ]?
what is the easy workaround?<(answer) = [ whatever]>
Easy workaround.
- DownsGameClub
-
Scratcher
1000+ posts
[ ] contains [ ]?
<(answer) = [ whatever]>
Easy workaround.
Uhh…. That doesnt work.
Support. But a quick revision
<[] contains []?>::sensing // The entire block is supposed to be blue... =/Since this version of programming is somewhat like a sentence, and saying “if does (answer) contains (blank)”
Last edited by DownsGameClub (April 9, 2016 12:49:46)
- Lythium
-
Scratcher
1000+ posts
[ ] contains [ ]?
I realised it after posting.<(answer) = [ whatever]>
Easy workaround.
Uhh…. That doesnt work.
Support. But a quick revision<[] contains []?>::sensing // The entire block is supposed to be blue... =/Since this version of programming is somewhat like a sentence, and saying “if does (answer) contains (blank)”
- pvz_pro
-
Scratcher
500+ posts
[ ] contains [ ]?
<[] contains [] ?::sensing>Support.
Supportreasons?
semi-support, this has a workaround with variables and lists
- theonlygusti
-
Scratcher
1000+ posts
[ ] contains [ ]?
semi-support, this has a workaround with variables and listsOkay, for the record, here is the work-around:
set [substring found? v] to [false]
set [letters found v] to [0]
set [i v] to [1]
repeat until <<(length of (string)) = ((i)+(1))> or <(substring found?) = [true]>>
set [j v] to [1]
repeat until <<(length of (substring)) = ((j)+(1))> or <(substring found?) = [true]>>
if <(letter (j) of (substring)) = (letter ((i)+((j)-(1))) of (string))> then
change [letters found v] by (1)
end
change [j v] by (1)
end
if <(letters found) = (length of (substring))> then
set [substring found? v] to [true]
end
change [i v] by (1)
end
if <(substring found?) = [true]> then
else
end
As you can see, it is very simple and intuitive, especially for new scratchers.</sarcasm>
I don't see any reason not to support this idea, so, yeah, support!
- BurnedCrystal
-
Scratcher
100+ posts
[ ] contains [ ]?
Support, as the workaround can have a considerable effect on performance.
That and I'm sure no one wants to redefine string manipulation functions that already exist in other languages
That and I'm sure no one wants to redefine string manipulation functions that already exist in other languages
- Scratcher1002
-
Scratcher
1000+ posts
[ ] contains [ ]?
For the block to be blue you have to put it inside the brackets.<(answer) = [ whatever]>
Easy workaround.
Uhh…. That doesnt work.
Support. But a quick revision<[] contains []? :: sensing> // The entire block is supposed to be blue... =/Since this version of programming is somewhat like a sentence, and saying “if does (answer) contains (blank)”
- alexphan
-
Scratcher
1000+ posts
[ ] contains [ ]?
Although you can simply add all of the letters into a list, and then using this:
Support.
<[ v] contains [ ]>It would be very useful for finding substrings.
Support.
- BookOwl
-
Scratcher
1000+ posts
[ ] contains [ ]?
Although you can simply add all of the letters into a list, and then using this:That only works if your looking for a single letter…<[ v] contains [ ]>It would be very useful for finding substrings.
Support.
Support
- theonlygusti
-
Scratcher
1000+ posts
[ ] contains [ ]?
Although you can simply add all of the letters into a list, and then using this:That doesn't work.<[ v] contains [ ]>It would be very useful for finding substrings.
Support.
Only this works:
semi-support, this has a workaround with variables and listsOkay, for the record, here is the work-around:set [substring found? v] to [false]
set [letters found v] to [0]
set [i v] to [1]
repeat until <<(length of (string)) = ((i)+(1))> or <(substring found?) = [true]>>
set [j v] to [1]
repeat until <<(length of (substring)) = ((j)+(1))> or <(substring found?) = [true]>>
if <(letter (j) of (substring)) = (letter ((i)+((j)-(1))) of (string))> then
change [letters found v] by (1)
end
change [j v] by (1)
end
if <(letters found) = (length of (substring))> then
set [substring found? v] to [true]
end
change [i v] by (1)
end
if <(substring found?) = [true]> then
else
end
As you can see, it is very simple and intuitive, especially for new scratchers.</sarcasm>
I don't see any reason not to support this idea, so, yeah, support!
- Prscr
-
Scratcher
100+ posts
[ ] contains [ ]?
<[] contains [] ?::sensing>
I support. I can't find an easy way to workaround this (above seems to have a workaround)
So, final answer,
support!::sensing
Last edited by Prscr (April 9, 2016 21:13:55)
- pvz_pro
-
Scratcher
500+ posts
[ ] contains [ ]?
Support if it's case sensitive.the scratch block's strings are not case sensitive
- alexphan
-
Scratcher
1000+ posts
[ ] contains [ ]?
I also defenitely support for that. That would make case detection SO much easier.Support if it's case sensitive.the scratch block's strings are not case sensitive
- Discussion Forums
- » Suggestions
-
» [ ] contains [ ]?














