DESCRIPTION OF EVALLIB.
LIBRARY IN DETAILS.


Eval library Eval - defined functions Unit EvalDefs  

Library consists of these components and units:
COMPONENT DESCRIPTION
TEval basic component, which includes substance able to provide analysis and summarizing of terms
TEvalList able to apply for a group of terms, it is suitable when applying more cells into one data table
TEvalDBNavigator wide-spread TDBNavigator which provides movement all around the suitable records
TEvalFnPanel user's database of terms and conditions. It consists of list box with many function groups and after entering the group there will be a list of functions displayed
TEvalParams provides editation of parameters of the entered function, provides re-entering the function after becoming parameter itself
TEvalHistory combo box is used when re-opening the old terms and conditions or when re-using them
TEvalFnGroupCombo TEvalFnGroupList used when choosing groups of functions (string functions, numeric functions, ...)
TEvalFnListBox used when choosing the concrete function of the list
   
UNITS  
Eval basic unit, the seat of the library EVAL and its TEval component
EvalDefs working with the list of functions, exporting this list into HTML
EvalRes consists of descriptions of functions, titles of windows, ... When localization of EVAL libraries into home language is needed, it is enough to modify texts in this unit and then you should recompile the library
EvalCom consists of components which are based on the combo boxes and list boxes (TEvalFnGroupList, TEvalFnGroupCombo, TEvalFnListBox, TEvalTEvalHistory)
EvalPar component called TEvalParam - provides setting up the user's parameters of chosen function
EvalSub Form TSubFunctionFmt which provides applying for completed function by parameters and each parameter can be a function again - in this case it will be automatically re-called. The result is TSubFunctionFmt.Expression. 

function DialogExpression(_Level:Integer; _DataSet:TDataSet):String - provides applying for completed function by using the TSubFunctionFmt form.

EvalReg provides registration of all the Eval components
EvalNav component of TEvalDBNavigator
EvalExPanel component of TEvalFnPanel - used when choosing a function from the list of functions, also gives a description of the function and parameters
EvalFn additional functions which are not situated in Delphi. They are used in order to make the Eval library larger.
Evalist component of TEvalList.


 



DESCRIPTION OF THE COMPONENTS IN DETAILS.


TEval
function Evaluate : Variant;
This function can summarize the term and is able to bring the result back as a changeable term - it is called from AsFloat, AsString, AsDate...
procedure Prepare;
it makes an analysis of the given condition and is able to make a control of the syntax. It creates an intern tree of posrtfix terms which are used for summarizing. This function is not for everyday use, because it is called in an intern way when changing the character of Expression.
procedure UnPrepare;
it can destroy the intern tree of post fix terms, but it is not necessary to call up this function all the time.
property Prepared:Boolean
it shows if the term has already been summarized or not. You will probably not need to use this function, because after the change of Expression follows Prepare.
WORKING WITH THE INTERN CHANGEABLE TERMS.
They are used to simplify and accelerate working with TEval. When summarizing of one single term with many changeable terms /which are almost constant/ is needed, you should use these changeable terms. 

Example : you need to calculate sin / DegToRad / x// for x from 0 to 360. If you used the function Expression := 'Sin/../, Evaluate,.... you would make the calculation slower. Therefore we use changeable terms. This term will be X and then we make a calculation. 

var i:Integer;
    y:Double;
begin
    EVAL.AddVariable('X',0);
    EVAL.Expression:='Sin(DegToRad(X))';
    for i:=0 to 359 do begin
        EVAL.SetValue('X',i);
        y:=EVAL.AsFloat;
    end;
end;
function AddVariable( Name : string; value : Variant) : Integer;
It is able to add to the list of changeable terms a single changeable term with given name and value. It gives back the index of added changeable value into the field of changeable values.
procedure RemoveVariable ( Name : string);
It is able to delete the specific changeable value from the list of them.
procedure RemoveAll;
It deletes all the changeable terms from the list of them.
procedure SetValue ( Name : string; NewValue : Variant);
It creates new value for the existing changeable term.
function GetValue ( Name : string) : Variant;
It gives the just applied value for the changeable term back.
function FindVariable ( Name : string) : integer;
It finds the changeable term and puts it back into the field of them.
property VarCount : integer
The account of defined changeable terms.
property VarNames[i :Cardinal] : string
The field which contains the names of the changeable terms.
property VarValues[i :Cardinal] : Variant
The field which contains the values of the changeable terms.
function RecordCount : Integer;
It gives back the amount of records which are suitable for the condition. It can last longer according to the greatness of the table and filter. If no filter has already been applied, it gives back the total number of records in the table.
property OnProgress : TProgressEvent
TProgressEvent = procedure ( Sender : TObject; Position : Integer) of object;

