how to add this function

I am a beginner in Delphi
how How to add these function in fastreport


convert num to letter fr
//

function TForm1.convert(var Aconvertir,Devise:string):string;
var
C, D, centimes, dinars : string;
car : array [1..3] of string;
I, Y, Z : integer;
begin

If (Aconvertir='') then // si la chaine S est vide Erreur
begin
exit;
end ;
i:=0;// connaitre la position du separateur decimale
While not((Aconvertir=',') or(i > length(Aconvertir))) do
begin
i:=i+1;
end;
C:=copy(Aconvertir,i,1);
if C=',' then // s'il y a un nombre decimale
begin
D:=copy(Aconvertir,1,(i-1));
dinars:=enLettres(StrToInt(d));
centimes:=copy(Aconvertir, i+1, (Length(Aconvertir)-i));
// remplir un tableau car par des chaines vides
for y:=1 to 3 do // Le nombre de Zero permit et de 3 maxi !
begin
car[y]:='';
end;
y:=0; // Y represente le nombre de Zero apres le separateur decimale
z:=i+1;
While (Aconvertir[z]='0') or(z > length(Aconvertir)) do
begin
y:=y+1;
z:=z+1;
car[y]:='Zero ';
end;
//s'il y a des Zero apres le separateur decimale
if y>0 then
// il faut l'ecrire -- maxi 3 nombres ont la valeur egal ?  0, soit permit
centimes:=' et '+car[1]+car[2]+car[3]+enLettres(StrToInt(centimes))+' Centimes'
else // sinon il n'y a pas de zero ?  ecrire
centimes:=' et'+enLettres(StrToInt(centimes))+' Centimes';
result :=dinars+' '+ Devise +centimes+' .';
end
else // sinon lire la partie entiere
begin
D:=copy(Aconvertir,1,(length(Aconvertir)));
dinars:=enLettres(StrToInt(D));
result :=dinars+ Devise+' .' ;
end; // else

end;

//

Comments

  • gpigpi
    edited 9:40AM
    wrote:
    FastReport has a large number of built-in standard functions for use in report designs. FastReport also allows custom functions to be written and used. Functions are added using the ???FastScript??? library interface, which is included in FastReport (to learn more about FastScript refer to it???s library manual).

    Let's look at how procedures and/or functions can be added to FastReport. The number and types of parameters vary from function to function. Parameters of ???Set??? and ???Record" type are not supported by FastScript, so they must be implemented using simpler types, for instance a TRect can be passed as four integers : X0, Y0, X1, Y1. There is more about the use of functions with various parameters in the FastScript documentation.

    In the Delphi form declare the function or procedure and its code.

    function TForm1.MyFunc(s: String; i: Integer): Boolean;
    begin
    // required logic
    end;

    procedure TForm1.MyProc(s: String);
    begin
    // required logic
    end;

    Create the ???onUser??? function handler for the report component.

    function TForm1.frxReport1UserFunction(const MethodName: String;
    var Params: Variant): Variant;
    begin
    if MethodName = 'MYFUNC' then
    Result := MyFunc(Params[0], Params[1])
    else if MethodName = 'MYPROC' then
    MyProc(Params[0]);
    end;

    Use the report component???s add method to add it to the function list (usually in the ???onCreate??? or ???onShow??? event of the Delphi form).

    frxReport1.AddFunction('function MyFunc(s: String; i: Integer):Boolean');
    frxReport1.AddFunction('procedure MyProc(s: String)');

    The added function can now be used in a report script and can be referenced by objects of the ???TfrxMemoView??? type. The function is also displayed on the "Data tree" functions tab. On this tab functions are divided into categories and when selected a hint about the function appears in the bottom pane of the tab.

    Modify the code sample above to register functions in separate categories, and to display descriptive hints:

    frxReport1.AddFunction('function MyFunc(s: String; i: Integer): Boolean',
    'My functions',
    ' MyFunc function always returns True');
    frxReport1.AddFunction('procedure MyProc(s: String)',
    'My functions',
    ' MyProc procedure does not do anything');

    The added functions will appear under the category ???My functions???.

    To register functions in an existing categories use one of the following category names:

    - 'ctString' string function
    - 'ctDate' date/time functions
    - 'ctConv' conversion functions
    - 'ctFormat' formatting
    - 'ctMath' mathematical functions
    - 'ctOther' other functions

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.