Quick Start: A Hello World Example

You can get started using Distributed NetBeans right away after installing the Distributed NetBeans Module (and restarting the IDE if prompted to do so). In this topic, a simple example and instructions will illustrate key steps in using DistributedNetBeans.

Step 1: Create and mount a directory

    1. From the NetBeans File menu, select Mount Filesystem.
    2. In the New Wizard, select Local Directory and click Next.
    3. Select or create a directory on your OpenVMS system in which to save your project files.
      To create a directory, click Create New Folder button icon and then change the name in the File name field. This is the directory that will be mounted in the NetBeans Explorer [Filesystem]
    4. Click Finish to close the New Wizard .


A newly mounted directory (EFS$:[user.projects.Example]) in the Explorer

Step 2: Create a new Fortran source file

    1. From the File menu, select New to open the New Wizard.
      (Make sure the newly created directory is selected when you do this.)
    2. Expand the OpenVMS Fortran folder and then expand the Fortran source files folder.
    3. Select the simple Fortran main program and click Next.
    4. Type HelloWorld in the name field of the Target Location page and click Finish.
      The HelloWorld.cpp file appears in Explorer. *** NEED TO FIX THIS EXAMPLE ****

Selecting the simple C++ main program on the Choose Template page

Step 3: Edit the source file

The Source Editor window should with the HelloWorld.cpp file open to edit. If the Source Editor Welcome screen or another source file is visible, click the HellowWorld tab (at the bottom).

    1. In the Source Editor, just below the header comment, specify the stdio.h header file:
      #include
    2. Between the open and closed braces, add the print Hello World statement:
      printf ("Hello World");

The complete code of HelloWorld.cpp

Step 4: Compile HelloWorld.cpp

In this step, you will use properties called compiler settings to compile your sources. This method does not require a command file. Instead, the Fortran module constructs a DCL command line that invokes your chosen compiler with the various arguments you require. Each argument is represented by a macro, the properties of which you can set individually.

  1. Right-click on the HelloWorld file in Explorer and select Properties from the context menu.
  2. Click the Compiler Settings tab and examine the default values of the properties.

    The C++ Compiler Command executes the cxx command using the /optimize and /warnings compilation options. You can try specifying another property, such as /debug.

  3. Right-click on the HelloWorld file in Explorer and select Compile from the context menu.
  4. View the result of the compilation in the Output Window.
    Compiling also saves the source file.
  5. Choose the Compile command again.

    The Output Window should show: Command completed. No files needed to be created, changed, or deleted.Finished HelloWorld.

  6. From the right-click menu for the HelloWorld file, select the Build command.

    The Output Window shows the successful compilation output again.

    This illustrates the difference between compiling and building. Building always compiles the sources even when they are unchanged from the last compilation.

Selecting the Compile command

Successful compilation output

Step 5: Navigating a compilation error

  1. Introduce a fault into the code by deleting the semicolon on the printf line.
  2. Choose the Compile command again and view the compilation error in the Output Window.
  3. Click on the underlined part of the error: HelloWorld.cpp [14:1], and the Source Editor selects the line as illustrated (the error occurs in the line following the omitted line delimiter).

The compiler error, CXX-E-EXPSEMICOLON, is reported along with its line number and character position [14:1]

Source Editor line is highlighted

Step 6: Compiling with a DCL command file

So far, the compilation method has been to use the compilation properties that are associated (or you associate) with a source file. These properties are passed to the compiler (the CXX compiler in this case) using the DCL command line. With the Fortran module, you can also use an existing or a new command file to compile or build your source code.

Part 1: Create a command file

      1. Select New from the File menu to open the New Wizard.
      2. Expand the OpenVMS DCL folder and select empty DCL file.
      3. Click Next and for a name type buildHelloWorld. Click Finish.
        A DCL file appears in Explorer and should open in the Source Editor window.
      4. Add the following line to the buildHelloWorld.com file (using your directory specification):

        $ cxx /optimize /debug /warnings /object= [<YOUR DIRECTORY SPECIFICATION>] 'P1'


    The complete command file in the Source Editor

    Note that the compiler command does not specify the source file, but uses the P1 parameter. If there are multiple source files, each one will be built with this command file.

Part 2: Execute the command file

      1. Right-click the HelloWorld file and select Properties from the context menu.
      2. On the Properties tab, select the field to the right of the Use Command File property and select True.
        The Compiler Settings tab becomes the Command File Settings tab.
      3. Click the Command File Settings tab.
        The default Build Command is a DCL command that executes the specified command file and source file. The default Build Directory is the location of the source file.
      4. In the Command File field, click the Customizer button (...) to browse for the command file you have just created. For example: /DEVICE$/user/projects/Example/buildHelloWorld.com
        Important Make sure you unselect the Inherit from project option. If you do not do this, your file selection is ignored.
      5. Now right-click on the buildHelloWorld file, select Properties and click the Execution Settings tab.
        You'll see that the Build Directory is the location of the source file, and the execution command is a macro that specifies the source file.
      6. Right-click on buildHelloWorld file and select Compile.
        The Output Window shows the compiler output.

Selecting the Use Command File option

Part 3: Use a DECterm window

If your command file requires any kind of input, you will need to execute it in an interactive window. You can do this by directing the output to a DECterm windows instead of the NetBeans Output Window.

  1. Right-click the HelloWorld file and select the Command File Settings tab.
  2. In the Use DECterm field, select True.
  3. Now click Build.

Selecting the DECterm option

A DECterm window opens. If the only text in the window is Press enter to exit, the compilation is complete and there are no errors. You can dismiss the window by pressing Enter when you're ready.

You can also set the Use DECterm property to True for an individual command file (on its property sheet's Execution Settings tab). In this case it will apply to all source files for which you use that command file. For example, applying this property to a command file could be useful if you know that its use always requires your interaction to specify various special parameters.