LoadFromFile image1 & 2

edited August 2009 in FastReport 4.0
Hi im new at this and im tryng to put this code to work but no luck..

i have a detail in page 4 that has to load vF1 & vF2 from file ( image1...10) how can i do that?
Thanks


var
ImagePath : String;
vF1:String;
vF2:String;
i:integer;
begin

for i:=1 to 100 do
begin
ImagePath := Dirlocal + 'Termogra\'+Contracto.text+ '\'+NInterv.text+ '\';
vF1:= (ImagePath +SubTRelFinal_sub.FieldByName('foto1').AsString);
vF2:= (ImagePath + SubTRelFinal_sub.FieldByName('foto2').AsString);
if FileExists(vF1)
then
QRImage1.Picture.LoadFromFile(vF1 );
if FileExists(vF2)
then
QRImage2.Picture.LoadFromFile(vF2 );
end;

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 7:26PM
    are you trying to work from an event inside the report or from delphi using the tfrxreport components onbeforeprint event.
    and why are you trying to do it 100 times.
  • edited 7:26PM
    gordk wrote: »
    are you trying to work from an event inside the report or from delphi using the tfrxreport components onbeforeprint event.
    and why are you trying to do it 100 times.

    my report normaly goes to 80 times a detailreport(+- 80 images each variavel.
    I tray this way but doesent work why?

    procedure TTermografia.MainReportBeforePrint(Sender: TfrxReportComponent);

    begin
    ImagePath := Dirlocal + 'Termogra\'+Contracto.text+ '\'+NInterv.text+ '\';
    MainReport.Variables:=ImagePath ;

    end;


    procedure Picture5OnBeforePrint(Sender: TfrxComponent);
    begin
    picture5.picture.loadfromfile(<Fot1>+'Termografia_subFoto1');
    // picture5.picture.loadfromfile('Termogra\CAM MAIA\101\IR_0783.jpg'); work??s fine

    end;
    where im wrong???
  • gordkgordk St.Catherines On. Canada.
    edited 7:26PM
    procedure TTermografia.MainReportBeforePrint(Sender: TfrxReportComponent);

    begin
    ImagePath := Dirlocal + 'Termogra\'+Contracto.text+ '\'+NInterv.text+ '\';
    MainReport.Variables:=ImagePath ;

    end;


    when passing a string into a report variable it must have additional string delimiters or it will be treated as an unknown by the expression parser and trigger the ongetvalue event.
    procedure TTermografia.MainReportBeforePrint(Sender: TfrxReportComponent);

    in this next procedure
    'Termografia_subFoto1' is a string added to the value of <Fot1> and does not have an image extension. ie .jpg
    procedure Picture5OnBeforePrint(Sender: TfrxComponent);
    begin
    picture5.picture.loadfromfile(<Fot1>+'Termografia_subFoto1');
    // picture5.picture.loadfromfile('Termogra\CAM MAIA\101\IR_0783.jpg'); work??s fine

    end;
  • edited September 2009
    'Termografia_subFoto1' or <Termografia_sub."Foto1"> stores a value IR_0783.jpg .
    Really im new ate this and I???m learning but i didn???t now what you what you meant..


    ml

    thank??s
  • gordkgordk St.Catherines On. Canada.
    edited 7:26PM
    The right way to pass a string values is:



    frxReport1.Variables := '''' + 'test' + ''''; or


    frxReport1.Variables := '''' +(delphistringvariable) + '''';

    read the programmers manual on working with a list of variables.
    tip
    when you are trying to trouble shoot a problem in report script code try a single time instead of many times and use the showmessage() function in the report script to see what value the string has.
    ie
    procedure Picture5OnBeforePrint(Sender: TfrxComponent);
    begin
    showmessage(<Fot1>+'Termografia_subFoto1');// temp test to check string.
    //picture5.picture.loadfromfile(<Fot1>+'Termografia_subFoto1');
    // picture5.picture.loadfromfile('Termogra\CAM MAIA\101\IR_0783.jpg'); work??s fine

    end;
    also remeber that when you use the external events of the tfrxreport component to pass values into the report
    you cannot preview from the delphi ide you must run the app.
  • edited 7:26PM
    Thank??s for the great HELP

    procedure TTermografia.MainReportBeforePrint(Sender: TfrxReportComponent);
    begin
    ImagePath := Dirlocal + 'Termogra\'+Contracto.text+ '\'+NInterv.text+ '\';
    MainReport.Variables := '''' +(ImagePath) + '''';
    MainReport.Variables := '''' +(ImagePath) + '''';
    end;


    procedure Picture5OnBeforePrint(Sender: TfrxComponent);
    var
    vF1:String;
    begin
    vF1:=<Termografia_sub."Foto1"> ;
    picture5.picture.loadfromfile(<Fot1>+vf1);
    end

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.