Versions Compared

Key

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

Looking for the documentation on the newest versions of SIL Engine and the Simple Issue Language for Jira 8 for Server/Data Center? Click here !

Contents

Table of Contents
maxLevel3

...

User-defined routines (UDR) are functions that perform specific actions that you can define in your SIL SIL™ programs for a later use. These can considerably improve the readability and maintainability of your code.

...

Warning

Definition of UDRs must be done before the code, even though it is not used anywhere up to that point. Therefore, the following code is invalid.

Code Block
number i;
const number pi = 3.14;
i = 0; //this is the error line, i is initialized to a constant and this is extra code, not allowed
function circleArea(number r) {
    return r * r * pi;
}
 


However, you are allowed to declare global variables and constants before function definitions:

Code Block
number i = 0; //global var with initialization, ok
const number pi = 3.14; //constant, ok

function circleArea(number r) {
    return (i + r) * (i + r) * pi;
}
number r = 10;
runnerLog("Area of radius " + r + " is " + circleArea(r));
i++;
runnerLog("Area of radius " + (r + i) + " is " + circleArea(r));

Running the above code in the Power Scripts for JIRA (formerly known as JJUPIN) Runner gadget:

 

...

The list of parameters in the definition of a UDR can be of any length (including 0) and their respective types can be any valid SIL SIL™ type.

Example

Code Block
function zero(){
    return 0;
}

function doSomething(string s, number n1, number [] n2, boolean flag, string [] oneMore){
    ....
}

...

Code Block
function f(const string s) {
	...
}

...


Variable visibility

There are three categories of variables that can be used in a UDR:

...

These are the values passed to the UDR in the list of parameters. Because SIL SIL™ uses a "pass-by-value" policy, even though you modify the value of these variables in the body of the function, on exit, their original values will be restored.

...

These are the variables that are already defined and can be used right away (issue fields, customfields and any variables defined before the routine). You can use issue fields and customfields custom fields anywhere in your code (including in the UDR body) without having to declare them.

...

Notice that the key variable is a standard issue field that you could otherwise use anywhere in your SIL SIL™ program without having to declare it.

...

Of course, the above code will print the text 'S IS NULL' in the log.