123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
- "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
- <sect1 id="Attribute_Definition">
- <title>Definitions</title>
- <para>Each ECL definition<indexterm>
- <primary>ECL definition</primary>
- </indexterm> is the basic building block of ECL. A definition specifies
- <emphasis>what </emphasis>is done but not <emphasis>how</emphasis> 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.</para>
- <para>All definitions take the form:</para>
- <para><emphasis role="bold">[</emphasis><emphasis>Scope</emphasis><emphasis
- role="bold">] [</emphasis><emphasis>ValueType</emphasis><emphasis
- role="bold">] Name<indexterm>
- <primary>Name</primary>
- </indexterm> [ </emphasis>(<emphasis>parms</emphasis>) <emphasis
- role="bold">] := Expression<indexterm>
- <primary>Expression</primary>
- </indexterm> [ </emphasis><emphasis>:WorkflowService</emphasis><emphasis
- role="bold">] ;</emphasis></para>
- <para>The Definition Operator<indexterm>
- <primary>Definition Operator</primary>
- </indexterm> (<emphasis role="bold"> :=</emphasis> read as “is defined
- as”) defines an expression. On the left side of the operator is an optional
- <emphasis>Scope<indexterm>
- <primary>Scope</primary>
- </indexterm></emphasis> (see <emphasis role="bold">Attribute
- Visibility</emphasis>), <emphasis>ValueType<indexterm>
- <primary>Value Type</primary>
- </indexterm></emphasis> (see <emphasis role="bold">Value
- Types</emphasis>), and any parameters<indexterm>
- <primary>parameters</primary>
- </indexterm> (<emphasis>parms</emphasis>) it may take (see <emphasis
- role="bold">Functions (Parameter Passing)</emphasis>). On the right side is
- the expression that produces the result and optionally a colon (:) and a
- comma-delimited list of <emphasis>WorkflowServices</emphasis> (see <emphasis
- role="bold">Workflow Services</emphasis>). A definition must be explicitly
- terminated with a semi-colon (;). The Definition name can be used in
- subsequent definitions:</para>
- <programlisting>MyFirstDefinition := 5; //defined as 5
- MySecondDefinition := MyFirstDefinition + 5; //this is 10</programlisting>
- <sect2 id="Attribute_Name_Rules">
- <title>Definition Name Rules</title>
- <para>Definition name<indexterm>
- <primary>Definition Name</primary>
- </indexterm>s begin with a letter and may contain only letters, numbers,
- or underscores (_).</para>
- <programlisting>My_First_Definition1 := 5; // valid name
- My First Definition := 5; // INVALID name, spaces not allowed</programlisting>
- <para>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
- <emphasis>ValueType</emphasis>.</para>
- </sect2>
- <sect2 id="Reserved_Words">
- <title>Reserved Words</title>
- <para>ECL keywords<indexterm>
- <primary>ECL keywords</primary>
- </indexterm>, built-in functions and their options are reserved
- words<indexterm>
- <primary>Reserved Words</primary>
- </indexterm>, 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:</para>
- <programlisting>ds2 := DEDUP(ds, ds.all, ALL); //ds.all is the 'all' field in the
- //ds dataset - not DEDUP’s ALL option</programlisting>
- <para>However, it is still a good idea to avoid using ECL keywords as
- attribute or field names.</para>
- </sect2>
- <sect2 id="Attribute_Naming">
- <title>Definition Naming</title>
- <para>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:</para>
- <programlisting><emphasis role="bold">Definition Type</emphasis> <emphasis
- role="bold">Are Named
- </emphasis>Boolean Is...
- Set Definition Set...
- Record Set ...DatasetName</programlisting>
- <para>For example:</para>
- <programlisting>IsTrue := TRUE; // a BOOLEAN Definition
- SetNumbers := [1,2,3,4,5]; // a Set Definition
- R_People := People(firstname[1] = 'R'); // a Record Set Definition</programlisting>
- </sect2>
- </sect1>
|