Modifying Fields at Run Time

In some cases, the printed field may need to be modified at run time. For this, the event can be triggered back to the server and make the necessary modifications to the current field before it is printed.

To create a duplicate copy of the rReport1 report:
  1. Select rReport1 Class from the REPORT1 Library, then right-click and select Duplicate.

A duplicate copy of the rReport1 Class displays.

  1. Type rReport3 to rename the duplicate copy.

  2. Select MyServer (Default) > Subroutines > mvDReport > bp > SimpleReport node from the Enterprise Browser.

  3. Right-click the SimpleReport node and select Duplicate Item...

A duplicate copy of the SimpleReport BASIC program is created.

  1. Type RunTimeField1 to rename the duplicate copy.

NOTE

Before proceeding, complete the procedures described in Creating a Simple Report.

To update the BASIC program:
  1. Select MyServer (Default) > Subroutines > mvDReport > bp > RunTimeField1 node from the Enterprise Browser.

  2. Double-click RunTimeField1 to open the BASIC Editor.

  3. Edit the RunTimeField1 BASIC program.

For example, change referencs to SUBROUTINE SimpleReport to SUBROUTINE RunTimeField1.

To catalog the program and assign the events:
  1. Select MyServer (Default) > Subroutines > mvDReport > bp > RunTimeField1 node from the Enterprise Browser, then right-click RunTimeField1 and select Catalog Item...

The mvDCatalog Entry window displays.

  1. Select the Allow Anonymous Access check box, then click Save.

  2. Double-click rReport3 Class from the REPORT1 Library to open the REPORT1.rReport3 design form.

  3. Select MyServer (Default) > ReportTutorial > RunTimeField1 from the Enterprise Browser, then drag the RunTimeField1 node to the REPORT1.rReport3 design form.

The rReport3 event window displays.

  1. Select the $getreportdata event check box, then click Save.

  2. Select the DataName iMvdDataRef.ID in the rReport3 design form, then type IDField in the Name field of the Property Manager window.

  3. Select MyServer (Default) > mvDCatalog > ReportTutorial > RuntimeField1 from the Enterprise Browser, then drag the RunTimeField1 node to the IDField.

The IDField window displays.

  1. Select the $print check box, then click Update to save changes.

The $print event is triggered every time the field is about to be printed. When this happens, mvDesigner can trigger an event to the database server to process the current field before it is printed. The next step explains how the field can be used within the BASIC program.

NOTE

An mvDCatalog for a program can be created without being compiled as long as the report does not run.

To modify the BASIC program:
  1. Select MyServer (Default) > Subroutines > mvDReport > bp > RunTimeField1 node from the Enterprise Browser, then double-click.

The BASIC program Editor displays.

  1. Change all rReport1 references to rReport3, then type the BASIC code to handle $print event of the ID field to edit the RunTimeField1 BASIC program.

When the $print event is triggered, the BASIC program is called and information regarding the field that triggered the event is sent. w3TriggerObject returns the name of the field to be printed.

The data in the field to be printed is returned to the BASIC program through the iMvdPrintValue variable. Its value can be retrieved using w3GetVal:

CALL w3GetVal(x,"iMvdPrintValue")

Once the Field name and the Field value are known, use w3mvDInsert to modify its value and w3mvDPropertyChange to change its look. In the RuntimeField1 example, the field $textcolor property is changed to red if the value of the field is an even number, and blue if it is an odd number.

  1. Click Compile.

The RunTimeField1 BASIC program successfully compiles.

  1. Right-click rReport3 Class from the REPORT1 Library, then select Print Report to test the report.

A tandem port runs to display the volume of traffic required to generate the report. Every time a record is set to print, it returns to the server to process it. This is not recommended for large reports.

See Also

Generating Report in mvDesigner

Setting up the Development Environment

Creating a Simple Report

Creating a Batch Report

Using the Report Data Grid

Using the Report Graph Control Component

Selecting Print Destination from BASIC

Summary

Examples