Introduction to Global Functions and Procedures

Global functions and procedures are predefined functions that you can use in Soley Studio rule sets, e.g. for realizing loops, comparing elements or traversing trees. We grouped the global functions in four categories. In the following articles you can find detailed information about the available global functions by category:

Before going to these detailed articles, please make sure that you understand the notation syntax, i.e. how to read the notation of the functions, by reading the following section.

Syntax of global functions & procedures

The notation of all global functions follows this syntax:

function_name(obligatory input parameter,[optional input parameter]):output parameter

An example for this syntax would be:

reachableOutgoing(Node[,EdgeType[,NodeType]]):set<Node>
isReachable(Node,Node[,EdgeType[,NodeType]]):boolean

The reachableOutgoing function returns a set of all nodes of type Node (output datatype) that can be reached  from the start node Node (this needs to be an identifier, see example below) using outgoing edges of the type EdgeType (this must be an edge class name) and passing and counting only nodes of the type NodeType (this must be a node class name). The start node is an obligatory parameter while the 2nd and 3rd arguments are optional, as denoted by the square brackets. If you do not specify the 2nd and 3rd arguments the generic superclasses Edge and Node will be used automatically. If you do not specify a 2nd argument you cannot specify a 3rd argument. So if you are looking for a specific NodeType but do not care about the EdgeType you could use reachableOutgoing(n, Edge, YourNodeClassName). Remember that the resulting set is of the generic type <Node>, as denoted by the output parameter, even if you specified a NodeType as 3rd argument.

In comparison, the isReachable function returns a boolean value and requires two node identifiers as obligatory 1st and 2nd input arguments, an optional edge class name as 3rd argument (edges that can be passed) and an optional node class name as 4th argument (nodes that can be passed).

Code Example

rule separateEdges{
    src:Product;
    trg:Part;
    -e:Contains->trg;

    if{isReachableOutgoing(src, trg, Contains);}  
    //if the trg node is reachable from the src node on any path
    //using only outgoing edges of the type Contains

    modify {
       delete(e); //then delete the Contains edge that has trg as target
    }
}

Was this article helpful?

Related Articles