FastReport VCL IIF Statement with variables

207 Views Asked by At

I am trying to use an if in my report using a variable as the condition this is what I tried IIF(<Client> = true, "Solde: " + [Solde], "Rendu: " + [Rendu]) but I get the error "undeclared identifier 'Client'"

frxReport1.Variables['Rendu'] := Versement - TotalAmount - Remise;
frxReport1.Variables['Solde'] := SoldClient;
frxReport1.Variables['Client'] := ClientTrue; //ClientTrue is a boolean
1

There are 1 best solutions below

0
Fabrizio On BEST ANSWER

I see these problems:

  1. There must be square brackets [] all around the expression
  2. You should use single quotes ' instead of double quotes " for strings
  3. You need to convert your variables values (which I suppose are floating variables) into strings
  4. You have to use the angle brackets <> only, for using variables in the expressions

Furthermore, you can avoid comparing your variable (<Client> = true), just use the variable since it's a boolean variable.

The following expression will work:

[IIF(<Client>, 'Solde: ' + FloatToStr(<Solde>), 'Rendu: ' + FloatToStr(<Rendu>))]