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 9:17AM
    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

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.