Discuss Scratch
- Discussion Forums
- » Suggestions
- » Scratch is overdue for more string manipulation blocks.
- SeptimusHeap
- Scratcher
100+ posts
Scratch is overdue for more string manipulation blocks.
Having a join and letter _ of _ block is definitely not enough. I propose adding 3 of the most commonly used string manipulation tools in other languages.
First, an “index of” block. (In PHP, it's called strrpos. In c++, it's called find.)
The block would have 2 inputs and would return an integer. (More could be added for a start and end value but that's easy to work around if we added the next block.)
(index of ____ in _____ )
A few examples:
(index of hello in hello world) would return 0. (These could all be increased by 1 to show the starting character and not the index)
(index of world in hello world) would return 6.
(index of o in hello world) would return 4.
(index of cake in hello world) could return -1 or a null value.
This block also functions as a <____ contains ____> block, as a simple <not <(index of ____ in ____) = -1>> will produce the same result.
Second, a (letters _ through _ of ___) block. (substring)
This block would have 3 inputs, a starting coordinate, and ending coordinate, and a string. It would return a string.
Examples:
(letters 1 through 5 of hello world) would return hello. (Not sure if the first character should be 0 or 1.)
(letters 7 through 11 of hello world) would return world.
Thridly, a generic string manipulation block like the block for trig and modulus in the Operators tab. This would contain several simple but useful operations like uppercase, lowercase, etc.
Fourthly, a find and replace block would be very useful.
(replace __ with __ in ___)
Examples:
(replace hello with world in hello world) would return world world.
(replace l with 123 in hello world) would return he123123o wor123d.
Those are all my ideas for now. All of these, especially the top two, would add huge amounts of functionality to scratch. Thank you for reading.
First, an “index of” block. (In PHP, it's called strrpos. In c++, it's called find.)
The block would have 2 inputs and would return an integer. (More could be added for a start and end value but that's easy to work around if we added the next block.)
(index of ____ in _____ )
A few examples:
(index of hello in hello world) would return 0. (These could all be increased by 1 to show the starting character and not the index)
(index of world in hello world) would return 6.
(index of o in hello world) would return 4.
(index of cake in hello world) could return -1 or a null value.
This block also functions as a <____ contains ____> block, as a simple <not <(index of ____ in ____) = -1>> will produce the same result.
Second, a (letters _ through _ of ___) block. (substring)
This block would have 3 inputs, a starting coordinate, and ending coordinate, and a string. It would return a string.
Examples:
(letters 1 through 5 of hello world) would return hello. (Not sure if the first character should be 0 or 1.)
(letters 7 through 11 of hello world) would return world.
Thridly, a generic string manipulation block like the block for trig and modulus in the Operators tab. This would contain several simple but useful operations like uppercase, lowercase, etc.
Fourthly, a find and replace block would be very useful.
(replace __ with __ in ___)
Examples:
(replace hello with world in hello world) would return world world.
(replace l with 123 in hello world) would return he123123o wor123d.
Those are all my ideas for now. All of these, especially the top two, would add huge amounts of functionality to scratch. Thank you for reading.
- scimonster
- Scratcher
1000+ posts
Scratch is overdue for more string manipulation blocks.
Scratch uses 1-based indices, so (index of hello in hello world) should return 1.
I support all of these.
For the third suggestion, we could have uppercase, lowercase, reverse, and shuffle. Perhaps also unicode of, which crashes if the string has a length > 1. (If we had first class lists, i would say it should just return a list.)
I support all of these.
For the third suggestion, we could have uppercase, lowercase, reverse, and shuffle. Perhaps also unicode of, which crashes if the string has a length > 1. (If we had first class lists, i would say it should just return a list.)
Retired Community Moderator
BTW, i run Google Chrome 41.0.2272.101 on a Linux system - Ubuntu 14.04. NEW: iPad 4th gen. w/retina.
418 I'm a teapot (original - to be read by bored computer geeks)
THE GAME (you just lost)
; THE SEMICOLON LIVES ON IN OUR SIGS
- SeptimusHeap
- Scratcher
100+ posts
Scratch is overdue for more string manipulation blocks.
Sure, I guess since letter of is 1-based the rest should be as well. Reverse and shuffle sound good as well. Scratch uses 1-based indices, so (index of hello in hello world) should return 1.
I support all of these.
For the third suggestion, we could have uppercase, lowercase, reverse, and shuffle. Perhaps also unicode of, which crashes if the string has a length > 1. (If we had first class lists, i would say it should just return a list.)
.
Last edited by SeptimusHeap (Sept. 8, 2013 14:35:11)
- Chainmanner
- Scratcher
100+ posts
Scratch is overdue for more string manipulation blocks.
I'm pretty sure that it can be done with the basic blocks and scripts, but I support for the not-geniuses!
- SeptimusHeap
- Scratcher
100+ posts
Scratch is overdue for more string manipulation blocks.
I'm pretty sure that it can be done with the basic blocks and scripts, but I support for the not-geniuses!I beg to differ
- turkey3
- Scratcher
1000+ posts
Scratch is overdue for more string manipulation blocks.
Exactly. It is a very complex method, but the only one I could think of. I don't think there's a simpler way than that, because you have to check each possible orderly combination of letters,I'm pretty sure that it can be done with the basic blocks and scripts, but I support for the not-geniuses!I beg to differ
- SeptimusHeap
- Scratcher
100+ posts
Scratch is overdue for more string manipulation blocks.
But if it was built into scratch it would be much more efficient and wouldn't cause block lag.Exactly. It is a very complex method, but the only one I could think of. I don't think there's a simpler way than that, because you have to check each possible orderly combination of letters,I'm pretty sure that it can be done with the basic blocks and scripts, but I support for the not-geniuses!I beg to differ
- DadOfMrLog
- Scratcher
1000+ posts
Scratch is overdue for more string manipulation blocks.
It's certainly true that it'd be real nice to have all of your suggestions in Scratch.
However, I think if I had to choose one to add then it would be a green operator to be located just below:
I did recently suggest a boolean block (another green operator) that could check for substring within string, but it also provided a way to bring simple case-sensing capability back to Scratch:
As always with these things, it's possible to find workarounds. But I think it's really quite important to note just how much work Scratch has to do for these workarounds - because you end up having to manipulate all strings letter by letter, meaning much interpretation of script in multi-layered repeat loops, meaning extra chance for more lag (especially when you start having to switch costume for every letter to check for case!).
And with the kind of complex, lag-inducing projects that are now being worked on with Scratch (yeah, ok, you're probably thinking my crazy attempts at 3d are really not that typical, but…), new blocks like these, which really are simple to understand, and seem no problem to implement, must surely be worth taking seriously.
However, I think if I had to choose one to add then it would be a green operator to be located just below:
(letter () of [hello])and it would be:
(letters () to () of [hello])Just that alone, as I've mentioned before (more than once), would make so much string manipulation so much simpler, including scripting of workarounds for many of your other suggestions…
I did recently suggest a boolean block (another green operator) that could check for substring within string, but it also provided a way to bring simple case-sensing capability back to Scratch:
< [hello] contains [a letter v] > // a letter, a digit, a small letter, a capital letter, only letters, only digits, only small letters, only capital lettersSince the rightmost dropdown allows dropping in a variable (there are many other such cases in scratch), we get:
< [hello] contains (substring) >
As always with these things, it's possible to find workarounds. But I think it's really quite important to note just how much work Scratch has to do for these workarounds - because you end up having to manipulate all strings letter by letter, meaning much interpretation of script in multi-layered repeat loops, meaning extra chance for more lag (especially when you start having to switch costume for every letter to check for case!).
And with the kind of complex, lag-inducing projects that are now being worked on with Scratch (yeah, ok, you're probably thinking my crazy attempts at 3d are really not that typical, but…), new blocks like these, which really are simple to understand, and seem no problem to implement, must surely be worth taking seriously.
Last edited by DadOfMrLog (Sept. 8, 2013 23:31:02)
Alternate account: TheLogFather –– HowTos and useful custom blocks (see studio). Examples below…
- String manipulation - - - X to power of Y - - - Clone point to clone - Detect New Scratcher - Speed tests studio -
- ProdigyZeta7
- Scratcher
1000+ posts
Scratch is overdue for more string manipulation blocks.
I made this project a while ago, which reports the string within a string and its index.
Last edited by ProdigyZeta7 (Sept. 8, 2013 22:44:05)
- SeptimusHeap
- Scratcher
100+ posts
Scratch is overdue for more string manipulation blocks.
Isn't that basically what I said? It's certainly true that it'd be real nice to have all of your suggestions in Scratch.
However, I think if I had to choose one to add then it would be a green operator to be located just below:(letter () of [hello])and it would be:(letters () to () of [hello])Just that alone, as I've mentioned before (more than once), would make so much string manipulation so much simpler, including scripting of workarounds for many of your other suggestions…
I did recently suggest a boolean block (another green operator) that could check for substring within string, but it also provided a way to bring simple case-sensing capability back to Scratch:< [hello] contains [a letter v] > // a letter, a digit, a small letter, a capital letter, only letters, only digits, only small letters, only capital lettersSince the rightmost dropdown allows dropping in a variable (there are many other such cases in scratch), we get:< [hello] contains (substring) >
As always with these things, it's possible to find workarounds. But I think it's really quite important to note just how much work Scratch has to do for these workarounds - because you end up having to manipulate all strings letter by letter, meaning much interpretation of script in multi-layered repeat loops, meaning extra chance for more lag (especially when you start having to switch costume for every letter to check for case!).
And with the kind of complex, lag-inducing projects that are now being worked on with Scratch (yeah, ok, you're probably thinking my crazy attempts at 3d are really not that typical, but…), blocks like these, which really are simple to understand, and seem no problem to implement, must surely be worth taking seriously.
- DadOfMrLog
- Scratcher
1000+ posts
Scratch is overdue for more string manipulation blocks.
Yup, pretty much! And now it's right there above a fourth time, so it's even harder to miss…Isn't that basically what I said? […some stuff, and…]
As always with these things, it's possible to find workarounds. But I think it's really quite important to note just how much work Scratch has to do for these workarounds - because you end up having to manipulate all strings letter by letter, meaning much interpretation of script in multi-layered repeat loops, meaning extra chance for more lag (especially when you start having to switch costume for every letter to check for case!).
And with the kind of complex, lag-inducing projects that are now being worked on with Scratch (yeah, ok, you're probably thinking my crazy attempts at 3d are really not that typical, but…), blocks like these, which really are simple to understand, and seem no problem to implement, must surely be worth taking seriously.
Alternate account: TheLogFather –– HowTos and useful custom blocks (see studio). Examples below…
- String manipulation - - - X to power of Y - - - Clone point to clone - Detect New Scratcher - Speed tests studio -
- Zaneki
- Scratcher
1000+ posts
Scratch is overdue for more string manipulation blocks.
Support! I was looking for something like this awhile ago, when I was playing around with lists and strings.
look a square
;
- savaka
- Scratcher
1000+ posts
Scratch is overdue for more string manipulation blocks.
You get many spores of supportness.
But the first character should be 1, not 0.
But the first character should be 1, not 0.
- sitaracool01
- Scratcher
23 posts
Scratch is overdue for more string manipulation blocks.
why don't we make scratch available for all apple products and android
Last edited by sitaracool01 (Dec. 31, 2014 23:32:28)
- RPFluffy
- Scratcher
1000+ posts
Scratch is overdue for more string manipulation blocks.
I completely agree with you!
Scratch has always been lacking this and it could get to a whole new level if this was added!
Support!
Scratch has always been lacking this and it could get to a whole new level if this was added!
Support!
Nothing Is EVER 100%, that is just an assumption.
Some important links: Here and here or need help click Here. Eats followers, Loves helping people.
My “..” and “…” are not spelling mistakes, it means that they are ways of telling someone that I can continue more about it and that the sentence isn't ended the best way. I like putting new indents and lines so I can split up what I am talking about.
Some important links: Here and here or need help click Here. Eats followers, Loves helping people. Check this MMO out! Kiwi = Support WHAT THAT'S IMPOSSIBLE: Through the drop down ;)if <> :: control cstart
else :: control
end
- InternetUser_005
- Scratcher
100+ posts
Scratch is overdue for more string manipulation blocks.
support
- Asymptoteles
- Scratcher
29 posts
Scratch is overdue for more string manipulation blocks.
and yet some more support…
- epickitty6104
- Scratcher
54 posts
Scratch is overdue for more string manipulation blocks.
define doing stuff
play sound [stuff v]
say [i want to do this simple] for (2) secs
- Failord
- Scratcher
1000+ posts
Scratch is overdue for more string manipulation blocks.
Support, as long as it's kept simple.
I mean, individual variables could technically be worked around, assuming we still have lists. The “glide to” block is totally workaroundable, among other things. The existence of a workaround in no way invalidates these particular suggestions.
I mean, individual variables could technically be worked around, assuming we still have lists. The “glide to” block is totally workaroundable, among other things. The existence of a workaround in no way invalidates these particular suggestions.
Last edited by Failord (Nov. 21, 2015 22:38:25)
Thanks for the ride, Scratch Team and community! Unfortunately, the time has come for me to move on from Scratch, so I'll no longer be using the forums. Thanks again, and farewell!
Invisible text! This will show you if a profile I claim to be mine IS mine. Just remember to visit the profile and see if I confirmed in the comments.
For old time's sake, see the revolutionary Laser Battle 2.0! Also see Unstoppable Game!
And no, the evil kumquats didn't alter my signature…
- Discussion Forums
- » Suggestions
- » Scratch is overdue for more string manipulation blocks.