Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: attempt to clarify __testing

...

When you develop a ruleset, you may choose to use the "Testing" tab of the developer UI which can provide a simple UI for your eventthe events and queries of the ruleset. The "Testing" tab works by querying your ruleset to see if it shares the name __testing and if it does, it parses the structure that __testing points to and builds simple forms using a map named __testing which is created automatically by the compiler when the ruleset is compiled. The tab builds a simple form to test each of the queries and events which the structure defines. The __testing structure is created automatically map defines (again, as generated by the compiler).

This __testing name can be may also be shared, so you and if you want to do this you can add it to the "shares" entry in the "meta" block of the ruleset. The "shares" keyword is followed by a comma-separated list of names defined in the globals section which we wish to use outside of the ruleset. Any names not mentioned in "shares" are for the private use of the the ruleset and are not exposed outside the ruleset. Edit the "meta" block of your ruleset to look like this:

...

Click on the "Testing" tab of the developer UI. Choose the "hello_world" channel from the ECI dropdown. Notice under your ruleset identifier that there are three forms, one for each of the shared functions and the event that you defined in your ruleset.

...

...

In the next example, the name __testing is not shared, so there is no button for it in the Testing tab.

Notice the button "echo/hello", representing this event for your ruleset named "hello_world". Click on this button to send the event.

...

Congratulations! You know how to send queries to a pico, either directly using a URL, or through the "Testing" tab of the UI, or through Postman.

Using logs

KRL provides an operator, klog(), which allows us to print information into the logs. It is an operator, rather than a statement, so it is applied to an expression. It prints into the log the message passed to it as an argument, followed by the value of the expression on which it operates. Finally, it returns the value of the expression on which it operates, unchanged. This makes it easy to add to or remove from your KRL code without changing its meaning.

...