Discuss Scratch

gamer270
Scratcher
18 posts

split block

I want a block like this to be added like
(split (scratch) at character(character to split at))
you could put it inside a list item select block like this
(item (1 v) of (split (scratch) at character(character to split at))) 
If
(character to split at)
was “a” the two items in the list would be “scr” and “tch”
AonymousGuy
Scratcher
1000+ posts

split block

gamer270 wrote:

I want a block like this to be added like
(split [scratch] at character [a]) //category=operators
That block looks better.

Anyways, I think this could be interesting, but would have to handle lists differently (as they are handled in BYOB) so I think that there needs to be a different way to make this block if it is going to be implemented.
1234abcdcba4321
Scratcher
1000+ posts

split block

no support, already workaroundable.

I'd highly appreciate it if you were to follow me. Don't forget to go to my profile.
All of my programming suggestions <— You should really get the suggestions move back to the suggestions forum!
Five hundred posts! I never expected to get up there… In only 2-3 months.
Does anyone know what a signature is? I mean, I've already seen 6-7 people get confused.
Rex208
Scratcher
500+ posts

split block

This is a block idea I had.
The block would look something like this:

(Section () of [] split by []) //category=operators

What it would do:

1. The block would split the first string wherever the second string appeared in it.
2. Then it would number the sections the second string was split up into.
3. Then it would count until it found a section with the same number as the number that was used as the number input. That would be the output.

e.g:
(Section (2) of [Hi, how are you today, Scratch cat?] split by [,]) //category=operators

1. “Hi, how are you today, Scratch cat?” would be split up into “Hi”, “ how are you today”, and “ Scratch cat?”
2. The sections would be numbered.
“Hi” is number 1.
“ how are you today” is number 2.
“ Scratch cat?” is number 3.
3. The block wants section 2, or “ how are you today”. That then becomes the output.

Possible uses:

Storing lists through cloud data, storing matrices or maybe even 3d matrices easily, storing multiple variables all in one variable, making import/export saved game data buttons easier…


powercon5
Scratcher
1000+ posts

split block

cool idea



Witty signature.





little_kitten
Scratcher
500+ posts

split block

Support!
   ._. ::sound
._.
._. ::list
._. ::control
._. ::operators
._. ::pen
._. ::sensing
._. ::motion
._. ::looks

The above post was likely clear sass. 10 outta 10.
Unless it wasn't. Which happens from time to time. Sadly.
gregory9
Scratcher
100+ posts

split block

Support. This is basically
$result = explode(“Hi, how are you today, Scratch cat?”, “,”);
in PHP then getting the second item of result (“Scratch cat?”)

Use DuckDuckGo instead of Google, Bing, or Yahoo

Check out Coursacado, and SBX Share!

I am gw90 on GitHub
cwrivera99
Scratcher
500+ posts

split block

Workaround! I have a project about this. It shows you how to encode an entire list into a variable. I call the encoding method “separated strings” becase it separates each item on the list with a predefined character. Here's the workaround for the block you're proposing.
define Find Item (Item) of (String) with Separator (Separator)
set [Counter v] to [0]
repeat ((Item) - (1))
repeat until <(letter (Counter) of (String)) = (Separator)>
change [Counter v] by (1)
end
change [Counter v] by (1)
end
set [Output v] to []
repeat until <(letter (Counter) of (String)) = (Separator)>
set [Output v] to (join (Output) (letter (Counter) of (String)))
change [Counter v] by (1)
The “Output” variable is your answer.

Last edited by cwrivera99 (Nov. 22, 2014 20:32:13)


