Using variables as strings

edited 11:23AM in FastReport 4.0
Hi,

I have defined a variable in a report called 'reporting_currency'. I am setting this variable in Delphi code before opening the report, like so:


if frxReport1.Variables.Items.Name = 'reporting_currency' then
begin
frxReport1.Variables.Items.Value := 'USD';
end;

Now, when I want to use the value of the variable to set a label in the report:

colHdr.Memo.Text := 'Currency ' + <reporting_currency>

I get the error:

Undeclared identifier 'USD'

Comments

  • edited 11:23AM
    Hi,

    Found the solution, it was:

    if frxReport1.Variables.Items.Name = 'reporting_currency' then
    begin
    frxReport1.Variables.Items.Value := '''' + 'USD' + '''';
    end;


    codebale wrote: »
    Hi,

    I have defined a variable in a report called 'reporting_currency'. I am setting this variable in Delphi code before opening the report, like so:


    if frxReport1.Variables.Items.Name = 'reporting_currency' then
    begin
    frxReport1.Variables.Items.Value := 'USD';
    end;

    Now, when I want to use the value of the variable to set a label in the report:

    colHdr.Memo.Text := 'Currency ' + <reporting_currency>

    I get the error:

    Undeclared identifier 'USD'
  • edited 11:23AM
    You should assign USD as quoted string.
    I mean

    frxReport1.Variables.Items.Value := '''USD''';

    or

    frxReport1.Variables.Items.Value := QuoteStr( 'USD');

    where QuoteStr adds quotation signs to string passed as its param.

    Search throug this forum for string variables - there are several comments about this issue.

    Mick


  • edited 11:23AM
    Thanks Mick.

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.