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

#26 2008-04-23 21:30:59

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

Re: Lists for Scratch

Amazing!  I have dreams about a Scratch that can read and write files....this is one more step closer to that goal.  And I will second fullmoon's nomination for the Scratcher of the Year award!


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

Offline

 

#27 2008-04-24 01:14:09

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Lists for Scratch

I offer a "Yay" to Paddle2See's second....

Offline

 

#28 2008-04-24 08:11:03

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Lists for Scratch

update

Thanks for all your enthusiastic and encouraging comments!

fullmoon wrote:

Many of these blocks are completely unnecessary, but they sure do make things simpler!

You are absolutely right. Most of the time you will only need four basic blocks to store and retrieve data. I made the other extra blocks mostly with file-access in mind. On your suggestion I now changed the blocks pallette to let you toggle between basic and extra blocks for each list. When you first create a list or open a project only the four basic blocks are shown:

http://chirp.scratchr.org/dl/experimental/listBlocksBasic.gif

You can then press the "Extra" button to show the complete set of blocks:

http://chirp.scratchr.org/dl/experimental/listBlocksExtra.gif

This expand-collapse mechanism works for each list individually. I believe that this is an efficient way to offer more blocks without overburdening the Scratch-IDE. What do you think?

fullmoon wrote:

Does the write function use absolute filenames, or do the .lst files have to be in the same folder?

This block writes to the specified filename. The directory is
   1) the one specified in the command line using the new "filedir:pathname" option
       in combination with the "presentation" option, or if none is specified
   2) the directory of the current project, or if it has not been saved yet
   3) the directory the vm (Scratch.exe or .app) is in.

Paddle2See wrote:

I have dreams about a Scratch that can read and write files...

I introduced the option to set the filedir using the command line to enable Chirp to compile these projects to exe-files and to let these exe-files write data into the same directory they are in (even though Scratch is actually running from a temp-folder ). That way you will be able to share your Chirp projects as exe-files together with any listfiles containing persistant project state (like highscore lists, levels achieved, objects collected etc.).

BTW the filenames can be anything and do not have to have an 'lst' suffix (they are also dangerous, because this block will overwrite anything it can...).

I also found and fixed some bugs, and uploaded the current executable version to:

     http://chirp.scratchr.org/dl/experimental/ScratchLists5.zip

Oh, and I changed the color of the list blocks once again back to a yellowish-green  smile


Jens Mönig

Offline

 

#29 2008-04-24 16:07:48

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Lists for Scratch

And I will second fullmoon's nomination for the Scratcher of the Year award!

You can't get a bet on at the bookies  - its a cert  smile

regards

Simon

Offline

 

#30 2008-04-24 17:03:36

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

Re: Lists for Scratch

Wow, I leave for twelve hours and I come back to find another version! Wow!


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

Offline

 

#31 2008-04-24 17:05:27

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

Re: Lists for Scratch

Paddle2See wrote:

Amazing!  I have dreams about a Scratch that can read and write files....this is one more step closer to that goal.  And I will second fullmoon's nomination for the Scratcher of the Year award!

I too, literally have dreams about Scratch 1.3. Unfortunately, it's clear that it's a dream as soon as I notice blocks called "get me a hamburger". Oh, well.


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

Offline

 

#32 2008-04-28 13:16:37

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Lists for Scratch

I finished the prototype:

   - found and fixed a lot of bugs in a lot of blocks
   - made sure incompatible files are from now on marked internally as "ChirpV01.1"
     so future versions of Scratch won't be confused by them.
   - packaged two demo projects

You can download the final version from:

   http://chirp.scratchr.org/dl/experimental/ScratchLists6.zip

There are two little demo projects to explore in the archive: The first one is called "1cat" and uses just the basic list blocks. The second one is called "7cats" and demonstrates all of the advanced list blocks, including how to design a single file containing multiple lists and how to parse these lists from such a file.

I am very pleased with this prototype and consider it to be pretty complete and stable. About the only thing missing is translation support (and "real" extensive testing).

This concludes my little experiment. Thanks for all your suggestions and advice!


Jens Mönig

Offline

 

#33 2008-04-28 13:28:13

D97
Scratcher
Registered: 2007-12-22
Posts: 100+

Re: Lists for Scratch

Jens wrote:

update

Thanks for all your enthusiastic and encouraging comments!

fullmoon wrote:

Many of these blocks are completely unnecessary, but they sure do make things simpler!