it creates the position of function RecordCount. If the table is large, the operation can last longer, therefore it would be suitable to show some kind of index. That is possible in OnProgress. The value of Position is given in percents. 
function CreateCalcField ( FieldName : string; Size : Word; Expr : String ) : TField;
This function adds a new calculated field into the dataset 
Field Name - the name of the field
Size - the greatness of the field

Expr - how to calculate the value of the field
 
When using this function again, the last field will be deleted. When more calculated fields for one dataset are needed, use more components TEval or one component of TEvalList.
 
procedure First, Prior ,Next ,Last;
These methods are used when movement for suitable records according to the condition is needed / the same as for dataset if no condition is applied/. If there are more than 50 records unsuitable for the condition in the movement, the cursor will change into Filter Cursor.
FilterCursor:TCursor
This cursor is used when moving among the records or when calculating the amount of the records by RecordCount function.
Entering the result of term or function:
property AsBoolean:Boolean 

property AsDateTime : TDateTime
property AsFloat : Double
property AsInteger : Integer
property AsString : string
property AsVariant : Variant
property Value : Variant
property Field : TField, ReadOnly
This field must have been defined as a field calculated by CreateCalcField function.
function Integral(FN:String; VARIABLE:String; X_MIN,X_MAX:Double; Steps:Integer):Double;
It calculates the integral of function fn in the margin from X_MIN to X_MAX. It is calculated for Steps steps. Function FN should contain changeable term VARIABLE, which is a master when calculating an integral.

Example for calling : Integral ( 'X*X','X',1,2,1000).
property Expression : string
This is the term which should be summarized. This line can be created by the component for creation of terms ( TevalFnPanel, TEvalFnGroupCombo,..) or you can directly find a master for the line.

Examples - terms
Sin ( RadToDeg ( Alfa))
Copy ( Name ,2,4) + Left ( City , 5)
Examples - conditions
ID > 100 and Copy ( Name ,1,3) = 'SVK'
Between (ID ,1 ,100)
property EnableDataSet : Boolean
It allows/ forbids using the dataset. Forbidding is used when the name of the changeable value from the table would be the same as the name of the changeable value/in the list of changeable values in TEval/.
property DataSet : TDataSet
It is dataset used by component of TEval for summarizing. It is able to use changeable values of it when using the name of the field, for example CITY , ID , NAME...
property UseDecimalSeparator : Boolean
If TRUE has already been applied, the spot or comma is mind to be according to the set up of localization in Windows(',' or'.')
 
property NullOnCalcError : Boolean
If there is a mistake in the summarizing and the program is set on FALSE, it shows the mistake in error window. It is unpleasant if the founded error is connected with new summarizing. If there is a mistake in the summarizing and the program is set on TRUE, the empty value will be brought back.
property FilterCursor:TCursor
This cursor will be shown by operations difficult in time.
 
TEvalList
It is the same as TEval but it contains the list of terms. It can summarize more terms for one dataset. It is more advantageous than working with TEval components. It contains also methods for manipulation with field of terms. There is one TEval component for each term in the field. They have just common dataset.
function Add ( exp : string ) : Integer
It adds new term to the list of terms.
procedure Insert (pos : integer; exp : string)
It puts new term on the position given by parameter pos.
procedure Delete ( pos : integer)
It deletes the term on the position of the last parameter.
procedure Clear
It deletes all the terms.
function CreateCalcField ( FieldName : string; FieldClass : TFieldClass; Size : Word; Expr : String ):TField
It creates a new object in the type of TField and adds it to the dataset with parameters - FieldName, FieldClass, Size. The calculation will be done according to the parameter Expr.
property Expressions [ pos : integer ] : string
It is a field of defined terms. Indexes of the fields Expression Evals and Fields are the same.
property Evals [ pos : integer ] : TEval
The Teval field of components which adds to each term a component of TEval.
property Fields [ Index : Integer ] : TField
This is the field of calculated changeable terms which are defined by CreateCalcField.
As for the same index of these fields, this can happen: Fields [i] = nil

For example when:

EvalList.Add ( 'Sin ( X)');

EvalList.CreateCalcField ( 'CF1', TStringField, 20,' Copy ( CITY, 1,3)+''-''+ State');
EvalList.Add ('Cos ( X)');

In this case, the Fields [0] and Fields [2] nil, Fields [1] will be in function of TField.
property Count : integer
The amount of defined terms
property EnableDataSet : Boolean

property ForceString : Boolean
property DataSet : TDataSet
These properties are the same as by the TEval component. Their setting up means the same character for the whole field.
 
