Basics-ActionsandAttrib.xml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
  4. <sect1 id="Actions_and_Attributes">
  5. <title>Actions and Definitions</title>
  6. <para>While Definitions define expressions that may be evaluated, Actions
  7. trigger execution of a workunit that produces results that may be viewed. An
  8. Action may evaluate Definitions to produce its result. There are a number of
  9. built-in Actions in ECL (such as OUTPUT), and any expression (without a
  10. Definition name) is implicitly treated as an Action to produce the result of
  11. the expression.</para>
  12. <sect2 id="Functions_as_ActionsFunctions_as_Actions">
  13. <title>Expressions as Actions<indexterm>
  14. <primary>Expressions as Actions</primary>
  15. </indexterm></title>
  16. <para>Fundamentally, any expression in can be treated as an Action. For
  17. example,</para>
  18. <programlisting>Attr1 := COUNT(Trades);
  19. Attr2 := MAX(Trades,trd_bal);
  20. Attr3 := IF (1 = 0, 'A', 'B');</programlisting>
  21. <para>are all definitions, but without a definition name, they are simply
  22. expressions</para>
  23. <programlisting>COUNT(Trades); //execute these expressions as Actions
  24. MAX(Trades,trd_bal);
  25. IF (1 = 0, 'A', 'B');</programlisting>
  26. <para>that are treated as actions, and as such, can directly generate
  27. result values by simply submitting them as queries to the supercomputer.
  28. Basically, any ECL expression can be used as an Action to instigate a
  29. workunit.</para>
  30. </sect2>
  31. <sect2 id="Attributes_as_ActionsAttributes_as_Actions">
  32. <title>Definitions as Actions<indexterm>
  33. <primary>Definitions as Actions</primary>
  34. </indexterm></title>
  35. <para>These same expression definitions can be executed by submitting the
  36. names of the Definitions as queries, like this:</para>
  37. <programlisting>Attr1; //These all generate the same result values
  38. Attr2; // as the previous examples
  39. Attr3;</programlisting>
  40. </sect2>
  41. <sect2 id="Actions_as_Attributes">
  42. <title>Actions as Definitions<indexterm>
  43. <primary>Actions as Definitions</primary>
  44. </indexterm></title>
  45. <para>Conversely, by simply giving any Action a Definition name it becomes
  46. a definition, therefore no longer a directly executable action. For
  47. example,</para>
  48. <programlisting>OUTPUT(Person);</programlisting>
  49. <para>is an action, but</para>
  50. <programlisting>Attr4 := OUTPUT(Person);</programlisting>
  51. <para>is a definition and does not immediately execute when submitted as
  52. part of a query. To execute the action inherent in the definition, you
  53. must execute the Definition name you've given to the Action, like
  54. this:</para>
  55. <programlisting>Attr4; // run the previously defined OUTPUT(Person) action </programlisting>
  56. </sect2>
  57. <sect2 id="Debugging_Uses">
  58. <title>Debugging Uses</title>
  59. <para>This technique of directly executing a Definition as an Action is
  60. useful when debugging complex ECL code. You can send the Definition as a
  61. query to determine if intermediate values are correctly calculated before
  62. continuing on with more complex code.</para>
  63. </sect2>
  64. </sect1>