syntax constructions
--------------------

REPORT [SPOOL <spool_file_name> [APPEND]] 
       [PAGESIZE <page_size> [NOALIGN]]
       [TITLE <report_title>];

Description
-----------

Describes common parameters of the report. This construction MUST BE A FIRST AND ONCE
construction of the report.

<spool_file_name> - name of file to spool report
APPEND - means what spool file will be appended (in this case spool file must exist)
<page_size> - size of page in lines
NOALING - if this keyword follows the <page_size>, reporter will add symbol #12 (chr = 12)
          at the and of each page, otherwise each page will be added to <page_size> by 
          blank lines
<report_title> - not used internally. This value can be accesses via Title property of
                 Delphi component

ATTENTION
---------

Report is finish rather all it's data sets are at EOF state or all data sets are skips
the current step! 

Example
-------

report spool "spool.txt" pagesize 60 noalign title "My first report";

--------------------------------------------------------------------------


QUERY [<query_name>] 
      [FETCH BY <rowset_size>]
      [FETCH WHEN <expr_name>]
      [RESET WHEN <expr_name>]
      [UPDATES PARAMS] 
      [ALIAS "<alias_name>" | REF "<data_set_name>"]
{
  <query_body>
};


Description
-----------

Describes data source for the report. Reporter supports a multiple query
definitions.

<query_name> - name of query. Used to access to query through built-in functions.
FETCH WHEN <expr_name> clause - Defines expression, what value will sign to reporter
                                how the records will be fetched. If the value of 
                                <expr_name> is TRUE on given 
                                step - the reporter will fetch next record from this 
                                data set, otherwise reporter will not fetch next records. 
                                If your report query the field value from the 
                                data set skipped the current step, it receive the NULL 
                                value (it also get NULL value of field, when reporter 
                                reaches the end of data set.
RESET WHEN <expr_name> clause - Defines expression what sing to reporter to reopen query
UPDATES PARAMS clause - if the query is used for call stored subprogram, wich contains
                        out parameters you can use this clause to apply returned values to
                        reporter's expressions
ALIAS "<alias_name>" - normally each query executed through TOracleQuery from DOA package,
                       but if your application works with BDE you can specify the "database
                       name" as <alias_name> at ALIAS clause. "database name" is the 
                       DataBaseName property of the TDatabase component in your application.
                       In this case the query will be executed using TQuery component. 
                       Example: 
                       --------
                        query q1 ALIAS "DBTest"
                        {...};

REF "data_set_name" - this clause is usefull if you have an opened TDataSet component. 
                      "data_set_name" is the value of Name property of the data set.

<query_body> - SQL statement. WARNING! You shouldn't specify semicolon character (';')
               after the statement. You can use placeholders in then SQL statement, for
               exapmle:
                  query q1 {
                   select * from emp where empno = :EMPNO
                  };
               in this case expression synonym EMPNO must exists. See below!

      
--------------------------------------------------------------------------

CONTROL [<control_name>] 
        [ALWAYS ON PAGE] 
        [FINISH PAGE [DISABLE FOOTER]]
        [TURN WHEN <expr_name>] 
        [ORDER HIGHEST | HIGH | NORMAL | LOW | DEFAULT]
{
  <control_body>
};

Description
-----------

The CONTROL structure is used for define reporter's output

--------------------------------------------------------------------------

PARAM  {param_name_1 [mask "<mask>"]}[, param_def_2];

Description
-----------

--------------------------------------------------------------------------

<expr_name> := <expr_body> [WHEN|BEFORE|AFTER <expr_name> RESET TO <expr_name>]; 

Description
-----------

Defines synonym for complex expression. It also defines behavior of the
accumulative expressions.

Example
-------

sum1 := sum(q1->cost); this expression accumalates SUM of COST field of query Q1 until
                       report ends.

Expr := Round(q1->cost * 52 / 100, 2);
                       this expression calculates 52% of COST field of Q1 query and 
                       rounds it to 2 digits after the dot.



--------------------------------------------------------------------------

SUBREPORT <name> AT FILE <file_path> 
     [USE PARENT OUTPUT] 
     [RUN WHEN <expr_name>]
     [NOWAIT];

Description
--------------------------------------------------------------------------


built-in functions
------------------


float SUM(float Expr)
float MAX(float Expr)
float MIN(float Expr)
float AVG(float Expr)
BOOL  CHECK(variant Expr)

//arithmetics plus or string concatination
variant operator +(variant Expr1, variant Expr2)
variant operator ||(variant Expr1, variant Expr2)

//arithmetic minus
float operator -(float Expr1, float Expr2)

//arithmetic multiplication
float operator *(float Expr1, float Expr2)
//
float operator /(float Expr1, float Expr2)

float operator -(float Expr)

BOOL operator AND(BOOL Expr1, BOOL Expr2)
BOOL operator OR(BOOL Expr1, BOOL Expr2)
BOOL operator XOR(BOOL Expr1, BOOL Expr2)
BOOL operator NOT(BOOL Expr)

variant operator -> (QUERY QueryName, FIELD FieldName)

BOOL operator > (variant Expr1, variant Expr2)
BOOL operator >= (variant Expr1, variant Expr2)
BOOL operator < (variant Expr1, variant Expr2)
BOOL operator <= (variant Expr1, variant Expr2)
BOOL operator = (variant Expr1, variant Expr2)
BOOL operator <> (variant Expr1, variant Expr2)

variant operator =>(SUBREPORT RepName, variant Expr)

variant OLD(variant Expr)
BOOL PageStart()
BOOL PageFinish()
BOOL ReportStart()
BOOL ReportFinish()

int PageNum()

variant IF(BOOL CaseExpr, variant TrueExpr, variant FalseExpr)
variant NVL(variant TestExpr, variant ExprIfNULL,
                              variant ExprIfNotNULL)

BOOL const FALSE SingleRowed(QUERY QueryName)
int RowsFetched(QUERY QueryName)
BOOL EOF(QUERY QueryName)
BOOL Empty(QUERY QueryName)

string LeftStr(string Expr, int Pos)
string RightStr(string Expr, int Pos)
string SubStr(string Expr, int Pos, int Len)
string Replicate(string Expr, int Count)
string Format(string Template, variant Expr)
string LTrim(string Str)
string RTrim(string Str)
string Trim(string Str)
int Pos(string StringExpr, string TestString)
int Length(string Str)

BOOL ControlProcessed(CONTROL ControlName)
BOOL QueryProcessed(QUERY QueryName)
BOOL SubreportProcessed(SUBREPORT SubRepName)

string CHR(int Code)


variant DECODE(variant TestExpr,
               variant TestValue1, variant ReturnValue1,
               [variant TestValueN, variant ReturnValueN,]
               variant ElseValue)

DateTime ToDate(variant Expr)
float ToNumber(variant Expr)
string ToChar(variant Expr)
int PageHeight()
int CurPageHeight()
int ExtraHeight()
int ExtraUsed()
int ControlHeight(CONTROL ControlName)

float Round(Float Expr, int Precision)


