Discuss Scratch
- mitdk
-
Scratcher
1000+ posts
split blocks
I would like these blocks:
(part() of split[] on []::operators)This would split a string on a particular character. the part input would tell the block which part of the split should it return. The split character would be deleted, like in python.
(number of parts in split[] on []::operators)
(part(2) of split[a,b,c] on [,]::operators)//bIf you have any further questions, here is a great clarifying post by PkmnQ(edited by me to match new blocks):
There seems to be a lot of confusion over what this does, so I've made a post that can be referred to.Once you understand this block this is more straightforward:(part (1) of split [a.b.c] on [.] :: operators)This simply reports “a”. Think of it as a list, with “.” as a separator.(part (1) of split [a,b] on [.] :: operators)This simply reports “a,b”. It's sort of like a 1-item list.(part (3) of split [a.b] on [.] :: operators)This simply reports an empty string. It acts similarly to this block:(item ( v) of [list v] :: list)
(number of parts in split[] on []::operators)reports how many parts are in a split
(number of parts in split[a.b.c] on [.]::operators)//3
Last edited by mitdk (Feb. 22, 2022 16:39:59)
- mitdk
-
Scratcher
1000+ posts
split blocks
please explain more about this blockThis block could be used like this:
when green flag clicked
ask [give me a decimal #] and wait
set [num v] to (answer)
say (join [There are] (join (length of (section (2) of split(num) on character[.]::operators)) [decimals after the decimal point]))
Last edited by mitdk (Oct. 1, 2020 18:39:42)
- Vibrato
-
Scratcher
1000+ posts
split blocks
hmm. Interesting. Would the character you split on be put on the first split or the second split? Which character would it be split on if there are multiple of that character?
- mitdk
-
Scratcher
1000+ posts
split blocks
If there are multiple of 1 character (say 2 periods) then you would get 3 sections. As for your other question, I got this idea from python, with the function
split(num, .)
In python, the split character disappears. I would go with that.
split(num, .)
In python, the split character disappears. I would go with that.
Last edited by mitdk (Sept. 25, 2020 19:05:08)
- Vibrato
-
Scratcher
1000+ posts
split blocks
If there are multiple of 1 character (say 2 periods) then you would get 3 sections. As for your other question, I got this idea from python, with the functionsounds good, and useful. Support.
split(.)
In python, the split character disappears. I would go with that.
- mitdk
-
Scratcher
1000+ posts
split blocks
More uses for this block can be:
\
\
- Breaking down saving codes
Getting first/last name
breaking down long strings/integers
making a sentence a list of words
Last edited by mitdk (Sept. 26, 2020 00:42:43)
- mitdk
-
Scratcher
1000+ posts
split blocks
If you support, please indicate it. If you don't agree, please tell me why and how i can improve the block idea.
- sportfan999
-
Scratcher
1000+ posts
split blocks
It may seem a little complicated to beginning Scratchers. Sorry, but no support. I may support it if the block name was easier to read.
- mitdk
-
Scratcher
1000+ posts
split blocks
It may seem a little complicated to beginning Scratchers. Sorry, but no support. I may support it if the block name was easier to read.Well, what should i make it?
- mitdk
-
Scratcher
1000+ posts
split blocks
It may seem a little complicated to beginning Scratchers. Sorry, but no support. I may support it if the block name was easier to read.or maybe it would make more sense with some fillers in the block menu?
(section(1) of split[apple, banana] on character[,]::operators)
Last edited by mitdk (Oct. 1, 2020 16:53:59)
- misteray
-
Scratcher
1000+ posts
split blocks
Support, and
It may seem a little complicated to beginning Scratchers. Sorry, but no support. I may support it if the block name was easier to read.A lot of things are complicated to beginning Scratchers.
- sportfan999
-
Scratcher
1000+ posts
split blocks
A lot of things are complicated to beginning Scratchers.Yup.
- sportfan999
-
Scratcher
1000+ posts
split blocks
I created a dumb little project that cuts a bit off of a string. It's right here if anybody here wants to check it out. It is kinda like this suggestion….
- pavcato
-
Scratcher
1000+ posts
split blocks
deleted Because apperently all my posts say “Workaround”.
Last edited by pavcato (Sept. 27, 2020 02:54:57)
- sportfan999
-
Scratcher
1000+ posts
split blocks
deleted
Last edited by sportfan999 (Sept. 27, 2020 19:16:19)
- pavcato
-
Scratcher
1000+ posts
split blocks
You don't need to make a rant because I misunderstood a suggestion.Duplicate.Honestly, half your posts say “Duplicate” or “Workaround”. Maybe consider being a little kinder on the Forums?
Also, that's not even a duplicate. While that post is similar to this, this is a totally different block.Did xXRedTheCoderXx suggest anything like that? I don't think so.when green flag clicked
ask [give me a decimal #] and wait
set [ num] to (answer)
say (join [There are] (join (length of (section (2) of split(num) on character[.])) [decimals after the decimal point]))
Please don't say “Duplicate”, especially when the post you linked isn't even a duplicate!
- sportfan999
-
Scratcher
1000+ posts
split blocks
You don't need to make a rant because I misunderstood a suggestion.Sorry, I was a little heated when I wrote that.





