Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Your owner pico is represented by a rounded rectangle, which is placed on a canvas, allowing you to change its placement. Keep this tab open for use in registering and installing your ruleset, below.

Writing KRL

Do the following:

  1. Create a git repo for your KRL rulesets and put it on Github. You can create a different repo for each ruleset if you like or create one repo and put multiple rulesets in it. 
  2. Create a file in your ruleset repo called hello_world.krl and put the code below into it.

  3. Validate (parse) your ruleset using one of the methods in Developer Tips for Pico Engine.
  4. Check your validated ruleset into Github.

Overall Structure of a KRL Ruleset

A first ruleset, in a file named hello_world.krl:

Code Block
linenumberstrue
ruleset hello_world {
  meta {
    name "Hello World"
    description <<
A first ruleset for the Quickstart
>>
    author "Phil Windley"
    logging on
    shares hello
  }
 
  global {
    hello = function(obj) {
      msg = "Hello " + obj;
      msg
    }
  }
 
  rule hello_world {
    select when echo hello
    send_directive("say") with
      something = "Hello World"
  }
 
}

...

The following describes parts of the ruleset shown above:

...

Registering and Installing Your Ruleset

A recommended workflow for writing KRL is found in KRL Programming Workflow. Please read and set up a workflow using your favorite editor and Git. 

Registering a ruleset means to make it available to the pico engine, which compiles the KRL source code into JavaScript and caches this as a node module.

...