Stimulsoft report variables

Tekla PowerFab Tekla PowerFab GO
Modified: 18 Nov 2024
2025i
Tekla PowerFab Tekla PowerFab GO

Stimulsoft report variables

You can use variables in reports. Variable is a value that can be modified and reused. There are various types of values such as string, date, number, and array.

Variables need a unique name, a description, and a data type. Once a variable is declared for the report, it can be accessed from anywhere within the report.

A variable can be created within an event using the C# language, but that variable can only be used within that event.

Variables can be used as the data source of a label, and then use code within an event to set the value of the variable.

View and edit variables

Reports can prepare values for report-level variables that can be used to display fields.

Variables are stored in the data dictionary. To find the variables, do the following:

  1. Go to Page > Panels > Dictionary.
  2. To see the variables used on the report, expand the Variables and FabSuite nodes.
  3. To edit an existing variable, do either of the following:
    • Double-click it in the tree view.
    • Right-click it and select Edit.

    The Edit Variable dialog opens.

System variables

Each report has a list of built-in variables that can be used in the components on the report.

To view the system variables, go to Page > Panels > Dictionary.

Example: Convert data type using variables

This is an example of code for taking the string data type for the Load Category of a Load and changing it to a decimal.

Code within an event can use comments that start a line with : //

Example:

// Set an interim variable.

decimal lnLoadCat1;

// Get the value from the data- i.e. ProductionControlTrucks.LoadCategory1, and try convert to a decimal.

// if TryParse is successful - the value is in "lnLoadCat1"

// if TryParse is not successful - the value is set to be 1.0 - a dummy multiplier.

if (!Decimal.TryParse( ProductionControlTrucks.LoadCategory1, out lnLoadCat1)) {

//The row could not be parsed as a decimal.

lnLoadCat1 = 1.0m; }

_LoadCat1 = lnLoadCat1;

At this point, the variable _LoadCat1 can be used within the event. If it is needed outside the event, you must create and use a report variable.

Was this helpful?
Previous
Next