Displaying a Variable's Value

You can use the Variable() function in PC-DMIS's reporting language to display a variable's value in your report. This function has the following syntax:

Variable(<varname>, [<optional command id or uid>])

The first parameter, coerced to a string type, represents the name of the variable. You can use the second optional parameter to solve for the variable's value relative to another command.

For example, suppose you have this code in your measurement routine:

ASSIGN/V1=2

F1=FEAT/CIRCLE...

ASSIGN/V1=F1.X

COMMENT/OPER,"Some comment text"

For the purposes of this example, assume that the comment has a unique ID or "UID" of 245.

Now consider the following examples with the code above:

=VARIABLE("V1") - If there are no other statements setting the value of V1 in the report then the value may be either 0, 2, or the same as the measured centroid x value of feature F1. It all depends on which commands have already executed at the point that the report expression is evaluated and which command is currently being processed for the report.

=VARIABLE("V1","F1") - If this is the only feature named "F1" in the measurement routine, then the result of evaluating this expression should be 2 since V1 is assigned to 2 directly above feature F1.

=VARIABLE("V1",245) - In this case, the UID is used; the value of this expression on the report should be the same as F1.X.

Individual cells of a GridControlObject cannot acquire a variable's value from the measurement routine. In most cases, you will need to use Text objects.

Variables and Headers

Normally, you cannot display a variable's value inside your report's file header because PC-DMIS evaluates the file header before executing statements in the measurement routine. So, when the file header attempts to reference a variable that hasn't yet been created, PC-DMIS displays a zero value. However, some options do exist to get information from your measurement routine into your header:

Option 1 - Use the tracefields instead of Variables
Use tracefields instead of variables in your measurement routine to capture the information and then use the =TRACEFIELD() function inside the desired cell in the GridControlObject of the header's label template to reference it. Tracefields force the template to re-evaluate the report based on the new information causing the tracefield to appear.

Advantages / Disadvantages

Procedure

Option 2 - Embed the Report Template
Embed the report template into your measurement routine sometime after the ASSIGN statements have been defined, and then send the variable's value to the label template as a parameter. Add additional rows or cells as needed and on top of the added cells, add and size a Text object for each variable you want to display. Finally, modify the Text property through a parameter of the REPORT/TEMPLATE command, like this:

ASSIGN/V1="A String Value to Pass"
CS1=REPORT/TEMPLATE,FILENAME=TEXTONLY.RTP,AUTOPRINT=NO,Section=-1
   PARAM/TEXT1.TEXT=V1
   PARAM/=
   ENDREPORT/

Because the label template is merged into the report template, you can modify certain parameters on the label template by referencing the report template in the above fashion.

Advantages / Disadvantages

Option 3 - Put the header information directly into the report
Instead of using a report template that refers to an external label template for the header, such as File_Header.lbl, recreate the GridControlObject from the header's label template directly inside your report template. Add additional rows or cells as needed and on top of the added cells, add and size a Text object for each variable you want to display. Then for each Text object use the =VARIABLE() function to pull in the variable information. For example, =VARIABLE("V1").

Make these remaining modifications inside the report template:

  1. In the TextReportObject change the rules so that the header label isn't used.

  2. Set these properties for the current section, Section1:

Command Set = All Commands

Maximum Number of Pages = 1

  1. Add a second section, Section2, and give it a TextReportObject as well, again changing its rules so that a header label isn't used.

  2. Set these properties for Section2:

Command Set = Continue From Previous Section

Maximum Number of Pages = 0 (meaning there is no maximum)

Advantages / Disadvantages

Option 4 - Use a generic feature to force report generation
This option uses an empty Generic feature to force the label template to re-evaluate the report and pull needed variables values into your final report.

In your measurement routine, create an empty Generic feature and give it a descriptive name such as:

REPORTHEADER=GENERIC/NONE,DEPENDENT,CARTESIAN,OUT,$

Next, modify the header label template, adding additional cells as needed to the GridControlObject, and then on top of the added cells, add and size a Text object for each variable you want to display. Now set the Text property for each Text object to use the =VARIABLE() function to pull in the variable information. In this option, however, you need to refer to the generic feature by using use the extra parameter in the =VARIABLE() function. For example, =VARIABLE("V1","REPORTHEADER")

Advantages / Disadvantages