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

#1 2011-08-01 09:59:25

EzekielE
Scratcher
Registered: 2010-09-26
Posts: 100+

Scripting Question

I want to be able to take a variable value like

hello world

and divide it up into words and put it into a list, the list would look like

1. hello
2. world

whats the easiest way to do this?


http://mag.racked.eu/cimage/i2260/Achievement++get%21/Find+a+Disk/mca.pnghttp://ezekielelin.com/1x1Gif/image.php

Offline

 

#2 2011-08-01 11:26:45

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Scripting Question

Currently, you would need to have a two lists: You have a script go through every letter and add it to the first list, then once it hits a space ( " " ) then it adds the first list into the second list, then clears all the data from the first list and then continues ( not adding the space to the list ).

I've asked for a "split" block ( the reverse of the "join" block ), but it hasn't been added yet.

Offline

 

#3 2011-08-01 13:56:09

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: Scripting Question

Magnie wrote:

Currently, you would need to have a two lists: You have a script go through every letter and add it to the first list, then once it hits a space ( " " ) then it adds the first list into the second list, then clears all the data from the first list and then continues ( not adding the space to the list ).

I've asked for a "split" block ( the reverse of the "join" block ), but it hasn't been added yet.

Well I have an easier way but yes we need a split block. (Split hello world)


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#4 2011-08-01 21:35:30

EzekielE
Scratcher
Registered: 2010-09-26
Posts: 100+

Re: Scripting Question

Thescratch3 wrote:

Magnie wrote:

Currently, you would need to have a two lists: You have a script go through every letter and add it to the first list, then once it hits a space ( " " ) then it adds the first list into the second list, then clears all the data from the first list and then continues ( not adding the space to the list ).

I've asked for a "split" block ( the reverse of the "join" block ), but it hasn't been added yet.

Well I have an easier way but yes we need a split block. (Split hello world)

yes, but then would you be able to do

split hello split world split and split have split a split nice day


http://mag.racked.eu/cimage/i2260/Achievement++get%21/Find+a+Disk/mca.pnghttp://ezekielelin.com/1x1Gif/image.php

Offline

 

#5 2011-08-01 22:22:12

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: Scripting Question

I have used that exact script in my chatbot!  big_smile  Its called Julia. It is the first part of the only script.


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#6 2011-08-01 23:57:38

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: Scripting Question

jji7skyline wrote:

I have used that exact script in my chatbot!  big_smile  Its called Julia. It is the first part of the only script.

How did you do it?


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#7 2011-08-02 07:29:48

EzekielE
Scratcher
Registered: 2010-09-26
Posts: 100+

Re: Scripting Question

I got it, thanks

(now a good way to PROCESS the input *sigh*


http://mag.racked.eu/cimage/i2260/Achievement++get%21/Find+a+Disk/mca.pnghttp://ezekielelin.com/1x1Gif/image.php

Offline

 

Board footer