Print special character on report

Leo BidiLeo Bidi Montevideo, Uruguay
edited 6:11PM in FastReport VCL 5
Hi, I have a report that needs to print some special name like SMITH'S

I have a variable defined in the report to print this field and had assigned this way
Report.Variables['Name'] := '''' + cName + ''''
and get error. How can I define my variable to use this name ??

cName its obtained from the db

Thanks

Comments

  • gpigpi
    edited 6:11PM
    Print SMITH''S
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 6:11PM
    Hi gpi thanks for your answer.

    I've change my single quote to double by doing
    cName := StringReplace( cName, chr(34), chr(39 ), [rfReplaceAll] )
    
    but still gets the same error with the same code I mentioned.

    Maybe I need to change also that code , where I assign the reports's variable ?


  • gpigpi
    edited 6:11PM
    Use
    frxReport1.Variables.Variables['Name'] := '''' + 'SMITH''''S' + '''';
    
    or
    frxReport1.Script.Variables['Name'] := 'SMITH''S';
    
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 6:11PM
    Thanks gpi but SMITH'S was only an example

    Thats why I post the code I was using in delphi

    Will try anyway.
  • LurkingKiwiLurkingKiwi Wellington, New Zealand
    edited 6:11PM
    gpi wrote: »
    Use
    frxReport1.Variables.Variables['Name'] := '''' + 'SMITH''''S' + '''';
    
    or
    frxReport1.Script.Variables['Name'] := 'SMITH''S';
    
    What gpi is saying is that you need to replace any single quotes in the string with TWO SINGLE quotes, like you do in Delphi literals in your code.
    NOT a double-quote character, which is what you thought you saw.
    This is because variables are treated like tiny scripts.
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 6:11PM
    Thank you LurkingKiwi

    Now I undestand what you and gpi mean. I was replacing the single quote by a double quote .
    When I change to 2 single quotes, works perfect.

    Excuse me gpi if I dont understand you before.

    Thanks both a lot.

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.