ILE C/C++ Programmer's Guide

Example: Returning Indicators to a Separate Indicator Area

You can specify indicators in records to be read or written by a program in a separate indicator area using the INDARA keyword in DDS.

The following example illustrates how indicators are returned in a separate indicator area. The INDARA keyword that is specified in the DDS means that the indicator for the display is returned to a separate indicator area.

Instructions

  1. To create the display file T1520DD0 using the DDS source shown below, enter:

    CRTDSPF FILE(MYLIB/T1520DD0) SRCFILE(QCPPLE/QADDSSRC)
    Figure 137 shows the DDS source.
  2. To create the program T1520ID2, using the source shown in Figure 138, enter:

    CRTBNDC PGM(MYLIB/T1520ID2) SRCFILE(QCPPLE/QACSRC)
  3. To run the program T1520ID2, enter:

    CALL PGM(MYLIB/T1520ID2)

    The output is as follows:

    +--------------------------------------------------------------------------------+
    |                                                                                |
    |                                  PHONE BOOK                                    |
    |                           Name:                                                |
    |                        Address:                                                |
    |                        Phone #:                                                |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |                                                                                |
    |                                 F3 - EXIT                                      |
    |                                                                                |
    +--------------------------------------------------------------------------------+

Source Code Samples

Figure 137. T1520DD0 -- DDS Source for a Phone Book Display




A INDARA
A R PHONE
A CF03(03 'EXIT')
A 1 35'PHONE BOOK'
A DSPATR(HI)
A 7 28'Name:'
A NAME 11A I 7 34
A 9 25'Address:'
A ADDRESS 20A I 9 34
A 11 25'Phone #:'
A PHONE_NUM 8A I 11 34
A 23 34'F3 - EXIT'
DSPATR(HI)

Figure 138. T1520ID2 -- ILE C Source to Specify Indicators in a Separate Indicator Area




/* This program uses response indicators to inform the program that */
/* F3 was pressed by a user to indicate that an input request */
/* finished. The response indicators are returned in a separate */
/* indicator area. */ 
#include <stdio.h>
#include <recio.h>
#include <stdlib.h>
typedef struct{
char name[11];
char address[20];
char phone_num[8];
}info;
#define IND_ON '1'
#define F3 2

int main(void)
{
_RFILE *fp;
_RIOFB_T *rfb;
info phone_list;
_SYSindara indicator_area; 
if (( fp = _Ropen ( "*LIBL/T1520DD0", "ar+ indicators=y" )) == NULL )
{
printf ( "display file open failed\n" );
exit ( 1 );

_Rindara ( fp, indicator_area ); 
_Rformat ( fp, "PHONE" );
rfb = _Rwrite ( fp, "", 0 );
rfb = _Rreadn ( fp, &phone_list, sizeof(phone_list), __DFT );
if ( indicator_area[F3] == IND_ON )
{
printf ( "user pressed F3\n" );
}
_Rclose ( fp );
}
Note:

This program uses response indicators IND_ON '1' and F3 2 to inform the ILE C program T1520ID2 that a user pressed F3. The _Rindara() function accesses the separate indicator buffer indicator_area associated with the externally described file T1520DD0. The display file T1520DD0 is opened with the keyword indicators=yes to return the indicator to a separate area.


[ Top of Page | Previous Page | Next Page | Table of Contents ]