MicroNugget: How to Use Lists in Scratch Programming

preview_player
Показать описание

In this video, Tim Warner covers how to use lists in Scratch to temporarily store your data. There are two basic types of variables, one of which is a list. In other programming languages, this is often called an array.

A variable is used in Scratch in the same way that it’s used in any programming language: to temporarily store data for some type of use within your app. There are two types of variables that are supported in Scratch.

The first is a straight-up variable: when you create one of these, you get a stage monitor that you can turn on and off, as well as set, change, show, and hide events that focus on the variable.

The second type is called a list and acts as a storage location for more than one piece of data.

Tim will give you a brief overview of what this process is going to do, then walk you through the necessary steps to use this function.

Start learning with CBT Nuggets:

Рекомендации по теме
Комментарии
Автор

It's 2019, and you're still helping us out :)

CoderKids
Автор

Actually, in Scratch 3 there is a limit now to how many items a list can hold. The limit, according to the Scratch M.I.T. website, is hard-coded to amount to 200, 000 items. This limit was introduced because longer lists can take a lot of time to load into memory, thus irritating the - waiting - user. Anyhow, I would be hard pressed to come up with more than 200, 000 names for colors... If you need more space to hold items, you can resort to strings and format them into chunks yourself (using a fixed-length approach or introducing marker characters between items), as the number of characters strings can hold is only limited by available machine memory.

enantiodromia
Автор

Is There A Way To Hide/Show Your List?

maxrichhart
Автор

How Would I make an inventory with this?

sheepstudios
Автор

And scratch 3.0 is coming in three weeks

pixelstudios
Автор

So it's a variable with multiple values? Or is it a way to contain multiple variables easily?

solarpellets
Автор

Hello Tim: I am making a Scratch project. I want to get the user to identify a major scale. Then I want them to identify a modal scale (derived from that scale, ex: on C, the lydian modal scale is D, E, F, G, A, B, C.) Then I want them to pick notes on the modal scale - as the first, third and sixth. The program would then play the triads based on these root notes. This would give us a chord progression  in that mode. 

To do so, I would need a choose function, and a list of the scales; a choose function, and a list of the modes; a choose function, then a list of triads formed on that modal scale. So what I hope to do is to map, say, the scale of C onto its lydian counterpart scale (by starting with D in the scale and not C), then the root notes of that modal scale onto the triads formed with the root notes (for example, the major triad or chord is the fist, third and fifth note of a major scale). 

Here's how it would look to the user. ''Pick a major scale.'' A list of major scales would appear. Then when they had chosen, the question would appear ''Pick a modal scale.'' A list of modals scales on hat major scale would appear. Then when they had chosen, the question would appear, ''Pick three notes on the scale.'' Then Scratch would play this progressin. 

So what I am asking is how to map one list onto another then onto a third list? 

oumcalthoum
Автор

Oh, and I would deeply appreciate, Tim if you could find a way to do this. Some of the best pop and jazz music was composed with modal scale progressions. 

oumcalthoum