You are absolutely right. Most of the time you will only need four basic blocks to store and retrieve data. I made the other extra blocks mostly with file-access in mind. On your suggestion I now changed the blocks pallette to let you toggle between basic and extra blocks for each list. When you first create a list or open a project only the four basic blocks are shown:

http://chirp.scratchr.org/dl/experiment … sBasic.gif

You can then press the "Extra" button to show the complete set of blocks:

http://chirp.scratchr.org/dl/experiment … sExtra.gif

This expand-collapse mechanism works for each list individually. I believe that this is an efficient way to offer more blocks without overburdening the Scratch-IDE. What do you think?

fullmoon wrote:

Does the write function use absolute filenames, or do the .lst files have to be in the same folder?

This block writes to the specified filename. The directory is
   1) the one specified in the command line using the new "filedir:pathname" option
       in combination with the "presentation" option, or if none is specified
   2) the directory of the current project, or if it has not been saved yet
   3) the directory the vm (Scratch.exe or .app) is in.

Paddle2See wrote:

I have dreams about a Scratch that can read and write files...

I introduced the option to set the filedir using the command line to enable Chirp to compile these projects to exe-files and to let these exe-files write data into the same directory they are in (even though Scratch is actually running from a temp-folder ). That way you will be able to share your Chirp projects as exe-files together with any listfiles containing persistant project state (like highscore lists, levels achieved, objects collected etc.).

BTW the filenames can be anything and do not have to have an 'lst' suffix (they are also dangerous, because this block will overwrite anything it can...).

I also found and fixed some bugs, and uploaded the current executable version to:

     http://chirp.scratchr.org/dl/experimental/ScratchLists5.zip

Oh, and I changed the color of the list blocks once again back to a yellowish-green  smile

I think this sounds rather complicated, and, what would these blocks actually do?


Yes, I am still alive, and no, I am not GLADOS.
Join Sayonara, my Scratch games company!

Offline

 

#34 2008-04-28 16:35:44

bobboder
Scratcher
Registered: 2008-04-25
Posts: 9

Re: Lists for Scratch

i know this sounds dumb, but whats the difference

Offline

 

#35 2008-05-02 10:28:25

AddZero
Scratcher
Registered: 2007-08-11
Posts: 100+

Re: Lists for Scratch

This is very nice.  Thanks!  I like how you have a button to show and hide extra blocks... I like your tweaks to this.  If there's concern about it's ability to overwrite any file, perhaps have a header in the lst files, and before saving over a file, it has to detect this header.  or limit to .lst files?  Has there been any word of the possibility of this being added to scratch?
I hope it makes it soon, this is gold.


http://scratch.mit.edu/static/icons/buddy/524717_med.png?t=2010-06-15+09%3A48%3A36

Offline

 

#36 2008-05-02 16:25:53

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

Re: Lists for Scratch

D97, these blocks are for creating arrays. Arrays are a kind of variable that can have more than one value stored at them at the same time. Think of them as lists *cough*. For instance:

Set Array at 1 to 10
mean that the first "slot" in the array is set to 1

(Array at 1) then reads back as 10.

With Lists, there is no limit to the size of the array (as far as I know):

Set Array at 560395638 to 10 is quite possible.

Basically all of the other blocks do varations of this. However,
<Array includes 0?> is a true/false Boolean statement. If there is a 0 stored anywhere in the list, it will return true.

Clear, sort, reverse are just variations. Clear sets all slots to 0 and the other two are self-explainatory. Size, Average, Min, Max are just fifth-grade math.

Finally, write List.lst for Array allows to to read or write an array from a file that ScratchLists creates, so you can save things like high scores.


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

Offline

 

#37 2008-05-03 09:26:17

ScipioBellorum
Scratcher
Registered: 2007-05-15
Posts: 94

Re: Lists for Scratch

Brilliant work! This will be really useful, especially in replacing my Binary Code formulas which never seemed to work quite right. It's amazing just how many different things you can do with all those blocks.

Keep up the good work. I hope this will soon be incorporated into Scratch so we can share our list based projects online.

SB

Last edited by ScipioBellorum (2008-05-03 18:04:23)


http://img393.imageshack.us/img393/339/logory8.png
                      The word processor for Scratch

Offline

 

#38 2008-05-05 04:22:55

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Lists for Scratch

Thanks again, everyone, especially fullmoon for your excellent and accurate explanation!

I'm still experimenting with the current version myself, basically trying out if things work the way I intended them to. I'm still unsure about incorporating this list prototype into Chirp, because it would produce incompatible projects (even though I marked them internally as being incompatible).

