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!
Offline
I offer a "Yay" to Paddle2See's second....
Offline
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:
You can then press the "Extra" button to show the complete set of blocks:
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
Offline
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
regards
Simon
Offline
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.

Offline
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!
Offline
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![]()
I think this sounds rather complicated, and, what would these blocks actually do?
Offline
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.
Offline
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.

Offline
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)
Offline
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...)
Offline
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

My Wii Friend Code 5069-3634-2461
Offline
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!
Offline
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!
Offline
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.
Offline
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!

Offline
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)

Offline
oh, like one variable can have more than one number?
Offline
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)

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