12
What’s new in SIL 3.0? Contact Florin Haszler Tel: +40 21 233 10 80 Email: [email protected] www.kepler-rominfo.com

What’s new in SIL 3.0? - Kepler-Rominfo€¦ · What’snew in SIL 3.0? Contact Florin Haszler Tel: +40 21 233 10 80 Email: [email protected]

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: What’s new in SIL 3.0? - Kepler-Rominfo€¦ · What’snew in SIL 3.0? Contact Florin Haszler Tel: +40 21 233 10 80 Email: florin.haszler@kepler-rominfo.com

What’s new in SIL 3.0?

ContactFlorin HaszlerTel: +40 21 233 10 80Email: [email protected]

www.kepler-rominfo.com

Page 2: What’s new in SIL 3.0? - Kepler-Rominfo€¦ · What’snew in SIL 3.0? Contact Florin Haszler Tel: +40 21 233 10 80 Email: florin.haszler@kepler-rominfo.com

In short…

1. Defining Global Variables

2. Constants

3. Multi-dimensional arrays

4. User-defined structure types

5. Chaining index and field access

6. Additional operators

7. Error handling (try-catch blocks)

Page 3: What’s new in SIL 3.0? - Kepler-Rominfo€¦ · What’snew in SIL 3.0? Contact Florin Haszler Tel: +40 21 233 10 80 Email: florin.haszler@kepler-rominfo.com

Defining Global Values

• Define variables before function definitions

number HOURS_PER_DAY = 8;

number DAYS_PER_WEEK = 5;

function hoursInWeek() {

return HOURS_PER_DAY * DAYS_PER_WEEK;

}

• Create libraries of application-wide values

include “application_constants.incl”;

function hoursInWeek() {

return HOURS_PER_DAY * DAYS_PER_WEEK;

}

Page 4: What’s new in SIL 3.0? - Kepler-Rominfo€¦ · What’snew in SIL 3.0? Contact Florin Haszler Tel: +40 21 233 10 80 Email: florin.haszler@kepler-rominfo.com

Constants

• Declare variables as constants

• Prevents (accidental) modification

const number HOURS_PER_DAY = 8;

const number DAYS_PER_WEEK = 5;

function hoursInWeek() {

return HOURS_PER_DAY * DAYS_PER_WEEK;

}

DAYS_PER_WEEK = 4; // error

Page 5: What’s new in SIL 3.0? - Kepler-Rominfo€¦ · What’snew in SIL 3.0? Contact Florin Haszler Tel: +40 21 233 10 80 Email: florin.haszler@kepler-rominfo.com

Constants (2)

• Declare function parameters as constants

function arrayContains(const string [] array,

string element) {

array[0] = element; // no cheating!

return arrayFind(array, element);

}

• Prevent parameters from being modified within function body

Page 6: What’s new in SIL 3.0? - Kepler-Rominfo€¦ · What’snew in SIL 3.0? Contact Florin Haszler Tel: +40 21 233 10 80 Email: florin.haszler@kepler-rominfo.com

Arrays

• SIL 2 only handles one-dimensional arrays

• … so why not more?

string [] arr1 = { “1”, “2” };

string [][] arr2 = { {“1.1”, “1.2”}, {“2.1”, “2.2”} };

• As many dimensions as one can keep track of (32 – can handle more? Let us know)

• Move around entire rows (dimensions)arr2[0] = arr1;

arr2[1] = arr1;

// or

arr2 = { arr1, arr1 }; // bonus feature

Page 7: What’s new in SIL 3.0? - Kepler-Rominfo€¦ · What’snew in SIL 3.0? Contact Florin Haszler Tel: +40 21 233 10 80 Email: florin.haszler@kepler-rominfo.com

Structures

• User-defined structure types

struct Person {

string firstName;

string lastName;

number age;

}

• Structured access to data

• Easy to understand SIL scripts

• Castable from string []

Person p = {“John”, “Doe”, “32”};

Page 8: What’s new in SIL 3.0? - Kepler-Rominfo€¦ · What’snew in SIL 3.0? Contact Florin Haszler Tel: +40 21 233 10 80 Email: florin.haszler@kepler-rominfo.com

Casting Structures

• Two-way casting between structures and arrays

• Casting array -> structure

– Array element type must be castable to any type of field in the structure

• Casting structure -> array

– Every type of field in the structure must be castable to array element type

Page 9: What’s new in SIL 3.0? - Kepler-Rominfo€¦ · What’snew in SIL 3.0? Contact Florin Haszler Tel: +40 21 233 10 80 Email: florin.haszler@kepler-rominfo.com

Indexing

• For arrays:– Indexed by number:

array[1] = value;

– Indexed by keyarray[“key”] = value;

• For structures– Indexed by field name

person[“firstName”] = “John”;

– Access by field nameperson.lastName = “Doe”;

• Chaining teams[“JIRA”].developers[3].firstName

Page 10: What’s new in SIL 3.0? - Kepler-Rominfo€¦ · What’snew in SIL 3.0? Contact Florin Haszler Tel: +40 21 233 10 80 Email: florin.haszler@kepler-rominfo.com

Additional Operators

• Pre-increment: ++i

• Post-increment: i++

• Pre-decrement: --i

• Post-decrement: i—i = 0;

j = i++ + --i + ++i + i--; //2

• Ternary ifreturn condition ? ifTrueValue : ifFalseValue;

Page 11: What’s new in SIL 3.0? - Kepler-Rominfo€¦ · What’snew in SIL 3.0? Contact Florin Haszler Tel: +40 21 233 10 80 Email: florin.haszler@kepler-rominfo.com

Exception Handling

• SIL variables can be thrown as errorsstring err = “Error message”;

throw err;

• try-catch blockstry {

// instructions

} catch <type> var {

// handle error

} catch {

// handle error

}

• If <type> is specified, will only catch SIL objects of the specified type

• If <type> is NOT specified, will catch any exceptions (SIL errors or Java exceptions)

Page 12: What’s new in SIL 3.0? - Kepler-Rominfo€¦ · What’snew in SIL 3.0? Contact Florin Haszler Tel: +40 21 233 10 80 Email: florin.haszler@kepler-rominfo.com

Find out more

• Documentation

http://confluence.kepler-rominfo.com

• Feedback & suggestions

[email protected]