Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What are the different types of variables, and what are the differences?

Types of Variables

What are the different types of variables, and what are the differences?

by  MalcolmW  Posted    (Edited  )
Seagate Crystal Reports Variable Declarations in SCR version 7 and later
SCR v7 and above uses three different scope levels for variables:
+ global
+ local
+ shared.

Global variables
A variable can be declared as
Code:
Global NumberVar Test ;
to indicate that this variable uses the same memory block to store a value throughout the main report. The value is available to all formulas that declare this variable, except for those in subreports. If no scope is indicated, as in
Code:
NumberVar Test ;
then SCR will use the default scope of Global. There is no way to change this default behaviour.
Formulas with Global scope are evaluated at the time specified in the formula, or if no time is specified, then at what SCR understands to be a good time to evaluate the formula. (and if that doesn't convince you to specify the evalution time, nothing will)

Local variables
It is possible to restrict a variable for use within a single formula only. This means that if the same variable is used in another formula, the value assigned in a previous formula will not be carried over. This isolation of variables thus allows many formulas to use the same variable name with no interference from one another. The syntax for declaring this is:
Code:
Local NumberVar Test ;
Formulas with Local scope are evaluated at the time specified in the formula, or if no time is specified, then at what SCR understands to be a good time to evaluate the formula.

Shared variables
Since previous versions could not share variables with subreports, Store and Fetch functions were used for passing variable values from a main report to a subreport or the reverse. The shared variable declaration now replaces these functions and simplifies the process of sharing values with subreports. Store and Fetch functions are no longer automatically included during the product installation.
The syntax for declaring this is:
Code:
Shared NumberVar Test ;

Formulas with Shared scope are evaluated WhilePrintingRecords.

Releases of SCR v7 prior to 7.0.100.15 had an "issue" with drill downs on subreports with shared variables, so get the v7MR or v8
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top