This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.
  • Index
  •  » FAQ
  •  » What are arrays and how do I use them?

#1 2008-08-03 10:38:03

bhz
Scratcher
Registered: 2008-07-06
Posts: 100+

What are arrays and how do I use them?

Moderator summary:

An array, or "list" as they're called in Scratch, is exactly what they sound like: a list of values, essentially a variable with several variables within them.

You can make lists in the "Variables" tab, and you can view their contents by clicking the checkbox next to their name in order to display the list on the stage.

I've never heard of 'em. someone explain please?

Last edited by demosthenes (2010-12-17 17:28:59)

Offline

 

#2 2008-08-03 11:08:38

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

Re: What are arrays and how do I use them?

Arrays are a type of variable.  But instead of holding just one number, they can hold a whole lot of numbers.  You tell it which number you want to work with by changing an index value.  Here's an example using a language like Basic where we have an array called Size which is assigned some values:

     Size(1) = 10
     Size(2) = 15
     Size(3) = 32

You can see that the name of the array, Size, stays the same but the index value changes from 1 to 2 to 3.  The array is holding three numbers all at once.  Arrays can hold lots of data - hundreds or thousands of values.  And the data can be accessed easily in a loop, simply by changing the index value.  In most languages, arrays can do more than just hold numbers;  you can make arrays that hold words or other types of data.  You can do some cool things with arrays.

Scratch is expected to have arrays in version 1.3 but they will probably look quite a bit different from what I have shown here.  The basic idea, however, will be the same.


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

Offline

 

#3 2008-08-03 11:51:45

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

Re: What are arrays and how do I use them?

Paddle2See wrote:

Arrays are a type of variable.  But instead of holding just one number, they can hold a whole lot of numbers.  You tell it which number you want to work with by changing an index value.  Here's an example using a language like Basic where we have an array called Size which is assigned some values:

     Size(1) = 10
     Size(2) = 15
     Size(3) = 32

You can see that the name of the array, Size, stays the same but the index value changes from 1 to 2 to 3.  The array is holding three numbers all at once.  Arrays can hold lots of data - hundreds or thousands of values.  And the data can be accessed easily in a loop, simply by changing the index value.  In most languages, arrays can do more than just hold numbers;  you can make arrays that hold words or other types of data.  You can do some cool things with arrays.

Scratch is expected to have arrays in version 1.3 but they will probably look quite a bit different from what I have shown here.  The basic idea, however, will be the same.

They are actually quite similar to what you said (I have the beta). Except that they're called lists. There's a variable display type thing which actually looks quite strange, but you can resize it and all. There are also a few blocks:
add [thing] to list (you can type or drag a variable as variables can be either text strings or numbers),
delete (all, first, last, or number) of list,
insert [thing] at (first, last, or number) of list,
replace (first, last, or number) of list with [thing],
then there are the variable blocks for the arrays.
item (1) of list
length of list

it's pretty easy to use, actually. when i first saw them, I thought I wouldn't understand them, but they're simpler than they look.

Offline

 

#4 2008-08-03 18:04:40

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

Re: What are arrays and how do I use them?

coolstuff wrote:

Paddle2See wrote:

Arrays are a type of variable.  But instead of holding just one number, they can hold a whole lot of numbers.  You tell it which number you want to work with by changing an index value.  Here's an example using a language like Basic where we have an array called Size which is assigned some values:

     Size(1) = 10
     Size(2) = 15
     Size(3) = 32

You can see that the name of the array, Size, stays the same but the index value changes from 1 to 2 to 3.  The array is holding three numbers all at once.  Arrays can hold lots of data - hundreds or thousands of values.  And the data can be accessed easily in a loop, simply by changing the index value.  In most languages, arrays can do more than just hold numbers;  you can make arrays that hold words or other types of data.  You can do some cool things with arrays.

Scratch is expected to have arrays in version 1.3 but they will probably look quite a bit different from what I have shown here.  The basic idea, however, will be the same.

They are actually quite similar to what you said (I have the beta). Except that they're called lists. There's a variable display type thing which actually looks quite strange, but you can resize it and all. There are also a few blocks:
add [thing] to list (you can type or drag a variable as variables can be either text strings or numbers),
delete (all, first, last, or number) of list,
insert [thing] at (first, last, or number) of list,
replace (first, last, or number) of list with [thing],
then there are the variable blocks for the arrays.
item (1) of list
length of list

it's pretty easy to use, actually. when i first saw them, I thought I wouldn't understand them, but they're simpler than they look.

Actually, I have the beta too and I've been working with it quite a bit.  But the Scratch Team asked us to not discuss beta features on the forums as it might confuse people.  Also, the final form might change before the official release - remember the Comment Block!


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

