(Items: Mentioned another shortcut which performs a function as notable as one that was stated - creating a new list item with ENTER key and added a span on illegal file names when mixed with exporting)
(Broken Project Fix)
(22 intermediate revisions by 11 users not shown)
Line 4: Line 4:
 
==List Blocks==
 
==List Blocks==
 
{{main|List Blocks}}
 
{{main|List Blocks}}
[[File:List Blocks.png|frame|200px|All of the list blocks.]]The following blocks can be used to program lists:
+
The following blocks can be used to program lists:
*[[Add () to () (block)|Add () to ()]] {{-}} Adds an item to a list
+
* [[Add () to () (block)|<sb>add [thing] to [list v]</sb>]] {{-}} Adds an item to a list
*[[Delete () of () (block)|Delete () of ()]] {{-}} Deletes a chosen item of a list
+
* [[Delete () of () (block)|<sb>delete (1 v) of [list v]</sb>]] {{-}} Deletes a chosen item of a list
*[[Insert () at () of () (block)|Insert () at () of ()]] {{-}} Inserts an item at a chosen point in a list
+
* [[Insert () at () of () (block)|<sb>insert [thing] at (1 v) of [list v]</sb>]] {{-}} Inserts an item at a chosen point in a list
*[[Replace Item () of () With () (block)|Replace Item () of () With ()]] {{-}} Replaces an item in a list with a new item
+
* [[Replace Item () of () With () (block)|<sb>replace item (1 v) of [list v] with [thing]</sb>]] {{-}} Replaces an item in a list with a new item
*[[() (List block)|()]] {{-}} A reporter block with few uses; however, this can be used as a [[Stage Monitor]]
+
* [[() (List block)|<sb>(list::list)</sb>]] {{-}} A reporter block with few uses; however, this can be used as a [[Stage Monitor]]
*[[Item () of () (block)|Item () of ()]] {{-}} A [[Reporter Block|reporter block]] that reports what text an item in a list contains
+
* [[Item () of () (block)|<sb>(item (1 v) of [list v])</sb>]] {{-}} A [[Reporter Block|reporter block]] that reports what text an item in a list contains
*[[Length of () (List block)|Length of ()]] {{-}} A reporter block that reports how many items a list contains
+
* [[Item Number of () in () (block)|<sb>item # of () in [list v]</sb>]] {{-}} Reports the index in a list where an item first appears
*[[() Contains () (List block)|() Contains ()]] {{-}} A [[Boolean Block|boolean block]] that checks if a list contains a given [[string]].
+
* [[Length of () (List block)|<sb>(length of [list v])</sb>]] {{-}} A reporter block that reports how many items a list contains
 +
* [[() Contains () (List block)|<sb><[list v] contains [thing]></sb>]] {{-}} A [[Boolean Block|boolean block]] that checks if a list contains a given [[string]].
  
 
==Items==
 
==Items==
 
[[File:Empty list.png|right|thumb|An image of an empty list]]
 
[[File:Empty list.png|right|thumb|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. <br> 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. 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.<ref>https://scratch.mit.edu/projects/214142180/</ref><ref>https://www.youtube.com/watch?v=qTo6kYHStss</ref>
+
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. <br> 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.<ref>https://scratch.mit.edu/projects/214142180/</ref><ref>[[yt:qTo6kYHStss]]</ref>
 
The allowed characters will vary between operating systems.
 
The allowed characters will vary between operating systems.
  
 
==Limits on list size==
 
==Limits on list size==
There is no limit to the length of an item<ref group=note>(except in special circumstances)</ref> or the number of items a list can hold, apart from an amount sufficient to crash [[Scratch]]. However, you may not be able to save a project online if your list takes too long to upload, because Scratch will return a network error after about 30 seconds. Few lists need to contain that amount of information, but a dictionary of 350,000 English words may fail to save when 250,000 words would succeed. This is due to the list being stored twice in the [[JSON]] source.
+
<!--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, you may not be able to save a project online if your list takes too long to upload, because Scratch will return a network error after about 30 seconds. Few lists need to contain that amount of information, but a dictionary of 350,000 English words may fail to save when 250,000 words would succeed. This is due to the list being stored twice in the [[JSON]] source.-->
===Special circumstances===
+
{{expand|date=July 2019}}
When operating with the "Replace Item () of () with ()" block, there exists a hard-limit on the maximum length of the resulting item, although this only occurs in the event that the block replaces an item with something conjoined to that item. For example:
+
In [[Scratch 3.0]], Lists have a size limit of 200,000 items.<ref name="List size limit">https://github.com/LLK/scratch-vm/wiki/Compatibility</ref>
<scratchblocks>
 
replace item (1 v) of [list v] with (join (item (1 v) of [list v] :: list) [abc])
 
</scratchblocks>
 
Under these circumstances, the maximum size of the replaced item's length is capped to 10240 characters.<ref>https://scratch.mit.edu/discuss/youtube/2rEVuce10bw/</ref><ref>https://scratch.mit.edu/projects/214071512/</ref>
 
The remaining characters beyond the 10240<sup>th</sup> character are simply truncated.
 
  
 
==Example Uses==
 
==Example Uses==
 
Some example uses for lists are as follows:
 
Some example uses for lists are as follows:
*Calculations
+
* Calculations
*Encoding/Decoding strings
+
* Encoding/Decoding strings
*Inventories
+
* Inventories
*[[Artificial Intelligence]]
+
* [[Artificial Intelligence]]
*Recording multiple values
+
* Recording multiple values
*Conserving variables
+
* Conserving variables
*[[Saving Data#Saving Data in Lists|Saving and loading data]]
+
* [[Saving Data#Saving Data in Lists|Saving and loading data]]
  
 
===More Complex Uses===
 
===More Complex Uses===
*Storing user-input data in [[Operating System]] simulations
+
* Storing user-input data in [[Operating System]] simulations
*Storing AI data in games
+
* Storing AI data in games
*Allowing users to re-create past inputs
+
* Allowing users to re-create past inputs
  
 
===Copy and pasting===
 
===Copy and pasting===
Line 49: Line 45:
 
==Cloud Lists==
 
==Cloud Lists==
 
{{main|Cloud Data}}
 
{{main|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 will make coding easier.<ref>https://scratch.mit.edu/discuss/topic/85970/?page=1#post-744420</ref>
+
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.<ref>[[post:744420]]</ref>
  
 
==Casting==
 
==Casting==
 
{{main|Casting}}
 
{{main|Casting}}
 
Lists are cast to numbers and strings with a set of explicit rules depending on its contents.
 
Lists are cast to numbers and strings with a set of explicit rules depending on its contents.
 +
 +
== List Editor ==
 +
[[File:List editor.png|thumb|right|300px|The [[Scratch]] list editor.]]
 +
The '''List Editor''' is a feature that allows you to edit lists. It is only avalible inside the project editor. Use it by clicking on a list item and typing in the new list item. You 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 Language (Project Type)|Programming languages]] in [[Scratch]] by importing a <code>*.txt</code> 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 [[Scratcher]]s do not know about the list; therefore, not many projects use it.{{citation needed|date=July 2018}}
 +
 +
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 {{b|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==
 
==Example Projects==
*[http://scratch.mit.edu/projects/930729 Fibonacci Generator] by [http://scratch.mit.edu/users/WeirdF WeirdF]
+
* [https://scratch.mit.edu/projects/72564018/ Fibonacci Generator] by [https://scratch.mit.edu/users/makethebrainhappy makethebrainhappy]
*[http://scratch.mit.edu/projects/583768 FruitcraftRPG] by [http://scratch.mit.edu/users/Wodunne Wodunne]  
+
* [http://scratch.mit.edu/projects/583768 FruitcraftRPG] by [http://scratch.mit.edu/users/Wodunne Wodunne]
*[http://scratch.mit.edu/projects/777127 Random Level Generator] by [http://scratch.mit.edu/users/poopo poopo]
+
* [http://scratch.mit.edu/projects/777127 Random Level Generator] by [http://scratch.mit.edu/users/poopo poopo]
*[http://scratch.mit.edu/projects/1384397 Scratch Memory] by [http://scratch.mit.edu/users/spaceguy12 spaceguy12]
+
* [http://scratch.mit.edu/projects/1384397 Scratch Memory] by [http://scratch.mit.edu/users/spaceguy12 spaceguy12]
  
 
==Requests==
 
==Requests==
From the time lists were introduced, many users requested two new blocks,<sb>hide list [list v]</sb> and <sb>show list [list v]</sb>. Due to such high demand, they were included in Scratch 2.0.
+
From the time lists were introduced, many users requested two new blocks,<sb>hide list [list v]</sb> and <sb>show list [list v]</sb>. Due to such high demand, they were included in [[Scratch 2.0]].
 +
 
 +
Some users have suggested adding two-dimensional, or even multidimensional lists.<ref>[[topic:212876]]</ref> The Scratch Team has yet to comment on that suggestion.{{citation needed|date=November 2018}}
  
 
==See Also==
 
==See Also==
*[[Array]]
+
* [[Array]]
*[[:Category:Variables and List Tutorials]]
+
* [[:Category:Variables and List Tutorials]]
*[[Compiling a List Into a String]]
+
* [[Compiling a List Into a String]]
  
 
==References==
 
==References==
 
<references/>
 
<references/>
  
[[Category:Scratch Program]]
 
[[Category:Values]]
 
 
[[de:Listen]]
 
[[de:Listen]]
 
[[id:Daftar]]
 
[[id:Daftar]]
Line 79: Line 87:
  
 
==Notes==
 
==Notes==
<references group=note />
+
[[Category:Scratch Program]]
 +
[[Category:Values]][[nl:Lijsten]][[ru:Список]]

Revision as of 20:34, 7 October 2019

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. Each item can be retrieved by its paired number. List blocks can be found in the Data blocks palette.

List Blocks

Main article: List Blocks

The following blocks can be used to program lists:

Items

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

Document.png Please expand this article or section. You can help by adding more information if you are an editor. More information might be found in a section of the talk page. (July 2019)

In Scratch 3.0, Lists have a 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

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]

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 you to edit lists. It is only avalible inside the project editor. Use it by clicking on a list item and typing in the new list item. You 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 included in Scratch 2.0.

Some users have suggested adding two-dimensional, or even multidimensional lists.[5] The Scratch Team has yet to comment on that suggestion.[citation needed]

See Also

References

  1. https://scratch.mit.edu/projects/214142180/
  2. yt:qTo6kYHStss
  3. https://github.com/LLK/scratch-vm/wiki/Compatibility
  4. post:744420
  5. topic:212876

Notes