Using Custom Functions in FastReport in C++Builder 10.3.3

I notice that there is no in-built function for FastReport to verify the existence of a file but it is possible to add custom functions such as FileExists function. However all those functions are in delphi code. As I am using C++ Builder 10.3.3 I tried to convert it to C++ Builder code as shown below. Although code was successfully compiled the function did not appear the in FastReport IDE and on execution it gave massage that "Script error at 6.22: Undeclared Identitier: 'FrFileExists' ". I hope some one can help me to solve this problem and thank you very much.


// IN C++ BUILDER FORM, CREATE CUSTOM FUNCTION FOR FileExists

boolean __fastcall TForm1::FrFileExists(String FileName)

{

 return (FileExists(FileName.c_str()));

}


// CREATE THE "onUser" FUNCTION HANDLER FOR THE REPORT COMPONENT

Variant __fastcall TForm1::frxReport1UserFunction(const UnicodeString MethodName,

       Variant &Params)

{

 if (MethodName == "FrFileExists") {

    String x = Params.GetElement(0);

    return (FrFileExists(x));

  }

 return 0;   

}


// Use the report component’s add method to add it to the function list

void __fastcall TForm1::FormShow(TObject *Sender)

{

 frxReport1->AddFunction("boolean __fastcall TForm1::FrFileExists(String FileName)");

 frxReport1->DesignReport();

}

Comments

  • gpigpi Volnovakha, Ukraine

    Use

     if (MethodName == "FRFILEEXISTS") {

    instead of

     if (MethodName == "FrFileExists") {

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.