Difference between revisions of "C version of DISPR"

From MidrangeWiki
Jump to: navigation, search
m
m
 
(4 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
==C Program ==
 
==C Program ==
 
A C program that uses a subfile.
 
A C program that uses a subfile.
I named the program CDISPR snd it is a conversion of the RPGLE program  DISPR.  
+
I named the program CDISPR and it is a conversion of the RPGLE program  DISPR. (see UDDS file displayer)
  
  
Line 11: Line 11:
  
 
<pre>
 
<pre>
 
 
  
 
/*                */
 
/*                */
Line 36: Line 34:
 
#pragma mapinc("ddhpf","*libl/REL(*ALL)","input"," ",,"")
 
#pragma mapinc("ddhpf","*libl/REL(*ALL)","input"," ",,"")
 
#include "ddhpf"
 
#include "ddhpf"
 +
#define REL_t    QWHFDACP_i_t
  
 
#pragma mapinc("ddspf","*libl/SEL(*ALL)","input"," ",,"")
 
#pragma mapinc("ddspf","*libl/SEL(*ALL)","input"," ",,"")
 
#include "ddspf"
 
#include "ddspf"
 +
#define SEL_t    QWHFDSO_i_t
  
 
#pragma mapinc("ddhdf","*LIBL/CDISPRF(*ALL)","both indicators"," ",,"")
 
#pragma mapinc("ddhdf","*LIBL/CDISPRF(*ALL)","both indicators"," ",,"")
 
#include "ddhdf"
 
#include "ddhdf"
 +
#define RECS01i  S01_i_t
 +
#define RECS01o  S01_o_t
 +
#define RECC01i  C01_i_t
 +
#define RECC01o  C01_o_t
 +
#define RECS02i  S02_i_t
 +
#define RECS02o  S02_o_t
 +
#define RECC02i  C02_i_t
 +
#define RECC02o  C02_o_t
  
  
  
#define RECLENPF sizeof(QWHFDACP_i_t)
+
#define RECLENPF sizeof(REL_t)
#define RECLENSEL sizeof(QWHFDSO_i_t)
+
#define RECLENSEL sizeof(SEL_t)
#define RECLENS01i sizeof(S01_i_t)
+
#define RECLENS01i sizeof(RECS01i)
#define RECLENS01o sizeof(S01_o_t)
+
#define RECLENS01o sizeof(RECS01o)
#define RECLENC01i sizeof(C01_i_t)
+
#define RECLENC01i sizeof(RECC01i)
#define RECLENC01o sizeof(C01_o_t)
+
#define RECLENC01o sizeof(RECC01o)
#define RECLENS02i sizeof(S02_i_t)
+
#define RECLENS02i sizeof(RECS02i)
#define RECLENS02o sizeof(S02_o_t)
+
#define RECLENS02o sizeof(RECS02o)
#define RECLENC02i sizeof(C02_i_t)
+
#define RECLENC02i sizeof(RECC02i)
#define RECLENC02o sizeof(C02_o_t)
+
#define RECLENC02o sizeof(RECC02o)
  
 
#define IND_ON '1'
 
#define IND_ON '1'
 
#define IND_OFF '0'
 
#define IND_OFF '0'
#define I03     02
+
#define I03     2
 
#define I12    11
 
#define I12    11
 
#define I51    50
 
#define I51    50
Line 68: Line 76:
 
#define EXPORT
 
#define EXPORT
 
#define IMPORT  extern
 
#define IMPORT  extern
 +
#define forever for (;;) /* infinite loop */
 +
  
 +
void fOpenFiles(_RFILE **, _RFILE **,_RFILE **);
 
void fS01BLD(_RFILE *, _RFILE *, int *, char *, char *);
 
void fS01BLD(_RFILE *, _RFILE *, int *, char *, char *);
 
void fS01PRC(_RFILE *, int *, char *, char *);
 
void fS01PRC(_RFILE *, int *, char *, char *);
Line 80: Line 91:
 
EXPORT    int  pnl_lvl = 0;
 
EXPORT    int  pnl_lvl = 0;
 
EXPORT    _SYSindara      indicator_area;
 
EXPORT    _SYSindara      indicator_area;
 +
  
  
 
int main(void)
 
int main(void)
 
{
 
{
    _RFILE          *pf;
 
    _RFILE          *subf;
 
    _RFILE          *sopf;
 
 
  
 +
  _RFILE          *pf  ;
 +
  _RFILE          *subf ;
 +
  _RFILE          *sopf ;
 
     int              i;
 
     int              i;
 
     int              n;
 
     int              n;
Line 94: Line 105:
 
     int              n2;
 
     int              n2;
 
     int              *pn2  = &n2;
 
     int              *pn2  = &n2;
 +
  
 
     char C01FILE[10] = "          ";
 
     char C01FILE[10] = "          ";
Line 116: Line 128:
  
  
/* Open the Relations  file.                            */
+
  //  OPEN the FILES
    if ((pf = _Ropen(PFILENAME, "rr")) EQ NULL)
 
    {  printf("can't open file %s\n", PFILENAME); exit(1); }
 
  
/* Open the subfile  file.                            */
+
     fOpenFiles(&pf, &subf, &sopf );
     if ((subf = _Ropen(SUBFILENAME, "wr+ indicators=y")) EQ NULL)
 
    {  printf("can't open file %s\n", SUBFILENAME); exit(2); }
 
    _Rindara ( subf, indicator_area );
 
 
 
/* Open the Select/Omit  file.                            */
 
    if ((sopf = _Ropen(SOPFILE, "rr")) EQ NULL)
 
    {  printf("can't open file %s\n", SOPFILE); exit(1); }
 
 
 
 
 
for (;;) {
 
  
  
 +
forever
 +
{
 
   switch (Panel[pnl_lvl])
 
   switch (Panel[pnl_lvl])
 
   {
 
   {
Line 184: Line 186:
 
   _RIOFB_T      *fb;
 
   _RIOFB_T      *fb;
 
     int          i;
 
     int          i;
     QWHFDACP_i_t  pfrcd;
+
     REL_t        pfrcd;
     S01_o_t       sfrcd;
+
     RECS01o       sfrcd;
     S01_o_t       *p_sfrcd;
+
     RECS01o       *p_sfrcd;
 
     char          wfile[10];
 
     char          wfile[10];
 
     char          wlib[10];
 
     char          wlib[10];
Line 217: Line 219:
 
                 {
 
                 {
 
                 indicator_area[I56] = IND_ON;
 
                 indicator_area[I56] = IND_ON;
                 memcpy (sfrcd.S01FUNC  , "          ", 2  );
+
                 memset (&sfrcd, ' ', sizeof(sfrcd)) ;
                memcpy (sfrcd.S01APFILE, "          ", 10 );
 
                memcpy (sfrcd.S01APLIB , "          ", 10 );
 
                memcpy (sfrcd.S01APACCP, "          ", 1  );
 
                memcpy (sfrcd.S01APUNIQ, "          ", 1  );
 
                memcpy (sfrcd.S01APSELO, "          ", 1  );
 
                memcpy (sfrcd.S01APFTYP, "          ", 1  );
 
                memcpy (sfrcd.S01APJOIN, "          ", 1  );
 
                memcpy (sfrcd.S01APKEYO, "          ", 1  );
 
 
                 memcpy (sfrcd.S01APKSEQ, pfrcd.APKSEQ, 1  );
 
                 memcpy (sfrcd.S01APKSEQ, pfrcd.APKSEQ, 1  );
 
                 memcpy (sfrcd.S01APKSIN, pfrcd.APKSIN, 1  );
 
                 memcpy (sfrcd.S01APKSIN, pfrcd.APKSIN, 1  );
Line 284: Line 278:
 
     _RIOFB_T      *fb;
 
     _RIOFB_T      *fb;
  
     C01_o_t       cfrcd;
+
     RECC01o       cfrcd;
     C01_o_t       *p_cfrcd;
+
     RECC01o       *p_cfrcd;
  
 
     p_cfrcd    = &cfrcd;
 
     p_cfrcd    = &cfrcd;
Line 292: Line 286:
 
     fb = _Rwrite(subf, "", 0);
 
     fb = _Rwrite(subf, "", 0);
  
    for (;;)
+
forever
    {
+
  {
 
     _Rformat(subf, "C01");
 
     _Rformat(subf, "C01");
 
     _Rindara(subf, indicator_area );
 
     _Rindara(subf, indicator_area );
Line 332: Line 326:
 
     break;
 
     break;
  
    }
+
  }
 
  }
 
  }
  
Line 340: Line 334:
  
 
   _RIOFB_T      *fb;
 
   _RIOFB_T      *fb;
     S01_i_t       sfrcd;
+
     RECS01i       sfrcd;
     S01_i_t       *p_sfrcd;
+
     RECS01i       *p_sfrcd;
 
     long        rrn;
 
     long        rrn;
 
     int        i;
 
     int        i;
Line 369: Line 363:
 
                 memcpy (&func, sfrcd.S01FUNC, 2);
 
                 memcpy (&func, sfrcd.S01FUNC, 2);
  
             //  convert to upper case radj blank fill
+
             //  convert to upper case ladj blank fill
 
                 for(j = 0; j EQ 1; j++) {func[j] = toupper(func[j]); }
 
                 for(j = 0; j EQ 1; j++) {func[j] = toupper(func[j]); }
 
                 if (memcmp(&func[0], " ", 1) EQ 0 )
 
                 if (memcmp(&func[0], " ", 1) EQ 0 )
Line 404: Line 398:
  
 
   _RIOFB_T      *fb;
 
   _RIOFB_T      *fb;
     QWHFDSO_i_t  pfrcd;
+
     SEL_t        pfrcd;
     S02_o_t       sfrcd;
+
     RECS02o       sfrcd;
     S02_o_t       *p_sfrcd;
+
     RECS02o       *p_sfrcd;
 
     long        rrn;
 
     long        rrn;
 
     int        i;
 
     int        i;
Line 483: Line 477:
 
     _RIOFB_T      *fb;
 
     _RIOFB_T      *fb;
  
     C02_o_t       cfrcd;
+
     RECC02o       cfrcd;
     C02_o_t       *p_cfrcd;
+
     RECC02o       *p_cfrcd;
  
 
     p_cfrcd    = &cfrcd;
 
     p_cfrcd    = &cfrcd;
Line 491: Line 485:
 
     fb = _Rwrite(subf, "", 0);
 
     fb = _Rwrite(subf, "", 0);
  
    for (;;)
+
  forever
    {
+
  {
 
     _Rformat(subf, "C02");
 
     _Rformat(subf, "C02");
 
     _Rindara(subf, indicator_area );
 
     _Rindara(subf, indicator_area );
Line 530: Line 524:
 
     }
 
     }
 
  }
 
  }
 +
 +
//  ###################################
 +
 +
static void fOpenFiles(_RFILE **f, _RFILE **sf,_RFILE **so)
 +
{
 +
 +
    /* Open the Relations  file.                            */
 +
      *f = _Ropen(PFILENAME, "rr");
 +
      if (*f EQ NULL)
 +
        {
 +
            printf("can't open file %s\n", PFILENAME);
 +
            exit(1);
 +
        }
 +
 +
 +
    /* Open the subfile  file.                            */
 +
      *sf = _Ropen(SUBFILENAME, "wr+ indicators=y");
 +
      if (*sf EQ NULL)
 +
        {
 +
            printf("can't open file %s\n", SUBFILENAME);
 +
            exit(2);
 +
        }
 +
 +
    /* Open the Select/Omit  file.                            */
 +
      *so = _Ropen(SOPFILE, "rr");
 +
      if (*so EQ NULL)
 +
        {
 +
            printf("can't open file %s\n", SOPFILE);
 +
            exit(3);
 +
        }
 +
 +
}
 +
 +
 +
  
 
</pre>
 
</pre>

Latest revision as of 04:24, 7 April 2014


C Program

A C program that uses a subfile. I named the program CDISPR and it is a conversion of the RPGLE program DISPR. (see UDDS file displayer)


CDISPR C


/*                 */
#include <stdio.h>
#include <stdlib.h>
#include <recio.h>
#include <string.h>
#include <ctype.h>
#include <decimal.h>
#include <xxcvt.h>

enum Panels
     {
     TOP , S01BLD, S01PRC, S01PRS, S02BLD, S02PRC
     };

#define NUM_RECS   9999

#define PFILENAME    "*LIBL/REL"
#define SOPFILE     "*LIBL/SEL"
#define SUBFILENAME  "*LIBL/CDISPRF"

#pragma mapinc("ddhpf","*libl/REL(*ALL)","input"," ",,"")
#include "ddhpf"
#define REL_t    QWHFDACP_i_t

#pragma mapinc("ddspf","*libl/SEL(*ALL)","input"," ",,"")
#include "ddspf"
#define SEL_t    QWHFDSO_i_t

#pragma mapinc("ddhdf","*LIBL/CDISPRF(*ALL)","both indicators"," ",,"")
#include "ddhdf"
#define RECS01i  S01_i_t
#define RECS01o  S01_o_t
#define RECC01i  C01_i_t
#define RECC01o  C01_o_t
#define RECS02i  S02_i_t
#define RECS02o  S02_o_t
#define RECC02i  C02_i_t
#define RECC02o  C02_o_t



#define RECLENPF sizeof(REL_t)
#define RECLENSEL sizeof(SEL_t)
#define RECLENS01i sizeof(RECS01i)
#define RECLENS01o sizeof(RECS01o)
#define RECLENC01i sizeof(RECC01i)
#define RECLENC01o sizeof(RECC01o)
#define RECLENS02i sizeof(RECS02i)
#define RECLENS02o sizeof(RECS02o)
#define RECLENC02i sizeof(RECC02i)
#define RECLENC02o sizeof(RECC02o)

#define IND_ON '1'
#define IND_OFF '0'
#define I03      2
#define I12     11
#define I51     50
#define I52     51
#define I53     52
#define I56     55
#define EQ      ==
#define SHARE   static
#define EXPORT
#define IMPORT  extern
#define forever for (;;) /* infinite loop */


void fOpenFiles(_RFILE **, _RFILE **,_RFILE **);
void fS01BLD(_RFILE *, _RFILE *, int *, char *, char *);
void fS01PRC(_RFILE *, int *, char *, char *);
void fS01PRS(_RFILE *, int *, char *, char *);
void fS02BLD(_RFILE *, _RFILE *, int *,char *, char *);
void fS02PRC(_RFILE *, int *,char *, char *);



EXPORT    enum Panels Panel[99]  ;
EXPORT    int  pnl_lvl = 0;
EXPORT    _SYSindara       indicator_area;



int main(void)
{

  _RFILE           *pf   ;
  _RFILE           *subf ;
  _RFILE           *sopf ;
    int              i;
    int              n;
    int              *pn  = &n;
    int              n2;
    int              *pn2  = &n2;


    char C01FILE[10] = "          ";
    char C01LIB[10]  = "          ";
    char *p_c01file ;
    char *p_c01lib ;
    char C02FILE[10] = "          ";
    char C02LIB[10]  = "          ";
    char *p_c02file ;
    char *p_c02lib ;

    p_c01file =  C01FILE;
    p_c01lib  =  C01LIB;
    p_c02file =  C02FILE;
    p_c02lib  =  C02LIB;

    Panel[++pnl_lvl] = TOP ;
    Panel[++pnl_lvl] =  S01BLD ;

    for (i = 0; i <= 98; i++)
        { indicator_area[i] = IND_OFF;}


   //  OPEN the FILES

    fOpenFiles(&pf, &subf, &sopf );


forever
{
  switch (Panel[pnl_lvl])
  {
    case S01BLD:
       fS01BLD(pf, subf, pn, p_c01file, p_c01lib );
      break;

    case S01PRC:
       fS01PRC(subf, pn, p_c01file, p_c01lib );
      break;

    case  S01PRS:
       fS01PRS(subf, pn,  p_c02file, p_c02lib);
      break;

    case S02BLD:
       fS02BLD(sopf, subf, pn2, p_c02file, p_c02lib);
      break;

    case S02PRC:
       fS02PRC(subf, pn2,p_c02file, p_c02lib);
      break;

    case TOP:
  //  EXIT THE PROGRAM
      exit(0);
  }

  //  CF3 EXIT
    if (indicator_area[I03] EQ IND_ON)
    { exit(0); }
  //  CF12  PREVIOUS
    if (indicator_area[I12] EQ IND_ON)
    { indicator_area[I12] = IND_OFF,pnl_lvl--; }

}


/* Close the physical files and the subfile.                           */
     _Rclose(pf);
     _Rclose(sopf);
     _Rclose(subf);
}

//  ###################################



void fS01BLD(_RFILE *pf, _RFILE *subf, int *n, char *f, char *l)
 {
   _RIOFB_T      *fb;
    int           i;
    REL_t         pfrcd;
    RECS01o       sfrcd;
    RECS01o       *p_sfrcd;
    char          wfile[10];
    char          wlib[10];

    p_sfrcd    =  &sfrcd;
    _Rindara(subf, indicator_area );

/* CLEAR the SUBFILE  */
     _Rformat(subf, "C01");
    indicator_area[I51] = IND_OFF;
    indicator_area[I52] = IND_OFF;
    indicator_area[I53] = IND_ON;
      fb = _Rwrite(subf, "" , 0);


/* Select the subfile record format.                                  */
        _Rformat(subf, "S01");
        *n = 0;
        for (i = 1; i <= NUM_RECS; i++)
        {
               fb = _Rreadn(pf, &pfrcd, RECLENPF, __DFT);
               if (fb->num_bytes != EOF)
               {


                memcpy (f , pfrcd.APFILE, 10);
                memcpy (l , pfrcd.APLIB , 10);
                if (( memcmp(pfrcd.APFILE, wfile, 10) EQ 0 ) &&
                    ( memcmp(pfrcd.APLIB, wlib, 10) EQ 0 ))
                {
                indicator_area[I56] = IND_ON;
                memset (&sfrcd, ' ', sizeof(sfrcd)) ;
                memcpy (sfrcd.S01APKSEQ, pfrcd.APKSEQ, 1  );
                memcpy (sfrcd.S01APKSIN, pfrcd.APKSIN, 1  );
                memcpy (sfrcd.S01APKEYF, pfrcd.APKEYF, 10 );
                }
                else
                {
                indicator_area[I56] = IND_OFF;
                memcpy (sfrcd.S01FUNC  , "          ", 2  );
                memcpy (wfile, pfrcd.APFILE, 10 );
                memcpy (wlib, pfrcd.APLIB, 10 );
                memcpy (sfrcd.S01APLIB , pfrcd.APLIB , 10 );
                memcpy (sfrcd.S01APFILE, pfrcd.APFILE, 10 );
                memcpy (sfrcd.S01APLIB , pfrcd.APLIB , 10 );
                memcpy (sfrcd.S01APACCP, pfrcd.APACCP, 1  );
                memcpy (sfrcd.S01APUNIQ, pfrcd.APUNIQ, 1  );
                memcpy (sfrcd.S01APSELO, pfrcd.APSELO, 1  );
                memcpy (sfrcd.S01APFTYP, pfrcd.APFTYP, 1  );
                memcpy (sfrcd.S01APJOIN, pfrcd.APJOIN, 1  );
                memcpy (sfrcd.S01APKEYO, pfrcd.APKEYO, 1  );
                memcpy (sfrcd.S01APKSEQ, pfrcd.APKSEQ, 1  );
                memcpy (sfrcd.S01APKSIN, pfrcd.APKSIN, 1  );
                memcpy (sfrcd.S01APKEYF, pfrcd.APKEYF, 10 );
                }

                 fb = _Rwrited(subf, p_sfrcd, RECLENS01o, i);

                 if (fb->num_bytes != RECLENS01o )
                 {
                   printf("error occurred during write\n");
                   exit(3);
                 }
                 else
                 {
                   *n = i;
                 }


               }
               else
               {
               break;
               }
        }
        Panel[++pnl_lvl] =  S01PRC ;

 }
//  ###################################

void fS01PRC(_RFILE *subf, int *n, char *f, char *l)
 {

 /*
 +Write the subfile to the display by writing a record to the
 +subfile control format.
 */
    int             i;
    _RIOFB_T      *fb;

    RECC01o       cfrcd;
    RECC01o       *p_cfrcd;

    p_cfrcd    = &cfrcd;

    _Rformat(subf, "R01");
    fb = _Rwrite(subf, "", 0);

 forever
  {
     _Rformat(subf, "C01");
     _Rindara(subf, indicator_area );

      i = 1;
      QXXITOZ (cfrcd.SRS01 , 4 , 0, i);

      memcpy (cfrcd.C01APBOF, f , 10);
      memcpy (cfrcd.C01APBOL, l , 10);

    indicator_area[I51] = IND_OFF;
    indicator_area[I52] = IND_ON;
    indicator_area[I53] = IND_OFF;
    if (n != 0)
    { indicator_area[I51] = IND_ON; }

     fb = _Rwrite(subf, p_cfrcd, RECLENC01o);

     if (fb->num_bytes != RECLENC01o )
                 {
                   printf("error occurred during write\n");
                   exit(3);
                 }


     _Rreadn(subf, "", 0, __DFT);

      //  CF3 EXIT
    if (indicator_area[I03] EQ IND_ON) { break; }

     //  CF12 Previous
         if (indicator_area[I12] EQ IND_ON)
         {pnl_lvl--; break; }

    //  Process the subfile

    Panel[++pnl_lvl] =  S01PRS ;
    break;

   }
 }

 //  ###################################
void fS01PRS(_RFILE *subf, int *n,  char *f, char *l)
 {

  _RIOFB_T      *fb;
    RECS01i       sfrcd;
    RECS01i       *p_sfrcd;
    long        rrn;
    int         i;
    int         j;
    char        func[2];

   p_sfrcd    =  &sfrcd;
   _Rindara(subf, indicator_area );


/* Select the subfile record format.                                  */
        _Rformat(subf, "S01");


    for (i = 1; i <= *n ; i++)
    {
        rrn = i;
         fb = _Rreadd(subf, p_sfrcd, RECLENS01i, __DFT,rrn);
               if (fb->num_bytes EQ EOF)
               {
               {pnl_lvl--; break; }
               }
               else
               {
                memcpy (f, sfrcd.S01APFILE , 10 );
                memcpy (l, sfrcd.S01APLIB , 10 );
                memcpy (&func, sfrcd.S01FUNC, 2);

             //  convert to upper case ladj blank fill
                for(j = 0; j EQ 1; j++) {func[j] = toupper(func[j]); }
                if (memcmp(&func[0], " ", 1) EQ 0 )
                  {
                  memmove(&func[0] , &func[1] ,1);
                  memcpy(&func[1] ," ", 1);
                  }

               if (memcmp(func, "X ", 2) EQ 0 )
               {
               indicator_area[I03] = IND_ON ;  break;
               }

               if (memcmp(func, "R ", 2) EQ 0 )
               {
                memcpy (sfrcd.S01FUNC  , "          ", 2  );
                fb  =  _Rupdate(subf,p_sfrcd, RECLENS01i);
                Panel[++pnl_lvl] =  S02BLD ; break;
               }
               if (fb->rrn  EQ *n)
               {  --pnl_lvl;   }

               }

    }


 }

//  ###################################

void fS02BLD(_RFILE *sopf, _RFILE *subf, int *n2, char *f, char *l)
 {

  _RIOFB_T      *fb;
    SEL_t         pfrcd;
    RECS02o       sfrcd;
    RECS02o       *p_sfrcd;
    long        rrn;
    int         i;
    int         j;
    char        wfile[10];
    char        wlib[10];

    p_sfrcd =  &sfrcd;
   _Rindara(subf, indicator_area );

    memcpy (wfile , f, 10);
    memcpy (wlib , l , 10);

    /* CLEAR the SUBFILE  */
     _Rformat(subf, "C02");
    indicator_area[I51] = IND_OFF;
    indicator_area[I52] = IND_OFF;
    indicator_area[I53] = IND_ON;
      fb = _Rwrite(subf, "" , 0);


/* Select the subfile record format.                                  */
    _Rformat(subf, "S02");
    *n2 = 0;
    j = 0;

    for (i = 1; i < NUM_RECS; i++)
    {
        rrn = i;
         fb = _Rreadd(sopf, &pfrcd, RECLENSEL, __NO_LOCK,rrn);
               if (fb->num_bytes EQ EOF)
               {
               break;
               }
               else
               {

               if (( memcmp(pfrcd.SOFILE, wfile, 10) EQ 0 ) &&
                    ( memcmp(pfrcd.SOLIB, wlib, 10) EQ 0 ))
               {
                memcpy (sfrcd.S02SOFLD, pfrcd.SOFLD, 10  );
                memcpy (sfrcd.S02SORULE, pfrcd.SORULE, 1  );
                memcpy (sfrcd.S02SOCOMP, pfrcd.SOCOMP, 2 );
                memcpy (sfrcd.S02SOVALU, pfrcd.SOVALU, 32 );

               fb = _Rwrited(subf, p_sfrcd, RECLENS02o, ++j);

                 if (fb->num_bytes != RECLENS02o )
                 {
                   printf("error occurred during write\n");
                   exit(3);
                 }
                 else
                 {
                   *n2 = j;
                 }
                }

               }

    }
             Panel[++pnl_lvl] =  S02PRC ;

   }

//  ###################################

void fS02PRC(_RFILE *subf, int *n, char *f, char *l)
 {

 /*
 +Write the subfile to the display by writing a record to the
 +subfile control format.
 */
    int             i;
    _RIOFB_T      *fb;

    RECC02o       cfrcd;
    RECC02o       *p_cfrcd;

    p_cfrcd    = &cfrcd;

    _Rformat(subf, "R02");
    fb = _Rwrite(subf, "", 0);

  forever
   {
     _Rformat(subf, "C02");
     _Rindara(subf, indicator_area );

      i = 1;
      QXXITOZ (cfrcd.SRS02 , 4 , 0, i);

      memcpy (cfrcd.C02APFILE, f , 10);
      memcpy (cfrcd.C02APLIB, l , 10);

    indicator_area[I51] = IND_OFF;
    indicator_area[I52] = IND_ON;
    indicator_area[I53] = IND_OFF;
    if (n != 0)
    { indicator_area[I51] = IND_ON; }

     fb = _Rwrite(subf, p_cfrcd, RECLENC02o);

     if (fb->num_bytes != RECLENC02o )
                 {
                   printf("error occurred during write\n");
                   exit(3);
                 }


     _Rreadn(subf, "", 0, __DFT);

      //  CF3 EXIT
    if (indicator_area[I03] EQ IND_ON) { break; }

     //  CF12 Previous
    if (indicator_area[I12] EQ IND_ON)
            { indicator_area[I12] = IND_OFF; }

     //  ENTER  and F12
        pnl_lvl--;pnl_lvl--;break;
    }
 }

 //  ###################################

static void fOpenFiles(_RFILE **f, _RFILE **sf,_RFILE **so)
{

    /* Open the Relations  file.                            */
      *f = _Ropen(PFILENAME, "rr");
      if (*f EQ NULL)
         {
            printf("can't open file %s\n", PFILENAME);
            exit(1);
         }


    /* Open the subfile  file.                            */
      *sf = _Ropen(SUBFILENAME, "wr+ indicators=y");
      if (*sf EQ NULL)
         {
            printf("can't open file %s\n", SUBFILENAME);
            exit(2);
         }

    /* Open the Select/Omit  file.                            */
      *so = _Ropen(SOPFILE, "rr");
      if (*so EQ NULL)
         {
            printf("can't open file %s\n", SOPFILE);
            exit(3);
         }

}




#top


CDISPR needed files

You need to create these file


To create files REL and SEL

DSPFD FILE(*libl/urfile*) TYPE(*ACCPTH) OUTPUT(*OUTFILE) OUTFILE(QTEMP/REL)
DSPFD FILE(*libl/urfile*) TYPE(*select) OUTPUT(*OUTFILE) OUTFILE(QTEMP/SEL) 

DDS for  CDISPRF

     A*%%TS  SD  
     A*
     A*%%EC
     A                                      INDARA
     A                                      DSPSIZ(24 80 *DS3)
     A                                      PRINT
     A                                      CF03(03)
     A                                      CF12(12)
     A          R S01                       SFL
     A*%%TS  SD  
     A            S01FUNC        2A  B  4  3
     A  55
     AO 56                                  DSPATR(PR ND)
     A            S01APFILE R        O  4  6REFFLD(QWHFDACP/APFILE QTEMP/REL)
     A            S01APLIB  R        O  4 17REFFLD(QWHFDACP/APLIB QTEMP/REL)
     A            S01APACCP R        O  4 29REFFLD(QWHFDACP/APACCP QTEMP/REL)
     A            S01APUNIQ R        O  4 33REFFLD(QWHFDACP/APUNIQ QTEMP/REL)
     A            S01APSELO R        O  4 37REFFLD(QWHFDACP/APSELO QTEMP/REL)
     A            S01APFTYP R        O  4 41REFFLD(QWHFDACP/APFTYP QTEMP/REL)
     A            S01APJOIN R        O  4 45REFFLD(QWHFDACP/APJOIN QTEMP/REL)
     A            S01APKEYO R        O  4 48REFFLD(QWHFDACP/APKEYO QTEMP/REL)
     A            S01APKSEQ R        O  4 53REFFLD(QWHFDACP/APKSEQ QTEMP/REL)
     A            S01APKSIN R        O  4 57REFFLD(QWHFDACP/APKSIN QTEMP/REL)
     A            S01APKEYF R        O  4 61REFFLD(QWHFDACP/APKEYF QTEMP/REL)
     A          R C01                       SFLCTL(S01)
     A*%%TS  SD  
     A                                      SFLSIZ(0019)
     A                                      SFLPAG(0018)
     A                                      OVERLAY
     A  50                                  SFLEND
     A  51                                  SFLDSP
     A  52                                  SFLDSPCTL
     A  53                                  SFLCLR
     A            SRS01          4S 0H      SFLRCDNBR(CURSOR)
     A*
     A                                  1 18'FILE RELATIONS for '
     A            C01APBOF  R        O  1 39REFFLD(QWHFDACP/APBOF QTEMP/REL)
     A                                  1 51'Lib.'
     A            C01APBOL  R        O  1 56REFFLD(QWHFDACP/APBOL QTEMP/REL)
     A                                  2 32'Uni SEL         LIFO ASC Key'
     A                                  3  6'File       Library    Acc Key OMT -
     A                                      TYP  J  FIFO DSC Sgn Key'
     A          R R01
     A                                 24  3'F3-Exit'
     A                                 22  3'R - Display Select/Omit rules'
     A                                 23  3'X - Select for display'
      *
     A          R R02
     A                                 24  3'F3-Exit'
     A          R S02                       SFL
     A                                      SFLNXTCHG
     A            S02SOFLD  R        O  4  4REFFLD(QWHFDSO/SOFLD QTEMP/SEL)
     A            S02SORULE R        O  4 17REFFLD(QWHFDSO/SORULE QTEMP/SEL)
     A            S02SOCOMP R        O  4 22REFFLD(QWHFDSO/SOCOMP QTEMP/SEL)
     A            S02SOVALU R        O  4 28REFFLD(QWHFDSO/SOVALU QTEMP/SEL)

     A          R C02                       SFLCTL(S02 )
     A                                      OVERLAY
     A  50                                  SFLEND
     A  51                                  SFLDSP
     A  52                                  SFLDSPCTL
     A  53                                  SFLCLR
     A                                      SFLSIZ(0019)
     A                                      SFLPAG(0018)
     A            SRS02          4S 0H      SFLRCDNBR(CURSOR)
     A*
     A                                  1  6'FILE SELECTS   for '
     A            C02APFILE R        O  2  7REFFLD(QWHFDSO/SOFILE QTEMP/SEL)
     A                                  2 20'Lib.'
     A            C02APLIB  R        O  2 25REFFLD(QWHFDSO/SOLIB QTEMP/SEL)
     A                                  3  4'Field'
     A                                  3 28'Select/Omit Value'
     A                                  3 16'S/O'
     A                                  3 21'COMP'






#top