Print special character on report

Leo BidiLeo Bidi Montevideo, Uruguay
edited 4:22PM 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 4:22PM
    Print SMITH''S
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 4:22PM
    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 4:22PM
    Use
    frxReport1.Variables.Variables['Name'] := '''' + 'SMITH''''S' + '''';
    
    or
    frxReport1.Script.Variables['Name'] := 'SMITH''S';
    
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 4:22PM
    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 4:22PM
    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 4:22PM
    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