IBM Visualization Data Explorer Programmer's Reference

[ Bottom of Page | Previous Page | Next Page | Table of Contents | Partial Table of Contents | Index ]

Chapter 5. Working with Data

Partial Table-of-Contents

  • 5.1 Add Module Example--Add a Number to Every Data Value
  • 5.2 Add2 Module Example--Add Two Data Fields
  • 5.3 Add2Invalid Module Example--Manipulate Invalid Data

  • For modules that manipulate the data component of an Object, positions and connections are often irrelevant. The Statistics module, for example, computes the mean of a data Field regardless of whether the connections are quads or cubes. In fact, it is unnecessary for the Statistics module to examine or access the connections component at all.

    The Module Builder is well suited to creating such modules.

    5.1 Add Module Example--Add a Number to Every Data Value

    The Add module adds a number to every data value in a Field.
    Note:This example is for illustration rather than "practice," since its function is already provided by Compute (see Compute in IBM Visualization Data Explorer User's Reference).

    The Add module takes two inputs: the first, data, is of type field and has no default value; the second, addend, is of type scalar, and has a default value of zero (0).

    The Add module has one output: result, of type field.

    (1) Start the Module Builder with the command:

      dx -builder

    The Module Builder dialog box appears. Note that the dialog box carries no information, since no module has been specified. (For a simple example of creating a module with the Module Builder, see 3.3 , "Using the Module Builder: A Quick Walk Through")

    (2) Select Open from the File pull-down menu. An Open a Module Builder file... dialog box appears.

    (3) Read in /usr/lpp/dx/samples/program_guide/add.mb as follows:

    (4) Save the .mb file to a writable directory (use Save As... in the File pull-down menu).

    (5) Select Create All from the Build pull-down menu of the dialog box. This option creates three files for the module: add.c, add.mdf, and add.make.

    (6) Implement the Add function.

    Use an editor to add the following lines after "User's code goes here," near the end of the add.c file:

       int i;
       float value;
       /* first implement the default for addend of 0 */
       if (addend_knt == 0)
          value = 0;
          value = *addend_data;
       /* add addend to each value in the data field */
       for (i=0; i < result_knt; i++) {
          result_data[i] = data_data[i] + value;
       return 1;

    The file /usr/lpp/dx/samples/program_guide/add.c contains a completed version of this program.

    (7) To create a version of Data Explorer that includes the Add module, enter the command:

    make -f add.make dxexec

    (You have now created an executable that contains the Add module.)

    (8) To invoke this version, enter:

    dx  -mdf ./add.mdf -exec ./dxexec

    This command starts Data Explorer (the add.mdf file tells the graphical user interface about Add and its inputs and outputs). The executable dxexec invoked here is the one created in Step 6.

    (9) With this version of Data Explorer you can now run any visual program that uses the Add module. One such program is /usr/lpp/dx/samples/program_guide/

    [ Top of Page | Previous Page | Next Page | Table of Contents | Partial Table of Contents | Index ]
    [Data Explorer Documentation | QuickStart Guide | User's Guide | User's Reference | Programmer's Reference | Installation and Configuration Guide ]

    [Data Explorer Home Page]

    [IBM Home Page | Order | Search | Contact IBM | Legal ]