25.3 - Use of the variables:25.31 - Variables nonrelated to the dataHere, one will add to our example, some variables nonrelated to data. They will make it possible for example to display the different wording according to the context.
For that, launch the editor of report then select the file menu and variables list.Add a category " Variables nonrelated " and the variable " Test " as explained the chapter 23 . The only difference is that you won't select a field of value but leave " [ None ] " (default value).
Publish one of your objects and add the variable " Test " as one saw in the previous chapters.Return under DELPHI (do not forget to record your report... ::O) ) then publish the OnGetValue event of the component " FrReport1 " and enter the following code.
procedure TForm1.frReport1GetValue(const ParName: String;
VAr ParValue: Varying; VAr fld: TField); / / valid Format with the French patch
begin
/ / Ici one treats the cases of nondependent variables
Yew UpperCase(ParName)=' TEST' then
ParValue:=' Answer: Variable " test1 " ';
end;Note: the field " fld " is not used to date, it is used to allow the formatting of data with DisplayFormat.25.32 - Calculated variables25.4 - Use of the formatsHere, one will see how to create a calculated variable. As before, create a new category (optional) and a variable " Test calculation ".
Select the new variable and on ComboBox value choose " Other " then " Expression ". This selection activates the area of data entry " Expression ".
Enter this: [ Table1."SIZE"]+[Table1."WEIGHT " ]
You thus obtain the sum of the fields of data " SIZE " and " WEIGHT ". You could have also put names of variables.You can use the following operators:
Type Logic >, <, BUT, AND, NOT, =, < >, > =, < = Mathematics -, *, +, MOD, / Moreover, you can dispos of the following functions standard:
Function Description Examples SUM Summon value SUM(Variable1) AVG Average AVG(Variable1) MIN Minimum MIN(Variable1) MAX Maximum MAX(Variable1) FORMATDATETIME ? ? FORMATFLOAT ? ? LOWERCASE Tiny NAMECASE ? ? STRTODATE Chains towards date STRTOTIME Chains around hour UPPERCASE Capital letter If that is not enough for you you can create your functions, but it is another chapter (thus to follow).
This chapter will enable you to define a format of display (and publishing) for the variables of a area. Before starting, you must know that a format is valid for the whole of the variables of a publishing area.
To display the editor of format, made a right click on an area and "Variable format ... ".
First ComboBox indicates the kind of data (Text, Number, Date, Time, Logic). The second allows to select a preset format.
The type " Text " does not allow any formatting and the type " Numbers " requires the number of decimal and the symbol comma to be used.Except the types " Text " and " Logic ", you can enter chains of formatting personalized respecting the formatting of DELPHI.
You can also include a concept of highlighting (" Intensified brightness ") what is very useful to emphasize data on a state. You can specify a condition to apply this highlighting. For that, use the key word " Value " to indicate the value of the variable. Here, one asks for a highlighting for all the values higher than 1000.
By defect, the highlighting is a simple boldfacing on white background. You can define these parameters for a area while clicking on the button
:
Then you can define the background color (of the whole area), the style and colour font to be used for a setting in " Intesified brightness".Note concerning the DisplayFormat property of the fields: Since version 05/05/99 of the French patch, this property is taken into account. If it is defined, it will be automatically taken into account.