TechTricks
Technical answers from the trenches 
 
 
 
 

     
   
Passing Values to Reports
 
   
 Posted: 17 June 2003
 
   
 
 Applies to: Paradox 5.0 and later
 
   
 
Audience: Beginner
 
       
   

Question: How do I pass values to reports so they can be printed with the report?

Answer: There are several ways to do this, but the easiest that we've found involves a two-step process:

  1. Use ObjectPAL to save the value to an environment variable. For example:

    writeEnvironmentString( "RPTVALUE", strSomeValue )
  2. Add a calculated field to your report that reads the environment variable.

    readEnvironmentString( "RPTVALUE" )

When you do this, remember that readEnvironmentString() returns an empty string if the variable doesn't exist. Because of this, it's best to include the IIF() in your calculation to provide a value if the variable doesn't exist when the report is run. As an example, consider the following calculation that we've used in a production application:

   iif( readEnvironmentString( "RPTTITLE" ) <> "",
        readEnvironmentString( "RPTTITLE" ),
        "<RPTTITLE was not defined>" )

This calculation calls readEnvironmentString() twice: once to make sure the value is defined and once to return the value from the environment.

Note: The above calculation is split across multiple lines for readability; Paradox does not let you (easily) use multi-line calculations in calculated fields.

For additional ideas and approaches, please see Mike Irwin's FAQ on the subject.

 

       

Top

Feedback About Paradox Delphi Assorted Web Stuff
 
 
Copyright © 2000-2004, techtricks.com; All Rights Reserved.
Acknowledgements, Disclaimers, Terms and Conditions.
Article last updated on 16 June 2003

 

Other Sites: Paradox, Delphi, Perl, Web Stuff, and More


 

[- End -]