Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
163
Добавлен:
11.05.2015
Размер:
4.73 Mб
Скачать

SQL Expressions Add method

Declaration

procedure Add(ExpressionName: TCrExpressionName);

Type

TCrExpressionName = string;

Description

The Add method manually adds an item to the Expressions object and sets the internal index to that item. It requires an Expression name as a parameter, which should be a name corresponding to an Expression already created in the Report.

The steps to using the Add method with Expressions are:

1Add an item to the Expressions object (you must specify the Expression Name).

2Fill the item's Expression property with a value.

3When Execute is called, the properties will be sent to the Print Engine.

NOTE: It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Expression names are correct for the current Report.

Example

The Add method can be used to manually add an item to the Expressions object, instead of using Retrieve:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Expression Name - must be same as in Report} Crpe1.SQL.Expressions.Add('Expression1'); Crpe1.SQL.Expressions.Expression.Text := '{fn UCASE(employee.`lastname`)}';

Crpe1.Output := toWindow;

Crpe1.Execute;

SQL Expressions Check method

Declaration

function Check: boolean;

VCL Reference

626

Description

The Check method can be used to check the syntax of an Expression before running the Report. Check returns a boolean value:

True :Expression is good.

False :Expression has an error.

Example

The following code loops through all the Expressions, checking each one:

var

cnt: integer; begin

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.SQL.Expressions.Retrieve;

for cnt := 0 to (Crpe1.SQL.Expressions.Count - 1) do begin

if not Crpe1.SQL.Expressions[cnt].Check then ShowMessage('Error in Expression #' + IntToStr(cnt));

end; end;

SQL Expressions Clear method

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the Expressions object. It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear method is only applied to the Expressions object of the current Report/Subreport specified in the Subreports object. Therefore, to clear all the Expressions of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear method.

Example

This code clears the Expressions for the main Report (assuming the default state of Subreports[0]):

Crpe1.SQL.Expressions.Clear;

VCL Reference

627

This code clears the Expressions for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do begin

Crpe1.Subreports[cnt];

Crpe1.SQL.Expressions.Clear; end;

SQL Expressions CopyFrom method

Declaration

function CopyFrom(Source: TCrpeSQLExpressions): boolean;

Description

The CopyFrom method copies the Expressions property values from another TCrpeSQLExpressions object. It is similar to Delphi's Assign method. It is useful for transferring or temporary storage of values.

Example

The following example copies all the Expressions property values to a temporary TCrpeSQLExpressions object:

var

tempExpressions : TCrpeSQLExpressions; begin

tempExpressions := TCrpeSQLExpressions.Create; tempExpressions.CopyFrom(Crpe1.SQL.Expressions); {...later, when finished with the temp object...} tempExpressions.Free;

end;

SQL Expressions Count method

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the Expressions object. It is handy for setting up loops to make similar changes to each item.

VCL Reference

628

Example

The Count method is useful for looping constructions. You would normally want to call Retrieve first:

var

cnt: integer; begin

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.SQL.Expressions.Retrieve;

for cnt := 0 to (Crpe1.SQL.Expressions.Count - 1) do begin

if not Crpe1.SQL.Expressions[cnt].Check then ShowMessage('Error in Expression: ' + IntToStr(cnt));

end; end;

SQL Expressions Create method

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the Expressions object, and does not need to be called in code, unless you are using the CopyFrom method to store Expressions data to a temporary object:

var

tempExpressions : TCrpeSQLExpressions; begin

tempExpressions := TCrpeSQLExpressions.Create; tempExpressions.CopyFrom(Crpe1.SQL.Expressions);

end;

SQL Expressions Delete method

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the Expressions object. The "nIndex" parameter represents the order of the item in the Expressions object.

VCL Reference

629

Соседние файлы в папке crystal