I like being able to write to *any* filename. My vision of things is that you will be able to convert your list projects to exe files and to associate you own filetypes with your own app. That way you will be able to create your own editors/drawing programms etc in Scratch and to produce interchangeable data-files with them.

In my current prototype you can only read/write files whose names are hardcoded in the file-block. I'm thinking about enhancing the file-block to allow user-specifyable files. This, however, introduces the concept of "widgets" to Scratch, which currently is not solved perfectly well in the Scratch IDE, because Dialog-boxes are *not* truly modal (you can still click on other parts of the main window and even of other dialogs when a Dialog is shown). So, before further enhancing the file-block I'll probably try some fixes for DialogBoxes (in my other Squeak-apps I usually use a transparent "shield-morph" pane to cover up the main window while a Dialog box is shown...)


Jens Mönig

Offline

 

#39 2008-05-05 11:52:16

geckofreak
Scratcher
Registered: 2007-12-20
Posts: 100+

Re: Lists for Scratch

While I like the idea of arrays in scratch, I feel they are unnessary for the reason they go against the purpose of scratch. Scratch was developed as a educational language for beginers to learn how programing works, (especialy with images and games). Arrays are unnsesary for scratch programing


http://img361.imageshack.us/img361/645/supersmashbroscharacterzg7.gif
cool  My Wii Friend Code 5069-3634-2461  cool

Offline

 

#40 2008-05-07 05:02:27

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Lists for Scratch

I finished the prototype, documented it and built a compiler for it. You can read my announcement about it here:

   http://www.chirp.scratchr.org/blog/?p=16

The documentation is here:

   http://chirp.scratchr.org/dl/Lists%20and%20Files%20for%20Scratch.pdf

And the prototype (for Windows) here:

   http://chirp.scratchr.org/dl/Lists%20and%20Files%20for%20Scratch.zip

I'll leave it like this until the next version of Scratch comes out. Then I'll decide weather to merge it with Chirp. The prototype itself is fully functional and you can even turn your list-projects (with file-access!) into Windows-exe's to share them. You can also use it to compile any existing Scratch project.

Enjoy!


Jens Mönig

Offline

 

#41 2008-05-07 05:16:46

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

Re: Lists for Scratch

geckofreak wrote:

While I like the idea of arrays in scratch, I feel they are unnessary for the reason they go against the purpose of scratch. Scratch was developed as a educational language for beginers to learn how programing works, (especialy with images and games). Arrays are unnsesary for scratch programing

Arrays (and other indexed data structures) are a VERY important programming concept!  Even beginners can benefit from knowing how to use them.  Where better to get an introduction to them then in Scratch?

I firmly believe that they belong in Scratch!


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

Offline

 

#42 2008-05-07 12:32:16

D97
Scratcher
Registered: 2007-12-22
Posts: 100+

Re: Lists for Scratch

fullmoon wrote:

D97, these blocks are for creating arrays. Arrays are a kind of variable that can have more than one value stored at them at the same time. Think of them as lists *cough*. For instance:

Set Array at 1 to 10
mean that the first "slot" in the array is set to 1

(Array at 1) then reads back as 10.

With Lists, there is no limit to the size of the array (as far as I know):

Set Array at 560395638 to 10 is quite possible.

Basically all of the other blocks do varations of this. However,
<Array includes 0?> is a true/false Boolean statement. If there is a 0 stored anywhere in the list, it will return true.

Clear, sort, reverse are just variations. Clear sets all slots to 0 and the other two are self-explainatory. Size, Average, Min, Max are just fifth-grade math.

Finally, write List.lst for Array allows to to read or write an array from a file that ScratchLists creates, so you can save things like high scores.

I still don't understand.


Yes, I am still alive, and no, I am not GLADOS.
Join Sayonara, my Scratch games company!

Offline

 

#43 2008-05-07 14:17:32

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

Re: Lists for Scratch

I'm not sure I completely understand Arrays (lists) in Javascript, so I'd do bad in Scratch, too...

Offline

 

#44 2008-05-07 18:15:51

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

Re: Lists for Scratch

coolstuff wrote:

I'm not sure I completely understand Arrays (lists) in Javascript, so I'd do bad in Scratch, too...

Maybe not...the goal of Scratch is to teach this sort of thing, and it worked for me...I use other languages now, but I could never stop using Scratch!


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

Offline

 

#45 2008-05-07 18:32:46

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

Re: Lists for Scratch

D97 wrote:

fullmoon wrote:

D97, these blocks are for creating arrays. Arrays are a kind of variable that can have more than one value stored at them at the same time. Think of them as lists *cough*. For instance:

