3

I want to know if there is an easy way to open a .txt file and load some comma delimited data into variables in Scratch and furthermore add some variable data from Scratch to a .txt file or similar?

I have done a fair bit of google searching but not come across anything so I thought I would ask you guys.

I would love to use Java or something but its for my school kids and I cannot teach them to do it in Java or something else as they need to do what they have to in Scratch which is annoying but something I cannot change.

Scimonster
  • 32,893
  • 9
  • 77
  • 89
user2965258
  • 137
  • 3
  • 12

3 Answers3

5

Scratch does not have file IO capabilities, and i doubt it ever will.

The closest thing that i know of is importing/exporting a list. Right-click on the list watcher from the Scratch IDE, and export. It will produce a .txt file, with each list item on a new line. If you have a similarly formatting TXT file, you can import it using the same method. Each line corresponds to a list item. Comma delimited data doesn't work with this.

Scimonster
  • 32,893
  • 9
  • 77
  • 89
2

You can download and edit the json script for the Scratch project.

  1. From the "See Inside" screen, File->Download to your computer.
  2. Rename the file to have a ".zip" extension instead of just ".sb2".
  3. Unzip the file to edit the "project.json" file.
  4. Edit the list data under "ListName": "[your list]" as desired.
  5. Reassemble the zip file
  6. Remove the ".zip" extension. (Back to ".sb2")
  7. Update the Scratch project by going to the original project and selecting File->Upload from your computer.

In this sample project I have a list called "Jobs". The project.json file has a section like this...

    "listName": "Jobs",
    "contents": ["Accountant",
        "Actor",
        "Advocate",
        "Appraiser",
        "Architect",
        "Baker",
...

Make whatever changes you want directly to the section for your list.

Carter Medlin
  • 11,857
  • 5
  • 62
  • 68
0

Currently, Scratch has no IO abilities, as the answer above me said, But there is a mechanism called JS extenions. Currently it's a closed beta, but when it will be released everyone would be able to program Javascript extensions for scratch. That means that you will be able to create a "Open file" block yourself.

Yotam Salmon
  • 2,400
  • 22
  • 36