Offline

 

#5 2009-05-28 17:54:11

Quaggledorf
Scratcher
Registered: 2009-03-27
Posts: 7

Re: What are arrays and how do I use them?

Does anyone know if you can add a sprite to a lsit and, if so, how do you do it?

Offline

 

#6 2009-05-28 19:41:43

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: What are arrays and how do I use them?

Quaggledorf wrote:

Does anyone know if you can add a sprite to a lsit and, if so, how do you do it?

You can't, that's a feature of object-oriented programming that's taking its sweet time to get to Scratch. You can give each sprite a "name" variable and add that to a list, it might help you accomplish whatever you're trying to do.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#7 2009-05-29 17:24:43

Quaggledorf
Scratcher
Registered: 2009-03-27
Posts: 7

Re: What are arrays and how do I use them?

thank you

Offline

 

#8 2009-08-27 03:47:43

raywili
Scratcher
Registered: 2009-08-23
Posts: 9

Re: What are arrays and how do I use them?

Thanks a lot! smile smile

Offline

 

#9 2009-08-28 14:39:53

TinyWanda
Scratcher
Registered: 2009-05-26
Posts: 35

Re: What are arrays and how do I use them?

To my way of thinking; An Array is a 2 Dimensional Block of Data...
And Scratch only has Lists, which are 1 Dimensional Lists of Data...
But--
The Items in Each Line of the List can be VERY BIG...
So that you can store a string of numbers as Characters in An Item on A List
Then use The Block (?) to Grab a Specific Item in that List
Then Use The String Block (?) to Grab a Specific Character in that String...
Effectively Creating a Viable Array...???


Visit The Source Material...
http://transamoebae.blogspot.com/

Offline

 

#10 2009-08-31 05:44:03

tibongko
Scratcher
Registered: 2009-08-18
Posts: 3

Re: What are arrays and how do I use them?

try my base project "Matrix"
Its a list of lists = array of arrays = matrix of matrices ...
these list can store numbers and strings/text/characters

Offline

 

#11 2009-08-31 08:54:37

TimeFreeze
Scratcher
Registered: 2008-08-11
Posts: 500+

Re: What are arrays and how do I use them?

um... Can people stop necroposting? It's really annoying. I think this should be closed.

If you don't know what necroposting is, it's posting on a topic that has not been posted on in a long time.


There are 10 types of people in this world: Those who understand binary, and those who don't. --[insert unrelated transition]-- GRANDILOQUENCE FTW!

Offline

 

#12 2009-08-31 14:29:29

cheddargirl
Scratch Team
Registered: 2008-09-15
Posts: 1000+

Re: What are arrays and how do I use them?

TimeFreeze wrote:

um... Can people stop necroposting? It's really annoying. I think this should be closed.

If you don't know what necroposting is, it's posting on a topic that has not been posted on in a long time.

Well, someone might have a question or comment about arrays in the future, I don't believe there's a need to close this thread. Besides, the last few posts are within few days of each other (the big jump in time is from Quaggledorf's post to raywili's post), and it seems to have remained on topic.  smile


http://i.imgur.com/8QRYx.png
Everything is better when you add a little cheddar, because when you have cheese your life is at ease  smile

Offline

 

#13 2009-08-31 14:51:02

TimeFreeze
Scratcher
Registered: 2008-08-11
Posts: 500+

Re: What are arrays and how do I use them?

oh yeah... Sorry.

Btw, I thought that P2S's post and Quaggledorf's post was the big jump.


There are 10 types of people in this world: Those who understand binary, and those who don't. --[insert unrelated transition]-- GRANDILOQUENCE FTW!

Offline

 

#14 2009-08-31 23:26:21

cheddargirl
Scratch Team
Registered: 2008-09-15
Posts: 1000+

Re: What are arrays and how do I use them?

TimeFreeze wrote:

oh yeah... Sorry.

Btw, I thought that P2S's post and Quaggledorf's post was the big jump.

I was referring to the last big time difference in posting (the one that could, in a sense, be qualified as the last necropost in this thread). And it's alright.  smile


http://i.imgur.com/8QRYx.png
Everything is better when you add a little cheddar, because when you have cheese your life is at ease  smile

Offline

 

#15 2009-09-14 10:19:32

newsoft
Scratcher
Registered: 2009-09-14
Posts: 6

Re: What are arrays and how do I use them?

Does anyone know if you can add a sprite to a lsit and, if so, how do you do it?


[url removed by moderator]

Last edited by cheddargirl (2009-09-16 23:04:28)

Offline

 
  • Index
  •  » FAQ
  •  » What are arrays and how do I use them?

Board footer