Hello World

When you start programming in an unaccustomed environment the hardest task is usually getting something--anything--to work and to be seen to be working. The initial difficulty is not in the internals of the program, but in bringing everything together--the CICS® server, the programming environment, program inputs and program outputs.

The example shown in this section shows how to get started in CICS OO programming. It is intended as an appetizer; Overview of the foundation classes is a more formal introduction and you should read it before you attempt serious OO programming.

This example could not be much simpler but when it works it is a visible demonstration that you have got everything together and can go on to greater things. The program writes a simple message to the CICS terminal.

There follows a series of program fragments interspersed with commentary. The source for this program can be found in sample ICC$HEL (see Sample source code for the location).

#include "icceh.hpp"
#include "iccmain.hpp"

The first line includes the header file, ICCEH, which includes the header files for all the CICS Foundation Class definitions. Note that it is coded as "icceh.hpp" to preserve cross-platform, C++ language conventions.

The second line includes the supplied program stub. This stub contains the main function, which is the point of entry for any program that uses the supplied classes and is responsible for initializing them correctly. (See main function for more details). You are strongly advised to use the stub provided but you may in certain cases tailor this stub to your own requirements. The stub initializes the class environment, creates the program control object, then invokes the run method, which is where the application program should 'live'.

void IccUserControl::run()
{

The code that controls the program flow resides not in the main function but in the run method of a class derived from IccControl (see IccControl class). The user can define their own subclass of IccControl or, as here, use the default one - IccUserControl, which is defined in ICCMAIN - and just provide a definition for the run method.

    IccTerminal* pTerm = terminal();

The terminal method of IccControl class is used to obtain a pointer to the terminal object for the application to use.

    pTerm->erase();

The erase method clears the current contents of the terminal.

    pTerm->send(10, 35, "Hello World");

The send method is called on the terminal object. This causes "Hello World" to be written to the terminal screen, starting at row 10, column 35.

    pTerm->waitForAID();

This waits until the terminal user hits an AID (Action Identifier) key.

    return;
}

Returning from the run method causes program control to return to CICS.

[[ Contents Previous Page | Next Page Index ]]