Definitions
Each ECL definition
ECL definition
is the basic building block of ECL. A definition specifies
what is done but not how it is to
be done. Definitions can be thought of as a highly developed form of
macro-substitution, making each succeeding definition more and more highly
leveraged upon the work that has gone before. This results in extremely
efficient query construction.
All definitions take the form:
[Scope] [ValueType] Name
Name
[ (parms) ] := Expression
Expression
[ :WorkflowService] ;
The Definition Operator
Definition Operator
( := read as “is defined
as”) defines an expression. On the left side of the operator is an optional
Scope
Scope
(see Attribute
Visibility), ValueType
Value Type
(see Value
Types), and any parameters
parameters
(parms) it may take (see Functions (Parameter Passing)). On the right side is
the expression that produces the result and optionally a colon (:) and a
comma-delimited list of WorkflowServices (see Workflow Services). A definition must be explicitly
terminated with a semi-colon (;). The Definition name can be used in
subsequent definitions:
MyFirstDefinition := 5; //defined as 5
MySecondDefinition := MyFirstDefinition + 5; //this is 10
Definition Name Rules
Definition name
Definition Name
s begin with a letter and may contain only letters, numbers,
or underscores (_).
My_First_Definition1 := 5; // valid name
My First Definition := 5; // INVALID name, spaces not allowed
You may name a Definition with the name of a previously created
module in the ECL Repository, if the attribute is defined with an explicit
ValueType.
Reserved Words
ECL keywords
ECL keywords
, built-in functions and their options are reserved
words
Reserved Words
, but they are generally reserved only in the context within
which they are valid for use. Even in that context, you may use reserved
words as field or attribute names, provided you explicitly disambiguate
them, as in this example:
ds2 := DEDUP(ds, ds.all, ALL); //ds.all is the 'all' field in the
//ds dataset - not DEDUP’s ALL option
However, it is still a good idea to avoid using ECL keywords as
attribute or field names.
Definition Naming
Use descriptive names for all EXPORTed and SHARED Definitions. This
will make your code more readable. The naming convention adopted
throughout the ECL documentation and training courses is as
follows:
Definition Type Are Named
Boolean Is...
Set Definition Set...
Record Set ...DatasetName
For example:
IsTrue := TRUE; // a BOOLEAN Definition
SetNumbers := [1,2,3,4,5]; // a Set Definition
R_People := People(firstname[1] = 'R'); // a Record Set Definition