Replace Item () of () with ()
Category Variables
Type Stack

The Replace Item () of () with () block is a List block and a Stack block. The block replaces the specified item; in other words, it changes the item's content to the given text.

Example UsesEdit

If an item has to change its content, this block will do the job.

Some common uses for the Replace Item () of () with () block:

  • Changing an itemTemplate:-for example, replacing an object in a list of objects

<scratchblocks> ask [What item would you like to change in the grocery list?] and wait set [item v] to (answer) ask [What would you like to change it to?] and wait set [new food v] to (answer) replace item (item) of [Grocery List v] with (new food) </scratchblocks>

  • Rewriting a list without deleting all the items and creating new ones

<scratchblocks> say [Oops, I got the wrong grocery list! I need to get a new one.] for (3) secs set [item v] to (0) repeat (length of [Grocery List v]) change [item v] by (1)

 replace item (item) of [Grocery List v] with (item (pick random (1) to (5)) of [Foods v])


  • Changing a record of certain statistics

<scratchblocks> say [And Mike crosses the finish line! This is new record for the 100 meter relay!] for (4) secs replace item (5 v) of [School Records v] with (Relay Time) </scratchblocks>

  • Adding characters onto an already-existing item

<scratchblocks> replace item (1 v) of [list v] with (join (item (1 v) of [list v]) (characters)) //"characters" is the new letters </scratchblocks>

  • Recording positions of individual clones

<scratchblocks> when I start as a clone set [id v] to (total clones) add [] to [clonesX v] forever if <key [left arrow v] pressed?> then change x by (-2.5) end if <key [right arrow v] pressed?> then change x by (2.5) end replace item (id) of [clonesX v] with (x position) </scratchblocks>


Main article: List of Block Workarounds

This block can be replicated with the following code:

<scratchblocks>delete (value) of [list v] insert (item) at (value) of [list v]</scratchblocks>

See AlsoEdit

Template:Data Blocksde:Ersetze () Element von () durch () (Block)

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.