Creating Scripts

Create scripts to automate Bike and integrate with other apps. If you just want to run a script that someone else has written please see the Using Scripts section.

Also consider using Bike's more powerful extension context.

Overview

When scripting Bike you are dealing with documents, windows, and rows. Documents and windows are common scripting objects with a few Bike extensions–rows are specific to Bike.

Each row represents a row in your outline. Rows have a name for accessing the row's text. Rows also have an id and other attributes. Rows can contain other rows. When you move or delete a row those contained rows are moved or deleted with it.

You gain access to rows in a few ways:

  1. From properties of a document such as root row, selected row, focused row.

  2. From the rows collection belonging to each document. This collection contains all rows in the document (except for the root). This collection is a good place to quickly find existing rows.

  3. From the rows collection belonging to each row. This collection contains only the rows that are directly contained by the row (the children). This collection is a good place for making new rows and to use as a target to moving existing rows into.

Dictionary

Use Bike's scripting dictionary to learn what parts of Bike are scriptable.

To open Bike's scripting dictionary:

  • Drag and drop Bike onto Script Editor's application icon.

  • Or from Script Editor use File > Open Dictionary and choose Bike's dictionary.

Getting Started

Here's the official starting point for learning AppleScript:

The starting point for lesser people, such as myself, is to find example scripts and then randomly change them until they do what you want. I've included some for you below. You can also find scripts in the Bike support form and ask scripting questions.

Example scripts

You'll get the most out of these scripts by using Script Debugger instead of Script Editor that comes with your Mac. Among other things Script Debugger allows you to step through the script line by line so you can see the effect of each command on you document.

Kitchen Sink

This is a nonsense script that demonstrates many of Bike's scripting abilities. It's a good place to learn how basic things are done like making and moving rows.

Home Script

This script resets your view state to "Home"

Cleanup Script

This script saves the current selected row. Collapses all rows. Then restores your selection, which also expands any rows needed to show the selection. Use it to cleanup when you have to many rows expanded, but you still want to keep working where you are.

Today Script

This script create a simple calendar structure in your outline and adds a new line to "today" where you can start taking notes. It's interesting because it uses row id's to track rows. Once the calendar is created you can move it to any place in your outline and the script will keep working.

Run app context script

You can call from ApplesScript into Bike's app context extension API using the evaluate command.

Why might you want to do this? Generaly, Bike's app context extension API is faster and more powerful than the AppleScript API. This lets you jump from AppleScript land, to Bike extension land, and then back to AppleScript land again.

Note: The script that you pass should be plain JavaScript, not the TypeScript code used in most of the extension API documentation.

Here's a explanation of each step in the process:

  1. Call evaluate command with script parameter and optional input parmeter.

  2. Bike will then evaluate that Javascript string in Bike's app extension context

  3. If the result is not a closure it's string form is returned immediatly.

  4. If the result is a closure, then Bike will call the closure, passing in the provided input (if any), and the string form of that closure result is returned.

Examples:

Apple's script editor also allows Javascript syntax, which looks like this:

Last updated