This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-09-08 18:02:40

illusionist
Retired Community Moderator
Registered: 2008-07-02
Posts: 1000+

New Block: "Split [ ] at letter ( )"

We can join text, but what about split it into pieces?

http://img338.imageshack.us/img338/859/newblox.png

Like the idea? I do!  lol


http://i.imgur.com/8LX1NrV.png

Offline

 

#2 2009-09-08 18:32:17

The-Whiz
Scratcher
Registered: 2007-07-09
Posts: 1000+

Re: New Block: "Split [ ] at letter ( )"

So what would it report? What would the answer be?

Last edited by The-Whiz (2009-09-08 18:32:34)

Offline

 

#3 2009-09-08 18:33:33

demosthenes
Retired Community Moderator
Registered: 2008-02-19
Posts: 1000+

Re: New Block: "Split [ ] at letter ( )"

The-Whiz wrote:

So what would it report? What would the answer be?

A list of length 'n' where 'n' is the number of articles. So really this should be in the lists category.


I've taken a long hiatus, but I still visit sometimes. Give me some time to answer any messages you post on my projects!

Offline

 

#4 2009-09-08 18:35:03

The-Whiz
Scratcher
Registered: 2007-07-09
Posts: 1000+

Re: New Block: "Split [ ] at letter ( )"

Would it report "H" or "ello world"?

Last edited by The-Whiz (2009-09-08 18:35:10)

Offline

 

#5 2009-09-08 19:23:13

illusionist
Retired Community Moderator
Registered: 2008-07-02
Posts: 1000+

Re: New Block: "Split [ ] at letter ( )"

The-Whiz wrote:

So what would it report? What would the answer be?

good question...

The-Whiz wrote:

Would it report "H" or "ello world"?

Er... Both? IDK

Last edited by illusionist (2009-09-08 19:23:43)


http://i.imgur.com/8LX1NrV.png

Offline

 

#6 2009-09-08 19:38:42

The-Whiz
Scratcher
Registered: 2007-07-09
Posts: 1000+

Re: New Block: "Split [ ] at letter ( )"

How does it report two things?  hmm  That's impossible. Maybe (first part of [hello world] split at (1)) and (last part of [hello world] split at (1))

You could do that...

Code:

[when flag clicked]
[delete (all) of [letters]]
[ask [input?]]
[set [text] to (answer)]
[set [iterator] to [0]]
[repeat (length of (answer))]
[][change [iterator] by (1)]
[][add (letter (iterator) of (answer)) to [letters]
[end repeat]
[ask [Split at where?]]
[set [split] to (answer)]
[set [first] to []]
[set [last] to []]
[repeat (answer)]
[][set [first] to (join (first) (item (1) of [letters])]
[][delete (1) of [letters]]
[end repeat]
[repeat (length of [letters])]
[][set [last] to (join (last) (item (1) of [letters])]
[][delete (1) of [letters]]
[end repeat]
[say (join (The first part of ) (join (text) (join ( split at ) (join (split) (join ( is ) (join (first) (join ( and the last part of ) (join (text) (join ( split at ) (join (split) (join ( is ) (join (last) (.))))))))))))]

Last edited by The-Whiz (2009-09-08 19:39:20)

Offline

 

#7 2009-09-08 20:23:48

DarthPickley
Scratcher
Registered: 2008-06-13
Posts: 100+

Re: New Block: "Split [ ] at letter ( )"

str$[num1:num2] is how you do it in Truebasic... where the reported value is the substring between the num1 character and the num2 character.

Offline

 

#8 2009-09-13 19:44:08

terminator68
Scratcher
Registered: 2008-02-26
Posts: 1000+

Re: New Block: "Split [ ] at letter ( )"

cool! I want this block  tongue !
The input it would probably give when you type in split "hello world" at letter one h ello world. The block would probably look like this (sort of): <split (Hello World) at letter (1)> ...
Another thing is how did you make the block illusionist? It looks so REAL  smile

Last edited by terminator68 (2009-09-19 19:26:43)


--------------------Scratcher since '08--------------------
http://images1.wikia.nocookie.net/__cb20110314152018/mlpfanart/images/5/5d/Applejack_chewing.gif

Offline

 

Board footer