Simple compare string

Hi -

I am using Delphi and Fastreports 4. I am simply trying to compare the value of a variable in the "BeforePrint" event of a control. The result of the comparison will either show or hide the control.

The problem is, how to use a simple if then statement to check its value ? I am using Pascal scripting language and I have tried using the normal Delphi / Pascal way to contruct the if.. then statement but I just get random non-helpful messages.

here is how I would do it intuitively..

if (<ShowPrices> = 'YES') then  
  self.Visible  true
else              
  self.Visible  false;


Here <ShowPrices> is a report variable. I have tried enclosing the constant in double-quotes such as "YES", tried defining a variable of type string and doing a similar test for equality and nothing seems to work .

Can anyone shed light on why ? After all, its a valid Pascal language statement. I have also tried different ways of refering to the variable itself (in case the error was a "best guess" error message) but still have no luck.

Any help would be much appreciated.

Thanks.





Comments

  • edited 6:31PM
    Not to worry, think I sorted it. Maybe the brackets were causing a problem ? Not sure, anyway - this code worked..
    if <ShowPrices> =  'YES'  then
      begin                   
      self.Visible  := true;
      self.Printable := true;                     
      end          
    else
      begin                              
      self.Visible  := false;
      self.Printable := false;      
      end;
    
    Hi -

    I am using Delphi and Fastreports 4. I am simply trying to compare the value of a variable in the "BeforePrint" event of a control. The result of the comparison will either show or hide the control.

    The problem is, how to use a simple if then statement to check its value ? I am using Pascal scripting language and I have tried using the normal Delphi / Pascal way to contruct the if.. then statement but I just get random non-helpful messages.

    here is how I would do it intuitively..

    if (<ShowPrices> = 'YES') then  
      self.Visible  true
    else              
      self.Visible  false;
    


    Here <ShowPrices> is a report variable. I have tried enclosing the constant in double-quotes such as "YES", tried defining a variable of type string and doing a similar test for equality and nothing seems to work .

    Can anyone shed light on why ? After all, its a valid Pascal language statement. I have also tried different ways of refering to the variable itself (in case the error was a "best guess" error message) but still have no luck.

    Any help would be much appreciated.

    Thanks.

Leave a Comment