Picture (Image) Object Verification

edited April 2012 in FastReport 4.0
Hi,

I can't seem to find how to check whether an image was successfully pulled dynamically via a Db record set.

I have defined the FileLink location correctly as in F:\Sites\EacLive\downloads\facilities\photos\[A_Fetch_A_Accommodation_Search."FacilityID"].jpg but not all of my Facilities have a related image.

In these instances, I need to hide the image object and show a "No Image Available" icon instead.

Via the command line browser, my report displays great (I had set the transparent colour to clWhite and simply placed the "No Image" image below my dynamic one). In those instances, the missing image is not displayed and so the "No Image" one (that is below it) shows through.

However, when exporting to pdf, the "missing" dynamic images display white and so the "No Image" picture remains overlayed and so still can't be seen.

My question is this: Is there a flag or event I can use to check in my OnBeforePrint function whether to hide or show my relevant images?

Many thanks, RSVP.

Andrew F.

Comments

  • edited 9:44AM
    Sheff wrote: »
    Hi,

    I can't seem to find how to check whether an image was successfully pulled dynamically via a Db record set.

    I have defined the FileLink location correctly as in F:\Sites\EacLive\downloads\facilities\photos\[A_Fetch_A_Accommodation_Search."FacilityID"].jpg but not all of my Facilities have a related image.

    In these instances, I need to hide the image object and show a "No Image Available" icon instead.

    Via the command line browser, my report displays great (I had set the transparent colour to clWhite and simply placed the "No Image" image below my dynamic one). In those instances, the missing image is not displayed and so the "No Image" one (that is below it) shows through.

    However, when exporting to pdf, the "missing" dynamic images display white and so the "No Image" picture remains overlayed and so still can't be seen.

    My question is this: Is there a flag or event I can use to check in my OnBeforePrint function whether to hide or show my relevant images?

    Many thanks, RSVP.

    Andrew F.


    No response.

    Does this mean FastReports doesn't give the ability to do File management checks such as FileExists?
    I wish I could find a document that lists all the functions available to me within FastReports :-(
  • gpigpi
    edited 9:44AM
    wrote:
    No response.

    Does this mean FastReports doesn't give the ability to do File management checks such as FileExists?
    I wish I could find a document that lists all the functions available to me within FastReports :-(
    Yes, FR doesn't have FileExistsfunction, but you can write your own user function

  • edited May 2012
    Would someone help me with this? I'm completely at a loss and over my depth tbh.

    I need to be able to check that the file I'm about to assign to a Picture Object Exists.

    I'm using the direct FastReports generator to do this work using C++ scripting but am struggling with the limted set of functions it looks like are available.

    Am I missing a trick here? Are there some #includes or suchlike that give me huge libraries of functionality?

    I've also seen examples of being able to use .gif files, but when I try to include the Picture.Bitmap.LoadfromFile(fileName) it fails telling me it can't convert to int.

    Any help would be greatly appreciated, preferrably with example code (telling me "just use FileExists" isn't getting me anywhere because I can't just use...).

    Thank you all, before, during and after :-)
  • gordkgordk St.Catherines On. Canada.
    edited 9:44AM
    here is a sample create the unit and just add a refrence to the uses clause

    unit myfrfunctions;

    interface

    implementation

    uses
    SysUtils, Classes, fs_iinterpreter;

    type
    TFunctions = class(TfsRTTIModule)
    private
    function CallMethod(Instance: TObject; classType: TClass; const
    MethodName: string; var Params: Variant): Variant;
    public
    constructor Create(AScript: TfsScript); override;
    end;


    function myFileExists(aFileName: string): Boolean;
    begin
    Result := SysUtils.FileExists(aFileName);
    end;

    constructor TFunctions.Create(AScript: TfsScript);
    begin
    inherited Create(AScript);
    with AScript do
    begin
    AddMethod('function DateiExistiert(aDateiName: string): Boolean',
    CallMethod, 'Datei', 'Pruft, ob eine Datei vorhanden ist');
    end;
    end;

    function TFunctions.CallMethod(Instance: TObject; classType: TClass;
    const MethodName: string; var Params: Variant): Variant;
    begin
    if upperCase(MethodName) = 'DATEIEXISTIERT' then
    Result := myFileExists(Params[0]);
    end;

    initialization
    fsRTTIModules.Add(TFunctions);
    end.
  • edited 9:44AM
    gordk wrote: »
    here is a sample create the unit and just add a refrence to the uses clause

    unit myfrfunctions;

    interface

    implementation

    uses
    SysUtils, Classes, fs_iinterpreter;

    type
    TFunctions = class(TfsRTTIModule)
    private
    function CallMethod(Instance: TObject; classType: TClass; const
    MethodName: string; var Params: Variant): Variant;
    public
    constructor Create(AScript: TfsScript); override;
    end;


    function myFileExists(aFileName: string): Boolean;
    begin
    Result := SysUtils.FileExists(aFileName);
    end;

    constructor TFunctions.Create(AScript: TfsScript);
    begin
    inherited Create(AScript);
    with AScript do
    begin
    AddMethod('function DateiExistiert(aDateiName: string): Boolean',
    CallMethod, 'Datei', 'Pruft, ob eine Datei vorhanden ist');
    end;
    end;

    function TFunctions.CallMethod(Instance: TObject; classType: TClass;
    const MethodName: string; var Params: Variant): Variant;
    begin
    if upperCase(MethodName) = 'DATEIEXISTIERT' then
    Result := myFileExists(Params[0]);
    end;

    initialization
    fsRTTIModules.Add(TFunctions);
    end.

    That's brilliant. Thank you so much! You've also given me the shell to begin to add my own funcs now I get the structure.
    I'll try it tonight.

    Thank you soooooo much :-D
  • edited May 2012
    gordk wrote: »
    here is a sample create the unit and just add a refrence to the uses clause

    unit myfrfunctions;

    [snip]

    Hi Gord,

    I try this, I include it in my Delphi unit, include it in my FR script code, but I do not see the function in the FR functions list at design time.
    I want to see it at design time and I want to be able to run the report from within the designer in the usual way, with working user functions.
    What am I missing here?

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.