TEvalDBNavigator
TDBNavigator (extended TDBNavigator) is really easy component useful when filtering the records.
property EvalComp : TEval
It defines the condition for the filter. Its dataset is probably the same as EvalDBNavigator's one. When entering the button EvalDBNavigator, there will be the method EvalComp.Prior, EvalComp.Next activated.
property Filtered:Boolean
It turns on and off the filter for the dataset. It doesn't influence the creation of the suitable records. See Filters via TEval)
 
TEvalFnPanel
It provides choosing the function from the list of functions. On the left side there is a list box with a list of the groups of functions according to their description. On the right side there would be the functions of chosen group shown. It is also possible to show the description of the function. It is allowed to use the component simultaneously with the TEvalParams components in order to gain total term with all the parameter's.
property FunctionType : TFnType
It allows to apply for the new group of functions.
property SelectedFunction : TEvalSymbol
It allows to apply for the new function.
property FunctionLabel : String
It gives back the short description of function's character. If VisibleHint is selected on TRUE, there will be description shown all the time.
property FunctionGroupLabel : String
It gives back the title of the latest chosen group of functions.
property VisibleExample : Boolean
If True is selected then there will be shown types of parameters of the function.
property VisibleHint :Boolean
-see FunctionLabel
property OnFunctionGroupChange : TNotifyEvent
It allows to take advantage of changing the group.
property OnFunctionChange :TNotifyEvent
It allows to take advantage of changing the function.
Example of component TEvalFnPanel :
 
TEvalParams
It is used to give parameters of a concrete function. According to the chosen function there are parameters displayed. Their description is situated in the Edit Box which includes also actual type of the term. It is also possible to write there something yourself. The thing you write will be used as a new term or condition.

Component includes one TEdit which displays the term. It also includes max. 6 combo boxes which are used by the users in order to give some parameter's. There is always one button in front of the combo box and it is used in order to give some sub terms.

Level : Integer;

It shows the level of using the function. The basic level is 0. When by choosing a parameter pressing a button on the left from the field, there will be window for giving sub function displayed with its level 1.
property Eval : TEval
TEval component's field Variable and its quality DataSet will be used in order to create a list of changeable terms, which will be then displayed as possible values for the suitable parameter.
property SelectedFunction : TEvalSymbol
It is chosen/selected/function. It should be used with TEvalFnPanel.EvalParams.SelectedFunction = EvalFnPanel.SelectedFunction
property Expression : String
It is just created term which can be added to TEval.Expression
property OnFunctionChange : TNotifyEvent
An event called when changing the group.
property OnSubfunction : TSubFunctionEvent
TSubFunctionEvent = procedure(Sender:TObject; ParamBox : TComboBox;

var Dialog : Boolean) of object;
It is an event called when using the sub function/entering the button on the left side of the parameter's field/. The user is also allowed to click the value of Dialogue on FALSE which means that there will be no sub function's window displayed. It is suitable when the user wants to simplify the term.

Example of component TEvalParams :

 
 
TEvalHistory
Component providing a quick choice from the group of saved terms and conditions. Term or condition could have their own name which will be displayed in user's combo box. Program is able to give a description of the event in OnChange. The qualities of Eval can be set up by its components. The terms are saved in the file called FileName. There can be many terms in one file, even if they are of various types or they are used in various datasets. Quality called FileNameKey is used to separate the terms according to the applied conditions.
 
property Eval : TEval
This is Veal's component connected with TEvalHistory. When changing a term there will be EVAL Expression set up for the suitable value.
property FileName : String
The name of the file which the terms will be given to.
property FileNameKey : String
The name of the key that will separate and save the terms. The line of the file shall include : key, separator, term's title, separator, the term.
property Caption : String
It gives back the title of the term and it can be seen by user.
procedure LoadItems, procedure SaveItems
It works with terms and their titles as for their set up in the FileName and FileNameKey.
procedure AddWithQuestion ( Expr : String )
It adds to the list term Expr. and asks in dialogue's window for the title.
procedure AddCond ( Expr : String; Str : String)
Adds term Expr. with the title Str. to the list of terms. Both functions (AddWithQuestion a AddCond) uses Eval.Expression, if Expr is null string and Eval<>nil
function Expression : String
It gives back the latest term.
function GetExpressionByIndex (idx : Integer) : String
The term is given back according to the index. Idx should be in the margin from 0 to Count - 1.
function GetCaption : String
It gives back the title of the latest term.
function GetCaptionByIndex ( idx : Integer) : String
It gives back the title of the latest term according to the index. Idx should be in margin from 0 to Count - 1.
 
