-- This script makes a new demo document so that it won't mess up any documents that you have open.
set demo to make document with properties {name:"Demo"}
-- Bike shows welcome text in new documents, this line deletes that text
-- Create a new "Hello World" row
set helloWorld to make row with properties {name:"Hello World"}
-- Add some child rows to "Hello World"
make row with properties {name:"one"}
make row with properties {name:"two"}
-- Insert a new child in into the middle
make row at (after row named "one") with properties {name:"middle child"}
-- Make a row "at" another row will at it as a child.
make row at row 2 with properties {name:"middle child child"}
-- You can also just make an empty row
-- Or you can make a row with an id, so its easy to find later, even if it's name has been edited.
-- If the given id is already in use then the row will still be made, but will get assigned a different id.
make row with properties {id:"boom", name:"My id is boom"}
-- Change the name of an existing row
set name of row id "boom" to "You've been renamed"
-- Check to see if a row exists
if exists row id "boom" then
log "Yes! row id boom exists"
-- When "Hello World" moves it brings all containing rows with it.
move row named "Hello World" to row id "boom"
move row named "one" to before row named "two"
collapse row named "Hello World" with all
expand row named "Hello World"
-- Now just show "Hello World" and contained rows
set focused row to row named "Hello World"
-- Now just show rows contained by "Hello World"
set hoisted row to row named "Hello World"
tell (make document with properties {name:"Move to"})
-- delete welcome text again
-- Move row from our original document to this new document
move row named "middle child" of demo to first row
-- Can also just copy rows to new document
duplicate row named "one" of demo to end of rows