Scripts

Scripts are a mechanism where business logic can be implemented using a procedural programming language. Ideally, most business rules should be represented using a declarative format such as Decision Tables or Rete Rules. Scripts can be useful however when the business logic is procedural, or when developers need additional tools to work around any potential "brick walls" in the development of business rule solutions. Scripts can also be used to build comprehensive unit and regression tests for your business rules.

The Pascal-like scripting language provided with Common Knowledge is very powerful, not only providing a rich set of language features but also leveraging a powerful expression syntax that is available throughout Common Knowledge. The language supports all common programming constructs including iteration, selection, functions, procedures, local and module variables, and constants.

Script Rule Format

Like all Common Knowledge rule formats, the Script rule format seamlessly integrates with Common Knowledge Designer and the Common Knowledge SDK and can be easily combined with other business rule formats to create powerful solutions to complex business rule problems.

Overview

The Common Knowledge Script rule format provides capabilities in a number of areas to enable you to implement procedural logic to complement your declarative business rules:

Script Language Mature and rich procedural scripting language that allows you to work directly with the elements of Common Knowledge Contexts and with other rule formats
Script Features Comprehensive set of programming language features including: functions, pass by value and pass by reference, loop statements, switch statements, sets and custom User Classes
Standalone Execution Standalone execution of Common Knowledge Scripts entirely within Common Knowledge Designer
Advanced Editor Easy-to-use Script editor that supports colour syntax highlighting, code-folding and debugging support
Procedural Use procedural logic and the powerful Common Knowledge expression syntax to integrate the execution of all other rule formats

Features

The Common Knowledge Script rule format incorporates an ever-growing set of features that assist you during the design, authoring, execution and testing of business rules procedural logic. Features include:

Procedural Constructs functions, procedures, variables, for-loops, while/repeat loops, case/switch statements, pass-by-reference/pass-by-value
Function Libraries Rich library of functions available including Mathematical, Statistical, Financial, Date/Time, String and System (platform specific) libraries
Access Elements Access and manipulate Common Knowledge Context elements such as Context Objects, Context Libraries, Context Properties and User Classes directly from scripts
Integrated Debugger Debugger can step through script line by line or stop on breakpoints. Use the Eval/Modify Window to examine current values of Script variables. Use the Call Stack Window to see the current execution path
Error Reporting Build errors may be traced directly to errant line and position within a script
Interactive Execution Interactive prompting for variable values when executing Scripts within Common Knowledge Designer