Example of managing transient data
This sample program demonstrates how to use the IccDataQueue and IccDataQueueId classes.
It can be found, along with the expected output, in
C++ sample programs
as file
ICC$DAT.
Here the code is presented without the terminal IO requests.
#include "icceh.hpp"
#include "iccmain.hpp"
The first two lines include the header files for the foundation
classes and the standard
main
function that sets up the operating
environment for the application program.
const char* queueItems[] =
{
"Hello World - item 1",
"Hello World - item 2",
"Hello World - item 3"
};
This defines some buffer for the sample program.
void IccUserControl::run()
{
The
run
method of
IccUserControl
class contains
the user code for this example.
short itemNum =1;
IccBuf buffer( 50 );
IccDataQueueId id( "ICCQ" );
IccDataQueue queue( id );
queue.empty();
This fragment first creates an identification object,
of type IccDataQueueId containing "ICCQ". It then creates an
IccDataQueue
object
representing the transient data queue "ICCQ", which it empties of
data.
for (short i=0 ; i<3 ; i++)
{
buffer = queueItems[i];
queue.writeItem( buffer );
}
This loop writes the three data items to the transient
data object. The data is passed by means of an
IccBuf
object
that was created for this purpose.
buffer = queue.readItem();
while ( queue.condition() == IccCondition::NORMAL )
{
buffer = queue.readItem();
}
Having written out three records we now read them back
in to show they were successfully written.
return;
}
The end of run , which returns control to CICS®.