## 2.4 Opening and Executing a Visual Program

This section will show you how to:

- Open a visual program.
- Execute that program to display an object in the Image window.

### Opening a Visual Program

A visual program must be opened before it can be executed:

1. From the Data Explorer Startup window choose `Edit Visual Program`. A file selection dialog box appears (see Figure 3). You can also get to the file selection dialog by choosing `Run Visual Program` in the Startup window or, once the visual program editor or image window has appeared, by selecting `File` in the menu bar of the window and then selecting `Open Program`.

2. Double click on any part of the `Filter` field at the top of the dialog box. Any text in that field will appear against the background of a black highlight bar.

3. Type

   `/usr/local/dx/samples/tutorial/*.net`

   (The cursor automatically moves to the beginning of the text line as soon as you start typing, and the highlighted text and highlight bar disappear.)

   Note: The file extension `.net` (for network) is the default for Data Explorer visual programs. In Data Explorer, "network" is a term for visual program.

4. Press `Enter` or click on the `Filter` pushbutton at the bottom of the dialog box. The `Selection` field just above this button now displays the directory path name. An alphabetized list of the `.net` files in the directory appears in the `Files` field.

   Note: If the path name you typed is invalid (the wrong list or no list of files appears), you can edit it: position the mouse cursor at the point where you want to start editing and click once before beginning to type.

   If the highlight bar reappears, retyping the entire path name is still unnecessary: again, position the cursor and click once. The highlight bar disappears, but the path name remains, with the cursor at the selected position.

5. Use the scroll bar to move to the bottom of the list in the `Files` field. Click on `example1.net` to highlight the file name. The `Selection` field now displays the file's full path name.

6. Click on `OK` to open the `example1.net` visual program: the dialog box closes; a "network" of modules and connecting lines appears in the "canvas" area of the VPE window; and the full path name of the program appears in the title bar of the window. Opening is completed.

For a short description of `example1.net`, click on `Help` at the right side of the menu bar and select `Application Comment` in the pull-down menu.

For Future Reference

- Double clicking on a name in the `Files` field also opens a program.
- It is not necessary to clear the canvas of one program before opening another. Just open the new program.
- If for any reason you want to start over again with a clean canvas--without closing Data Explorer: click on `File` in the menu bar and select `New` in the pull-down menu. This sequence clears the canvas of the previous program network and any associated windows.

### Executing a Visual Program

To execute a visual program like `example1.net` (once it has been opened):

1. Click on `Execute` in the menu bar of the VPE window.

   Note: A visual program can be executed from any window that has `Execute` in its menu bar.

2. Select `Execute Once` in the pull-down menu. Execution (which may take several seconds) is indicated by the highlighted `Execute` in the menu bar and the brief highlighting of various icons in the canvas area. The window that appears displays the image of a water molecule (Figure 5).

   Figure 5. Image Window. The window shown here displays the image generated by the visual program /usr/local/dx/samples/tutorial/example1.net .

   Once an object appears in the Image window, you can do a number of things with it, including:

   - Changing the view of the object (see 2.5 , "Controlling the Appearance of an Object: The Image Window").
   - Editing the visual program that generates the image (see 3.1 , "Editing a Visual Program: The Basics").
   - Saving and Printing its image, using the `File` pull-down menu in the menu bar (see "Saving and Printing Images").

For Future Reference

1. Many of the options in pull-down menus can be invoked by "accelerator" keyboard sequences. In the menus, these "shortcuts" appear next to the corresponding options. For a complete list, see Appendix G. "Accelerator Keys" in IBM Visualization Data Explorer User's Guide.
2. The editor window can be invoked directly with the command:

       dx -edit [program path name]

[ OpenDX Home at IBM | OpenDX.org ]