Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Knowledge Base
  3. 2D Blocks
  4. Editing a Table Using Blocks

Editing a Table Using Blocks

Scheduled Pinned Locked Moved 2D Blocks
1 Posts 1 Posters 933 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

    Prerequisite

    • Introduction to Tables

     

    Description

    You can easily edit a table using blocks, such as adding new rows, removing some rows, or changing the value of some items.

     
     

    Appending a New Row

    The “add to table” block appends a new row at the bottom of a table, then set the values of some or all of the items. It can take up to 12 values, so you can at most set the values of the first 12 items in the new row using this block.

    Note that the order of the values has to match the column order in the table. Blank input boxes will be ignored.

     

    Inserting a New Row

    You can also insert a new row at a particular row number. The existing rows will be pushed down to make room for this new row. You can specify at most the first 12 items in this new row:

     

    Replacing a Row

    You can replace all items in a row using the block below if you know its row number. Other rows will not be affected.

     

    Replacing One Item

    Sometimes you only need to change one item, and keep the other items in the row unchanged. If you know that item’s row number and column name, then you can change its value using this block:

     
    Note that for the second input, you have to specify the column name (e.g. “age”), not the column index (e.g. 2). This is a very common mistake.

     
     

    Changing an Item Relatively

    For some use cases, you only want to change an item relatively based on its current value. For example, if someone’s birthday has just passed, you might want to increase his age by 1. Similarly, if someone has lost a game, you can reduce his points by some number. The following 2 blocks can be used to change or reduce an item’s value:

     

    Deleting a Row by Row Number

    If you know the row number of any row you would like to delete, you can use the following block to delete that row. The rows below will move up by one row to fill in the gap.

     

    Deleting All Rows

    You can also clear the table and delete all rows. The column structure will not change:

     

    Deleting Rows by Matching Value in a Column

    Sometimes we only want to delete all rows in the table with a specific value in a specific column. You can use the following block to specify the column and the value to look for in that column.

     

    Inserting a New Column

    You can also insert a new empty column into a table. You need to specify the name and position of this new column. The existing columns at that position and after will all be pushed to the right by one column.

    Note that this is an uncommon operation, since normally a table’s structure is fixed, and we just change its rows or items.

     

    Deleting a Column

    You can also remove an entire column from a table by specifying the column name, and the letter case of the name does not matter.

     

    Deleting All Columns

    If you need to redefine a table, you can delete all its columns, then add new columns to it from scratch.

     
     

    Show or Hide the Table

    You can use the following 2 blocks to show or hide the table on the stage:

    70ce42df-d7f5-4f35-9bea-72d7321a6e26-image.png

     
    For example:

    tb.gif

     

    Learn More

    • Reading from a List
    1 Reply Last reply
    0
    • CreatiCodeI CreatiCode pinned this topic on

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode