set Text to a variable

Hello,

I am having difficulty setting the value of a variable to a string that has a single quotation mark in it. I see that this is how you have to set a variable value to a string:

Set('Variable', '''' + 'hat'+ '''');

Is this the only way? How would you set the variable to a sting containing a single quote? This doesn't work:

Set('Variable', '''' + 'Sally's Hat'+ '''');

Thank you!
Bridget

Comments

  • edited 6:39PM
    Hello,
    You can use following script:
    var
      QuotedText: string;                                                     
    begin
      QuotedText := '''Sally''s Hat''';                                      
      Set('Variable', 'QuotedText');         
    end.
    
    See a demo in attachment.

  • edited 6:39PM
    Hi OlegK,

    Thank you for you help. But going further, how would this be done if <qry."NAME"> sometimes contains a single quote. This is what I had and it doesn't work.

    Set('@Name', Copy(<qry."NAME">,1,50));

    I even tried this:

    tText := ''''+Copy(<qry."NAME">,1,50)+'''';
    Set('@Name', tText);


    If it isn't obvious, I'm new to Fast Reports programming and am unsure of the syntax sometimes. Thank you!
  • edited 6:39PM
    Hi OlegK,

    Thank you for you help. But going further, how would this be done if <qry."NAME"> sometimes contains a single quote. This is what I had and it doesn't work.

    Set('@Name', Copy(<qry."NAME">,1,50));

    I even tried this:

    tText := ''''+Copy(<qry."NAME">,1,50)+'''';
    Set('@Name', tText);


    If it isn't obvious, I'm new to Fast Reports programming and am unsure of the syntax sometimes. Thank you!
  • edited 6:39PM
    Hi, Bridget.
    Use following code:
    Set('@Name', '<qry."NAME">');
    
  • edited 6:39PM
    Going even further than that. I have an input variable (<VarIn>) that is sent in as 'Hat's'
    Now I want to set @Name to that input variable but this doesn't work:

    Set('@Name', '<VarIn>');
  • edited 6:39PM
    It's basically not letting me to do anything with a input variable who's value is this: 'Hat's'
  • edited 6:39PM
    really a interesting discussion was held here......

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.