How to read text file to FR?

dufduf Poland
edited February 2013 in FastReport 4.0
I would like to read a text file eg test.txt to FR. Do I have the text file format. I mean do I have to read the text to a database or save to a file *. Xml in a certain template. What are the simplest ways to read in the text or *.xml file. I would like to load *.xml files to specific Memo in FR.

Comments

  • gpigpi
    edited 7:51PM
    See C:\Program Files (x86)\FastReports\FastReport 4\Demos\PrintFile folder and ask in FR ticket system instead of youtube
  • dufduf Poland
    edited 7:51PM
    gpi wrote: »
    ... ask in FR ticket system instead of youtube
    What does it mean?
  • gpigpi
    edited 7:51PM
    wrote:
    What does it mean?
    http://support.fast-report.com/
    support@fast-report.com
    instead of
    http://www.youtube.com/watch?v=WZ3YdKpXpM8&lc
  • edited 7:51PM
    duf wrote: »
    I would like to read a text file eg test.txt to FR.
    You may read txt file using the idea below:
    var
        MyStr   :TStringList;                                               
    begin
        MyStr := TStringList.Create();                                                                             
        MyStr.LoadFromFile( 'c:\temp\anyfile.txt');
        ShowMessage( MyStr.text);                                                             
    end.
    
  • dufduf Poland
    edited 7:51PM
    Mick.pl wrote: »
    Mick.pl wrote: »
    I would like to read a text file eg test.txt to FR.
    You may read txt file using the idea below:
    var
        MyStr   :TStringList;                                               
    begin
        MyStr := TStringList.Create();                                                                             
        MyStr.LoadFromFile( 'c:\temp\anyfile.txt');
        ShowMessage( MyStr.text);                                                             
    end.
    
    Ok, thanks.
    This example shows how to load the entire file into a single object Memo. And how to load to several objects Memo different words from a text file? Of course, how to extract words from a file is known to me. I mean just like these words to redirect to specific objects Memo. Thanks.
  • edited 7:51PM
    duf wrote: »
    And how to load to several objects Memo different words from a text file? Of course, how to extract words from a file is known to me. I mean just like these words to redirect to specific objects Memo. Thanks.
    If you already have your file(s) written then you must convert it by your own code (compiler of FR scirpt).
    If you only plan to use a file that you're going to construct then have a look at TIniFile Class - you'll find there o lot of usefull functions.
  • dufduf Poland
    edited 7:51PM
    I have two objects of type TString in the main program.
    String a = "ala";
    String b = "ola"
    
    How do it to make these two words show in FR? Thanks.
  • edited 7:51PM
    duf wrote: »
    How do it to make these two words show in FR? Thanks.
    I guess you need to pass a value of variable from the compiled program to FR script.
    If so then search this forum for pass variable.
  • dufduf Poland
    edited March 2013
    Mick.pl wrote: »
    Mick.pl wrote: »
    How do it to make these two words show in FR? Thanks.
    I guess you need to pass a value of variable from the compiled program to FR script.
    If so then search this forum for pass variable.
    I do not know if I want to send to the FR script. I know that I want to compile my program and see those words in FR [img]style_emoticons/<#EMO_DIR#>/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" /> I found something like this on forum:[/img]
    frxReport1->Script->AddVariable("WPath", "String", "c:\windows");
    frxReport1->Script->Variables["Test"] = "test";
    
    But how to connect with Memo in FR?

    Or something like that:
    if ( Component != NULL )
        Memo = static_cast<TfrxMemoView*>(frxReport1->FindObject("Memo3"));
      else return;
       
      Memo->Text = "test";
    
      frxReport1->ShowReport(true);
    
    Is it called walking on thin ice? >
  • edited 7:51PM
    duf wrote: »
    Is it called walking on thin ice? >
    Spring is comming (at the northern Hemisphere) so ... beware of walking on ice [img]style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> Have a look at the attached sample[/img]
  • gordkgordk St.Catherines On. Canada.
    edited 7:51PM
    and if you are trying to pass values in from your program read the programmers manual
    you can pass values into the report variables after the report is loaded and before calling showreport or prepare report or you can use the findobjectmethod and pass it to the memo, or you can use the ongetvalue event
    or you can use the onbeforeprint event of the tfrxreport component.
  • dufduf Poland
    edited March 2013
    gordk wrote: »
    and if you are trying to pass values in from your program read the programmers manual
    you can pass values into the report variables after the report is loaded and before calling showreport or prepare report or you can use the findobjectmethod and pass it to the memo, or you can use the ongetvalue event
    or you can use the onbeforeprint event of the tfrxreport component.
    I applied ongetvalue event. How to specify a memo sent to the values?
    int count = frxReport1->AllObjects->Count;
    for(int i = 0; i < count; ++i)
    {
        if ( Memo->Name.Pos("Memo") != NULL ) 
               Value = "Test" + IntToStr(i);
    }
    
    In this example, the same data are entered into all fields Memo. How to write different data to different Memo?
  • gordkgordk St.Catherines On. Canada.
    edited 7:51PM
    that is due to the fact that you are
    1 stripping the name of the memo and
    2 you are not using the ogv event properly.
    using the ogv event requires a variable with no set value to be placed in a memo using[] to denote an expression
    that needs to be calculated ie, [myvar1] [myvar2]
    the code for the ongetvalue event handler is triggered when ever these variables are encountered by the report engine. Your code will use the name of the variable not the memo.
    here is a delphi sample you should be able to convert to c.
    procedure TForm1.frxReport1GetValue(const VarName: String;

    var Value: Variant);

    begin

    if CompareText(VarName, 'myvar1') = 0 then

    Value := 'test';

    if CompareText(VarName, 'myvar2') = 0 then

    Value := 'test2'



    end;



  • dufduf Poland
    edited 7:51PM
    gordk wrote: »
    that is due to the fact that you are
    1 stripping the name of the memo and
    2 you are not using the ogv event properly.
    using the ogv event requires a variable with no set value to be placed in a memo using[] to denote an expression
    that needs to be calculated ie, [myvar1] [myvar2]
    the code for the ongetvalue event handler is triggered when ever these variables are encountered by the report engine. Your code will use the name of the variable not the memo.
    here is a delphi sample you should be able to convert to c.
    procedure TForm1.frxReport1GetValue(const VarName: String;

    var Value: Variant);

    begin

    if CompareText(VarName, 'myvar1') = 0 then

    Value := 'test';

    if CompareText(VarName, 'myvar2') = 0 then

    Value := 'test2'



    end;
    Thanks.

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.