TEvalFnGroupCombo, TEvalFnGroupList
These are components used to choose group of functions, it is usual combo box which contains also predefined name of the group. The only strange quality is property FunctionType : TFnType. This quality enters the chosen group of functions. To join with another components the user should use event OnChange. See also EvalDefs
 
TEvalFnComboBox, TEvalFnListBox
These are components used to choose a concrete function. It is usual combo box, actually list box with predefined names of the functions.
Properties :
property FunctionType : TFnType - enters chosen function type
property SelectedFunction : TEvalSymbol - the just chosen function

To join with other components the user should use event OnChange. 
See also EvalDefs

 
 
 

QUICK SEARCH - FILTERING BY TEval, or TEvalList.

  1. The user creates or by application saves to TForm the component of TEval and the user fills up its qualities - Expression, DataSet
  2. To display in DBGrid the user shall fill up event OnDrawColumnCell according to the example. When using RXLibrary the user can also use OnGetCellProps.
procedure TForm2.FILTER_GRDrawColumnCell ( Sender: TObject;
       const Rect: TRect; DataCol: Integer; Column: TColumn;
       State: TGridDrawState);
begin
      if (EVAL_FILTER.Expression<>'') and (EVAL_FILTER.AsBoolean) then
           GRID.Canvas.Brush.Color := clYellow;
      GRID.DefaultDrawColumnCell ( Rect, DataCol, Column, State);
end;
 

 
 









Unit EvalDefs.


It contains a defining field of groups of functions with their names, description of their parameter's and their separation according to their qualities. It contains also a few types, functions and procedures which are used to work with the list of functions. It is not allowed to add a function to this list straight ahead. when adding a function, a lot of operations described in the following part should be done.
 
Working with the list of groups of functions.
TFnType fnOperators logical operations
  fnString String operations
  fnNumber functions with numbers
  fnDate Functions with date & time
  fnGonio Goniometric & Geometric
  fnFinancial Functions working with money
  fnConversion Conversional functions
  fnFile Functions working with files and their names
  fnMisc various functions that can not be added anywhere else
  fnAll all the functions, used by procedures and to apply for all the functions short version - fnOperators, fnGonio ...
  fnNone no function
     
TFnTypes   Set of TFnType
     
procedure GetFunctionGroup ( L : TStrings);   It fills the list L by kist of groups of functions. L.Strings contains the names /titles/ of groups and L
function GetFunctionGroupName ( T : TFnType ) : String; It gives back the name if the group of functions according to the identification.

 
 
LISTS OF FUNCTIONS AND THEIR USE.
TEvalSymbol Function's identification which is used straight for the gist of Eval library in order to identification the just worked on function. The list of functions is dependent on the version of the library. See List of Functions.
TDefFun This record is used when working with functions. The user is not allowed to use it straight, just by defined functions.
TDefFun = Record
  Name    : String;      // function's name
  Params  : ParamString; // parameter's list
  Kind    : TFnType;     // function's group
  FT      : TEvalSymbol; // id of function 
  Hint    : String;      // description of function
  ParHint : String;      // parameter's description with separator '|'                         
End;
GetFunctionCount
function GetFunctionCount : Integer 
It gives back the amount of functions supported by library EVAL.
 
GetFunctionByName
function GetFunctionByName ( Name : String ) : TDefFun; 
It gives back the function according to its name.
 
GetFunctionBySymbol
function GetFunctionBySymbol ( fn : TEvalSymbol ) : TDefFun;
It gives the function back according to its id.
 
GetFunctionByIndex
function GetFunctionByIndex ( idx : Integer ) : TDefFun;
It gives the function back according to its index of function's field.
 
GetFunctionList
procedure GetFunctionList ( L : TStrings);
It fills the list L by lists of all the functions and parameter's.
 
GetFnCall
function GetFnCall ( idx : Integer ) : String;
It gives the description of parameter's back with given index.
 
GetFunctionNames
procedure GetFunctionNames ( fn : TFnTypes; L : TStrings);
It fills the list L by the list of functions suitable according to their parameters.
Integer ( L.Objects / i/) is also index of the given function from the list of functions.
This index can be also used by functions GetFnCall and GetFunctionByIndex in 
order to gain closer information's about the function.
   

 
 
EXPORT OF THE LIST OF FUNCTIONS TO THE HTML FORMAT.
type TEvalHtml
fnEvalHtmlTable name and description of the function in the table format
fnEvalHtmlTableWithCall description of function and parameters in table format
fnEvalHtmlList export of the list in numerous format
fnEvalHtmlText export in the usual text's format
  procedure CreateFunctionHTML procedure CreateFunctionHTML ( FileName : String; Style : TEvalHtml)
Export of the list of functions to the HTML file.