Importing text with [User Name]

edited 9:28PM in FastReport 4.0
At present I have a report that imports two bodies of text, lets Say TEXT1 and TEXT2. The report works fine all text is loaded when SHOWREPORT is called.

How can i include the clients name in TEXT1, I have tried [frxDBDataset2."LAST_NAME"] in the text body. Do I have to prepare the report prior to showing, or format the text code.

Comments

  • gpigpi
    edited 9:28PM
    Attach your report template (fr3)
  • Anu de DeusAnu de Deus Hampshire, UK
    edited May 2011
    Yes, probably all you need is to prepare the report.
    And make sure that the memoview object receiving the texts have the ExpressionDelimiters = '[,]' (default value) and AllowExpressions = true (also default)
    However, if any of the delimiters appear in the original text, you probably need to do a string replace first or change the delimiters, as anything between any '' will be treated as an expression.
  • edited 9:28PM
    I may be trying to explain this wrong.


    I have a report that has 2 Datasets connected.

    Dataset1 is a client table.
    Dataset2 is an Employee table.

    I have 1 data band connected to the report but not to the Datasets.

    client table gives the client name in the header as [InSalon_Dataset."CLIENT_NAME_LKP"] this works fine as I only need 1 name.
    Employee table gives employee name as [InSalon_Dataset."EMPLOYEE_LKP"] this works fine as I only need 1 name.

    Both the above work fine.

    I also have a Variable Called [HeaderText] which loads at SHOWREPORT from a text file this also works.

    My problem is that I would like to import the name of the employee into the [HeaderText] file as below.

    My text file as is now, shortened

    Thank you for your visit and bla, bla bla
    This works

    but I would like to be able to output

    Thank you for your visit with [InSalon_Dataset."EMPLOYEE_LKP"] and we look bla, bla, bla
    employee name dosn't appear but appears as is.

    The reason to import from a text file is so that text can be changed as needed

    At present the Report is stored in the DFM

    Thanks in advance


  • edited 9:28PM
    I suppose:
    1. Your variable HeaderText is declared as string,
    2. At runtime you read plain text (no RTF or things like that) from a file,
    3. This file (and hence your variable) contains a piece of text you need to replace with other text you know at runtime.

    My suggestion:
    4) write your own function e.g. StringReplace( Text, T1, T2 :string) returning string
    5) use this function after you have read text from the file into variable like

    HeaderText := StringReplace( HeaderText, '[InSalon_Dataset."EMPLOYEE_LKP"]' , <InSalon_Dataset."EMPLOYEE_LKP">);

    Pay attention that this way you can make contents of file more simple like
    wrote:
    Thank you for your visit with {Customer_Name} and we look bla, bla, bla ...
    and use replace as below:

    HeaderText := StringReplace( HeaderText, '{Customer_Name}' , <InSalon_Dataset."EMPLOYEE_LKP">);

    And your end user (if it is him who edits the file) will not have to use magic phrases [InSalon_Dataset."EMPLOYEE_LKP"] or so [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Mick[/img]
  • edited 9:28PM
    Thanks guys for the help

    Both heading the same way.

    Mick.pl, many thanks for the explanation, this allows the end user to build their own header text file, just what I wanted to do.

    Can now move on.

    Great Forum

    Many 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.