when this block is clicked::sensing hat//FYI, this is my old account that I no longer use. My current account is @DaSpudLord.
forever {do (a [scratch v]::events ring)::sound}::extension cstart
say [what the...?] in (the language of [the moon people v]::red)::control
create [spontaneous v] explosion in [a flea's stomach]::motion
That's not right...::cend
If you are reading this… Then congratulations! You have found the part of my signature that was eaten by a kumquat! (On a side note, you are probably in a kumquat's stomach.) Now get out of the kumquat's stomach and go do something productive with your life. Like playing this game over and over again. Very productive.
rollercoasterfan
Scratcher
1000+ posts

split block

Support!














when [chromometer altimeter v] = [5th length v] and [7th length v] with a [gap v] of (17) ::events hat
forge [chromometer v] altimeter until < (speed) = (velocity)> ::control cstart
switch places with (759 v) altimeters with value of (speed) ::looks
control [altimeter 1 v] at time (10):(17):(58) ::control
end
initialize sequence (24) so [object 3 v] moves to x (156) y (231) ::control
reveal [final answer v] and stop running this script ::events cap
sithsiri
Scratcher
100+ posts

split block

support

Click here for an addition to procd's .sb2 to .exe compiler! It makes the compiler easier to use.
Copy some various emojis and chars from here. It'll come in handy for comments and things: ☁∞πℼ℉℃©®℗™℠§
Find more symbols at www.fsymbols.com
Told you kumquats are nice! That one over there gave me my signature!

9+10=19
Imagine+Program+Share=7+7+5
7+7+5=19
Scratch just makes sense.

Fake link! I used 00a1ff
Cream_E_Cookie
Scratcher
1000+ posts

split block

Support, but make it better

















Zekrom01
Scratcher
1000+ posts

split block

support

20 something years old
Probably doing college work
DaSpudLord
Scratcher
1000+ posts

split block

No support, workaroundable.

Also, there's a duplicate out there somewhere.

Last edited by DaSpudLord (Aug. 31, 2015 16:26:48)



U^ェ^U::motion//This is Blocky. He lives in my signature. He is a trained attack block. He protects my siggy from kumquats.
Cream_E_Cookie
Scratcher
1000+ posts

split block

DaSpudLord wrote:

No support, workaroundable.

Also, there's a duplicate out there somewhere.
Actually, the thread that you are probably thinking of is the duplicate.

DaSpudLord wrote:

No support, workaroundable.

Also, there's a duplicate out there somewhere.
Anything is workaroundable.
(well, you g et my point)

















DaSpudLord
Scratcher
1000+ posts

split block

Cream_E_Cookie wrote:

DaSpudLord wrote:

No support, workaroundable.

Also, there's a duplicate out there somewhere.
Anything is workaroundable.
(well, you g et my point)
Is this workaroundable?
create file [] at []::custom
Because if so, I'd love to hear the workaround. (Seriously, I would really like this.)

Last edited by DaSpudLord (Aug. 31, 2015 17:24:58)



U^ェ^U::motion//This is Blocky. He lives in my signature. He is a trained attack block. He protects my siggy from kumquats.
Zro716
Scratcher
1000+ posts

split block

The thing is the interpreter was not built to report lists as themselves, they get cast to strings. I would totally love a built-in split function to complement the join block (really bugging me a lot) and speed up many of my operations and save myself a few variables and debugging headaches… Though, I prefer that the split function, due to the nature of the interpreter, be a list stack block

split [hello, world!] by [space v] into [list v] ::list // where [space v] includes all characters on a standard keyboard
split [hello, world!] by [each letter v] into [list v] ::list // and includes this option too
If need be, the delimiter input can take anything so that more complicated splittings may be used.

Last edited by Zro716 (Aug. 31, 2015 17:27:51)


As a long time Scratcher, I have found new meaning to the name “Scratch”: for me, it means to “scratch that itch”, to come back again and again to realize new ideas in this toy language, even when I'm capable of creating my projects in real programming languages years later. It's a friend that helped me to pursue programming and get me to enjoy its fruit. I'm certain many others who have walked this path as well have grown fond of its importance in their life.
DaSpudLord
Scratcher
1000+ posts

split block

Zro716 wrote:

The thing is the interpreter was not built to report lists as themselves, they get cast to strings. I would totally love a built-in split function to complement the join block (really bugging me a lot) and speed up many of my operations and save myself a few variables and debugging headaches… Though, I prefer that the split function, due to the nature of the interpreter, be a list stack block

split [hello, world!] by [space v] into [list v] ::list // where [space v] includes all characters on a standard keyboard
split [hello, world!] by [each letter v] into [list v] ::list // and includes this option too
If need be, the delimiter input can take anything so that more complicated splittings may be used.
Actually, if removed, the
(join [][])
block would not have a workaround. Sure, you could use a list with the
(list::list)
reporter, but then there would be a space between each joined string, so… not a real workaround. But a split block does have a workaround.

Last edited by DaSpudLord (Aug. 31, 2015 17:34:32)



U^ェ^U::motion//This is Blocky. He lives in my signature. He is a trained attack block. He protects my siggy from kumquats.
Zro716
Scratcher
1000+ posts

split block

DaSpudLord wrote:

Actually, if removed, the
(join [][])
block would not have a workaround. Sure, you could use a list with the
(list::list)
reporter, but then there would be a space between each joined string, so… not a real workaround. But a split block does have a workaround.
you don't have enough experience to appreciate the benefit of the split function. Especially in scratch where it is required to hack the JSON to fully utilize a custom script for splitting a string into a list. And hacking =/= valid workaround.
split [hello world] by [ ] into [list v]
/* have to hack the custom block procDef and call blocks to be able ::grey
to specify an available list without having to type it in every time */ ::grey
define split (string) by (splitter) into (list)
delete (all v) of (list) // have to hack the list blocks
set [split_substr v] to []
set [split_i v] to [0]
if <(splitter) = []> then // empty splitter means split by each letter
repeat (length of (string))
change [split_i v] by (1)
add (letter (split_i) of (string)) to (list)
end
else
repeat (length of (string))
change [split_i v] by (1)
set [split_chr v] to (letter (split_i) of (string))
if <(split_chr) = (splitter)> then
add (split_substr) to (list)
set [split_substr v] to []
else
set [split_substr v] to (join (split_substr)(split_chr))
end
end
if <not <(split_substr) = []>> then // leave no substring unadded
add (split_substr) to (list)
end
end

Last edited by Zro716 (Aug. 31, 2015 18:10:32)


As a long time Scratcher, I have found new meaning to the name “Scratch”: for me, it means to “scratch that itch”, to come back again and again to realize new ideas in this toy language, even when I'm capable of creating my projects in real programming languages years later. It's a friend that helped me to pursue programming and get me to enjoy its fruit. I'm certain many others who have walked this path as well have grown fond of its importance in their life.
Cream_E_Cookie
Scratcher
1000+ posts

split block

DaSpudLord wrote:

Cream_E_Cookie wrote:

DaSpudLord wrote:

No support, workaroundable.

Also, there's a duplicate out there somewhere.
Anything is workaroundable.
(well, you g et my point)
Is this workaroundable?
create file [] at []::custom
Because if so, I'd love to hear the workaround. (Seriously, I would really like this.)
I mean what exist's in scratch.

















DaSpudLord
Scratcher
1000+ posts

split block

Cream_E_Cookie wrote:

DaSpudLord wrote:

...
I mean what exist's in scratch.
So this is workaroundable?
turn video [on v]

Zro716 wrote:

you don't have enough experience to appreciate the benefit of the split function.
No, but I have enough wisdom to understand the benefit of not having the split function-
  1. It could be confusing to inexperienced scratchers. Considering Scratch revolves around new scratchers, this is a stronger reason than some might realize.
  2. Forcing inexpereinced scratchers to come up with the workaround allows for a learning experience. It offers a chance to put their skills to the test in a problem-solving application. If they fail, then they can look up the answer and figure out how it works, so that next time they might succeed. Scratch revolves around teaching scratchers how to program and, more importantly, how to make stuff for themselves instead of being handed workarounds.
  3. Again, this is also a learning experience for skilled Scratchers. Without the block, you guys are forced to create the workaround. Whenever the workaround doesn't work they way you need it to for your project, that's another learning experience as you guys must test your brains to make the workaround work for you instead of having a workaround that doesn't work.
  4. Tired of programming being too simple? Then leave. Scratch is not about the skilled scratchers. It is not about you and me. It is for the unskilled scratchers to learn. Our purpose on this site is to create projects to act as guides that teach others how to do stuff that they might not know how to do. Stop trying to take Scratch and make it for you and the other skilled Scratchers. Instead, start thinking about the little guys for once.


U^ェ^U::motion//This is Blocky. He lives in my signature. He is a trained attack block. He protects my siggy from kumquats.

Powered by DjangoBB