Wikipedia-logo.svg  For more information, see List on Wikipedia.

This article is about the feature. For the section of blocks, see List Blocks.
An image of a list and example content

A list (also called an array in other programming languages) is a tool that can be used to store multiple pieces of information at once. It can also be defined as a variable containing multiple other variables. A list consists of a numbers paired with items. They were first introduced in Scratch 1.3. Each item can be retrieved by its paired number. List blocks can be found in the variables blocks palette.

List Blocks

Main article: List Blocks

The following blocks can be used to program lists:

Items

Main article: Item
An image of an empty list

Items can be added to or deleted from a list manually or by programming. Holding down shift and pressing enter on a list results in a new entry above the previously selected entry, and pressing enter without the shift key creates a list entry below the previously selected one. They can also be added by right-clicking the list, clicking 'import', and selecting a plain .txt or Comma Separated Values file. Each line in the file will become a new item in the list.
They can also be exported in the same way; however, it is not possible to do so if the list has a name which is unsupported in the user's operating system. In Windows, lists using question marks (?), asterisks (*), angle brackets (< >), pipes (|), a colon (:), a space ( ), or any ASCII control character cannot be exported with Scratch. The first time the export button is pressed for this type of list, nothing will happen; following the second click, the import/export menu will close.[1][2] The allowed characters will vary between operating systems.

Limits on List Size

In previous versions of the Scratch editor, there is no limit to the length of an item or the number of items a list can hold, apart from an amount sufficient to crash Scratch. However, in old versions of the online editor, a project may have been rendered unable to save online if a list took too long to upload, because Scratch returns a network error after about 30 seconds. This happened at around 300,000 list items.

In Scratch 3.0, lists have a hard size limit of 200,000 items.[3]

Example Uses

Some example uses for lists are as follows:

More Complex Uses

  • Storing user-input data in Operating System simulations
  • Storing AI data in games
  • Allowing users to re-create past inputs
  • Storing world data in 3d projects
  • Making list only games

Copy and Pasting

Because text in lists can be copied and pasted into text documents, and the data in lists can also be exported or imported, lists can be used to create save systems (along with the Ask () and Wait block).

Cloud Lists

Main article: Cloud Data

Cloud lists were an experimental feature in alpha and beta versions of Scratch 2.0. However, they were disabled when Scratch 2.0 was released. The values of cloud lists were stored on the Scratch servers; this was the only difference between them and regular lists. When a cloud list got updated, it did so across all copies of the project. This makes cloud lists ideal for things like public high score lists. Many users wanted cloud lists to come back because it would make coding easier for them.[4]However, they can be replicated by encoding and decoding cloud data.

Casting

Main article: Casting

Lists are cast to numbers and strings with a set of explicit rules depending on its contents.

List Editor

The Scratch list editor.

The List Editor is a feature that allows one to edit lists. It is only available inside the project editor. Use it by clicking on a list item and typing in the new list item. One can also delete an item by clicking the "X" at the right and add an item by clicking the "+" at the bottom left of the list area.

Usage

The list editor can be used to make programming languages in Scratch by importing a *.txt file into the list. It is also useful when a project needs users to edit a list. The list editor is not as widely used as many other features such as Say and Ask. Many Scratchers do not know about the list; therefore, not many projects use it.[citation needed]

The list editor is also useful in text editors as creating a full text editor in Scratch is almost impossible because of the limitations of what characters can be used in the Key () Pressed? block. Text editors using list editors are easy to code as the project just has to access the list item.

Limitations

The list editor has many limitations, which is why it is not widely used. It can only be used in the project editor, which means users can see all the code and edit it. Its use of Scratch features also means that it is hard on the user and is not customizable at all. List editors also do not have the best user interface, and it is often misleading for the user. Because of this, very few projects use the list editor and it is a very little-known feature.

Example Projects

Requests

From the time lists were introduced, many users requested two new blocks,hide list [list v] and show list [list v]. Due to such high demand, they were introduced in Scratch 2.0.

Some users have suggested adding two-dimensional, or even multidimensional as well as cloud lists.[5] However, the Scratch Team has rejected that suggestion, stating that it would be too complicated for a programming language meant for beginners.[6]

Cloud list engines use regular cloud variables to sync lists to cloud variables.

See Also

References

Cookies help us deliver our services. By using our services, you agree to our use of cookies.