Constants
In all DSL files it is possible to define constants. If the target version supports the object class COOSYSTEM@1.1:TypedExpression, these constants are part of the software component and can be reused in other software components.
Example |
const DrinkType[] AlcoholicDrinksConst = [DT_SHOT, DT_LONGDRINK, DT_SOUR, DT_HIGHBALL]; const DrinkType[] NonAlcoholicDrinksConst = [DT_SOFTDRINK, DT_WATER, DT_JUICE]; const SomeLines LineConst = { line1 = "First 1", line2 = "Second line" } |
These constants then can be used in generic assignments or inside of expressions.
Example |
const SomeLines LineConstEx = { LineConst, line2 = "Second line override", line3 = "Third line" } instance Bar MyDefaultBar { barinitwith = AlcoholicDrinksConst; barinitwithout = [DT_WATER, NonAlcoholicDrinksConst]; barinfo = { LineConstEx, line1 = "First line from init" } } instance Expression ex { exprtext = expression { DrinkType aDrink = DT_FIZZ; if (aDrink in AlcoholicDrinksConst) { coort.Trace("this drink contains alcohol", aDrink); } else if (aDrink in NonAlcoholicDrinksConst) { coort.Trace("this drink does not contain alcohol", aDrink); } else { coort.Trace("this drink might contain alcohol", aDrink); } SomeLines myline = { LinesConst, line3 = "a new line" }; SomeLines[] mylines = [ LinesConst, { line3 = "a new line" } ]; mylines = LinesConst; } } |