Set Array at 1 to 10
mean that the first "slot" in the array is set to 1

(Array at 1) then reads back as 10.

With Lists, there is no limit to the size of the array (as far as I know):

Set Array at 560395638 to 10 is quite possible.

Basically all of the other blocks do varations of this. However,
<Array includes 0?> is a true/false Boolean statement. If there is a 0 stored anywhere in the list, it will return true.

Clear, sort, reverse are just variations. Clear sets all slots to 0 and the other two are self-explainatory. Size, Average, Min, Max are just fifth-grade math.

Finally, write List.lst for Array allows to to read or write an array from a file that ScratchLists creates, so you can save things like high scores.

I still don't understand.

I'll give an example. Say you wanted to make a program that records the x and y position of the mouse pointer. You would use lists to record all those numbers in a single variable.

When flag clicked---
set "step" to 1
clear "mouse x pos"
clear "mouse y pos"
forever:
set mouse x pos at (step) to (mouse x)
change step by 1
______________________

Does this make things any clearer?
set mouse y pos at (step) to (mouse y)


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

Offline

 

#46 2008-05-08 11:46:03

D97
Scratcher
Registered: 2007-12-22
Posts: 100+

Re: Lists for Scratch

oh, like one variable can have more than one number?


Yes, I am still alive, and no, I am not GLADOS.
Join Sayonara, my Scratch games company!

Offline

 

#47 2008-05-08 13:51:02

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

Re: Lists for Scratch

D97 wrote:

oh, like one variable can have more than one number?

Yes, exactly; you have to specify the "slot" in the list you want to get info from. That's why it's "List at (1)" instead of just "(list)". I'm amazed that I understand this, 6 months ago I had no idea what arrays were. Basically, they're unlimited storage space in a single variable.

Last edited by fullmoon (2008-05-08 13:53:22)


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

Offline

 

#48 2008-05-08 17:20:36

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Lists for Scratch

D97 wrote:

oh, like one variable can have more than one number?

Here is a brief explanation. Arrays or lists are simply sets of values.

Say you wanted to record the prices for products in a store. You could make a separate variable for each different product but that would be time consuming. So instead you can make what is called an array that will hold all of the prices for the products.

//Demonstration code

//Using many variables
var price1:Number=1.11;
var price2:Number=2.22;
var price3:Number=3.33;
var price4:Number=4.44;
var price5:Number=5.55;

//using a single array
var prices:Array= new Array(1.11,2.22,3.33,4.44,5.55);


Can you see how much easier it is with an array? Imagine trying to make a list of 1000 values with out an array!

To call out a values in the array you could put in
price[#] and whatever number put replace the # with is the value in the array that you are calling! Also most arrays start at 0 to to call the first value you would put
price[0].


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#49 2008-05-09 16:52:50

Cyclone103
Scratcher
Registered: 2008-03-20
Posts: 500+

Re: Lists for Scratch

If scratch does add in arrays into the next version, I hope it is soon. I can't stand waiting, and just using Jens' version seems too complicated. I do not understand how to actually make arrays, but I do want them badly. I saw a wonderful flash game that I could reproduce in Scratch if we had them. Scratch Team - Add in arrays PLEASE! I know that they would be hard to make, but everybody who uses scratch would probably learn to appreciate them. PLEASE add them in!


All your base are belong to us

Offline

 

#50 2008-05-18 16:32:14

acolite246
Scratcher
Registered: 2007-09-19
Posts: 8

Re: Lists for Scratch

EDIT: I realize that this has already been writen about... Sorry.
EDIT2: I finished a proof of concept program... I hope to get it onto my website soon. Stolovitz.com
I don't know if this is already up on this topic, but I really don't want to read through 2 pages...

The List function contains a read and write feature- so you could essentially use the list function as a save-game. Make a list for each x or y position of a sprite and add a go-to x:mylist y:myotherlist at the beginning of the script. Add a new block that 'quits' or stops the program and records the x and y positions of the sprites. Then, when the game starts, you can save your progress and reload!

Sorry if it is confusing. I'll try to make a sample project.

(i'm not exactly sure how the lists work, are they like sets? or are they more like a distance as in 'any distance from 40km-433km...)

Last edited by acolite246 (2008-05-18 17:38:16)


-- Not sent from a Blackberry Wireless Handheld--

98% of people who read this signature think it is akin to chain mail. If you're one of the 2% who don't, feel free to copy and paste it into your signature.

Offline

 

Board footer