Hi im making a scratch program that lets you program a program!
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
Try using variables? I dunno

Offline
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
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
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.
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
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.![]()
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

Offline
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
Offline
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
Scat (my program) is now up for beta testing http://scratch.mit.edu/projects/Aro/260979
PLEASE DO NOT COPY...thank you
Offline