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

#1 2008-09-06 18:14:26

Aro
Scratcher
Registered: 2008-07-28
Posts: 7

Scratch array(list) help

Hi im making a scratch program that lets you program a program!  big_smile
im having some trouble with the arrays(lists)im trying to store a number in a list and nothing i do will work. in my program one of my keyword methods is "COLOR" it changes the back ground color by seting it to the number you want.

COLOR/
9/
end/

this program sets the color to black but it didnt work when i tried to set the back ground to "9" i tried it with a sprit but that didnt work. any one know what im doing wrong?

Last edited by Aro (2008-09-06 18:14:58)

Offline

 

#2 2008-09-06 18:19:12

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: Scratch array(list) help

Try using variables? I dunno


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#3 2008-09-06 19:58:09

Aro
Scratcher
Registered: 2008-07-28
Posts: 7

Re: Scratch array(list) help

I cant use variables because my input,processing and output are ALL lists. thats the only way i think it can be done and let the user type.

My program for input and processing uses three lists. All the letters,words,variables,keywords and phrases are list(s)

What I really need to know is if lists can hold strings and numbers in the same list?

Offline

 

#4 2008-09-06 20:17:58

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Scratch array(list) help

Aro wrote:

I cant use variables because my input,processing and output are ALL lists. thats the only way i think it can be done and let the user type.

My program for input and processing uses three lists. All the letters,words,variables,keywords and phrases are list(s)

What I really need to know is if lists can hold strings and numbers in the same list?

Actually, you can't type in presentation mode so you can't type in the applet. You can type using stamping and Arrays. So when the key a is pressed, it would add "a" to the list of current command line, then stamp it, and when the user notifies that they're done with that line it will sum up the current command line list and add it to the actual program list if it's a command line. Smartical, ain't I?

Offline

 

#5 2008-09-06 21:16:30

Aro
Scratcher
Registered: 2008-07-28
Posts: 7

Re: Scratch array(list) help

Yes i know you cant type in presentation mode and the applet.
so i did some coding so each letter that you type it goes into a "Letter" list. "hello" would look like this:
h
e
l
l
o
when you press the space bar it adds a / to the letter list. so hello would now be
h
e
l
l
o
/
now i process the letter list with the next list. the wordprocesser list with this i add the first word "h e l l o" is what i get added to the  lest list the word list. if the word is a keyword like "c o l o r" or "v a r" or maybe "d o" and "l o o p" it broadcast and waits for it to do that command. so yes i agree with you.  smile

heres a sample program

var/
repeat/  <<makes a var named "repeat"
equal/
1/
while/
repeat/ <<loops if  repeat is less then 10
islessthen/
10/
dot/
print/ <<prints repeats
var/
repeat/
var/
repeat/ <<adds one to repeat
add/
1/
loop/ <<this is the end of the loop

Last edited by Aro (2008-09-06 21:48:06)

Offline

 

#6 2008-09-06 21:24:34

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: Scratch array(list) help

Aro wrote:

Yes i know you cant type in presentation mode and the applet.
so i did some coding so each letter that you type it goes into a "Letter" list. "hello" would look like this:
h
e
l
l
o
when you press the space bar it adds a / to the letter list. so hello would now be
h
e
l
l
o
/
now i process the letter list with the next list. the wordprocesser list with this i add the first word "h e l l o" is what i get added to the  lest list the word list. if the word is a keyword like "c o l o r" or "v a r" or maybe "d o" and "l o o p" it broadcast and waits for it to do that command. so yes i agree with you.  smile

You know you could put a list or variable inside a broadcast block? Like this:

<broadcast[ <{ variable }>

Just note that if you wanna receive that command, you first set it (I'll set it to hello), than you type in it's value in the

<when I receive[   block


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#7 2008-09-06 22:50:56

Aro
Scratcher
Registered: 2008-07-28
Posts: 7

Re: Scratch array(list) help

YES! i got it to work with my numbers! ill post it once i get all the methods,keywords and output all together.  smile

Offline

 

#8 2008-09-06 22:52:38

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Scratch array(list) help

Aro wrote:

I cant use variables because my input,processing and output are ALL lists. thats the only way i think it can be done and let the user type.

My program for input and processing uses three lists. All the letters,words,variables,keywords and phrases are list(s)

What I really need to know is if lists can hold strings and numbers in the same list?

Yes, lists can hold both numbers and strings.  I think your problem is that you have the "/" character that you are using as a delimiter.  Scratch sees that and thinks that you have a string there, not a number.  Why use a delimiter at all, why not use each item in the list as a keyword or an argument?  That's what I'm doing (on a similar project) and it's working out pretty well.

Oh wait...you are using the / as a delimiter because your text is being entered from the keyboard as a list of letters.  Mine is coming from an external text editor...there's the difference.  I don't have a good solution for you at this point.  There is a technique where you can gather the letters in a list, then use the list concatenation technique to stick the letters into a string...but the letters all end up with spaces between them because that's what list concatenation uses as an output delimiter between list items.  See this project

http://scratch.mit.edu/projects/Paddle2SeeFixIt/257886


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#9 2008-09-07 13:38:45

Aro
Scratcher
Registered: 2008-07-28
Posts: 7

Re: Scratch array(list) help

I see what you are saying. i looked back on my program and the only thing i was doing wrong was when i tested for the keyword(if the last word is a keyword) then it waits for the next word it never got back into the keyword loop cuz it was not a keyword. lol

Offline

 

#10 2008-09-08 13:20:57

Aro
Scratcher
Registered: 2008-07-28
Posts: 7

Re: Scratch array(list) help

Scat (my program) is now up for beta testing http://scratch.mit.edu/projects/Aro/260979

PLEASE DO NOT COPY...thank you

Offline

 

Board footer