Difference between revisions of "CQDFRTVFD"

From MidrangeWiki
Jump to: navigation, search
(Created page with " code")
 
Line 1: Line 1:
    
+
   __FORCETOC__
  
code
+
 
 +
== Introduction ==
 +
 
 +
C version of the RPG prpgram DSPINFO. (in development)
 +
is a work in progress
 +
 
 +
<pre>
 +
 
 +
 
 +
/* Function: This program uses the QDFRTVFD API to return the */
 +
/* structure of a display file.  */
 +
 
 +
 
 +
#include <stdio.h>
 +
#include <stdlib.h>
 +
#include <string.h>
 +
#include "QSYSINC/H/QUSEC"
 +
#include "QSYSINC/H/QDFRTVFD"
 +
 
 +
#define EQ      ==
 +
 
 +
#define fail() do { printf("\nLine %d FAILED in file %s", \
 +
__LINE__,__FILE__); \
 +
} while(0)
 +
 
 +
/* Pointers to structures required to be used by this program. */
 +
QDFFBASE_t *p_QDFFBASE;
 +
QDFFINFO_t *p_QDFFINFO;
 +
QDFARFTE_t *p_QDFARFTE;
 +
QDFFRINF_t *p_QDFFRINF;
 +
QDFFRDPD_t *p_QDFFRDPD;
 +
QDFFRCTB_t *p_QDFFRCTB;
 +
QDFWFLEI_t *p_QDFWFLEI;
 +
QDFFNTBL_t *p_QDFFNTBL;
 +
QDFWRCDI_t *p_QDFWRCDI;
 +
QDFWFLDI_t *p_QDFWFLDI;
 +
QDFFRCTE_t *p_QDFFRCTE;
 +
QDFFSFCR_t *p_QDFFSFCR;
 +
QDFFSFHR_t *p_QDFFSFHR;
 +
QDFFSCRA_t *p_QDFFSCRA;
 +
QDFFFITB_t *p_QDFFFITB;
 +
QDFFFINF_t *p_QDFFFINF;
 +
 
 +
 
 +
    /* Global variables */
 +
 
 +
    typedef struct inputArguments
 +
    {
 +
        char *pgmname;
 +
        char *Lib;
 +
        char *File;
 +
    } main_args_t;
 +
 
 +
    int FindRec (void);
 +
    int FindField (void);
 +
 
 +
    int ProcessRec (void);
 +
    int ProcessField (void);
 +
 
 +
    int RecIndex;
 +
 
 +
  /* Area into which the QDFRTVFD returns  the requested data.*/
 +
    char *ReturnVar;
 +
 
 +
    char Format[8];
 +
    char FileName[20] = "                    ";
 +
    char RecordName[10];
 +
 
 +
/* DSPF information TEST ONLY  */
 +
    char MyRec[] = "C01      "; /* Test name */
 +
    char MyField[] = "SRS01    "; /* Test name */
 +
 
 +
    /* 4 bytes WDFFRETN Length of the returned data. */
 +
    /* 4 bytes WDFFSIZE Size of the display file description */
 +
    typedef struct RtvSizeInfo
 +
    {
 +
        int ReturnLen;
 +
        int ReturnSiz;
 +
    } RtvSizeInfo_t;
 +
 
 +
 
 +
 
 +
  /* ########################################################  */
 +
int main(int argc, main_args_t *main_args)
 +
{
 +
 
 +
    RtvSizeInfo_t *RtvSize;
 +
    Qus_EC_t Error_Code = {0};
 +
 
 +
 
 +
    char *p_file ;
 +
    char *p_lib ;
 +
    int  API_Len;
 +
 
 +
    p_file =  main_args->File;
 +
    p_lib  =  main_args->Lib;
 +
 
 +
 
 +
/* Define the API format requested and the display file to access */
 +
    memcpy(Format,"DSPF0100",8);
 +
 
 +
/* Point to your DSPF */
 +
    memmove(FileName,p_file, strlen(p_file));
 +
    memmove(FileName + 10 ,p_lib, strlen(p_lib ));
 +
 
 +
 
 +
/* Invoke the API. */
 +
    RtvSize =  malloc(8);
 +
    QDFRTVFD (RtvSize,
 +
                8,
 +
                Format,
 +
                FileName,
 +
                &Error_Code);
 +
    if ( Error_Code.Bytes_Available != 0 ) {
 +
            fail();
 +
            exit (1);
 +
    }
 +
    API_Len  =  RtvSize->ReturnSiz;
 +
    free(RtvSize);
 +
 
 +
    ReturnVar =  malloc(API_Len);
 +
    QDFRTVFD (ReturnVar,
 +
                API_Len,
 +
                Format,
 +
                FileName,
 +
                &Error_Code);
 +
    if ( Error_Code.Bytes_Available != 0 ) {
 +
            fail();
 +
            printf( "\nExcId: %s" , Error_Code.Exception_Id );
 +
            exit (1);
 +
    }
 +
 
 +
    FindRec();
 +
        printf("\nEnd of test");
 +
 
 +
    ProcessRec();
 +
 
 +
 
 +
  free(ReturnVar);
 +
}
 +
 
 +
int ProcessRec() {
 +
 
 +
      int i;
 +
    /* Access returned structures. The base structure starts at */
 +
    /* the begining of the returned space. */
 +
    p_QDFFBASE = (QDFFBASE_t *)ReturnVar;
 +
    p_QDFFINFO = (QDFFINFO_t *)((char *) p_QDFFBASE + p_QDFFBASE->WDFFINOF);
 +
    p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFDFLO);
 +
    p_QDFWFLEI = (QDFWFLEI_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFWUOF);
 +
    p_QDFFRDPD = (QDFFRDPD_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFRAOF);
 +
    p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWXLEN);
 +
    p_QDFFNTBL = (QDFFNTBL_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWNTBO);
 +
 
 +
    /*  here is the place to retreive File Keywords */
 +
 
 +
    for (i=0; i<p_QDFFBASE->WDFFRCS; ++i) {
 +
 
 +
        /* Bump ptr to next record structure */
 +
      if  (i  != 0)
 +
    {p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWNXTR);
 +
      p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFARFTE + sizeof(QDFARFTE_t));  }
 +
 
 +
    memcpy(RecordName,p_QDFARFTE->WDFARFNM,sizeof(p_QDFARFTE->WDFARFNM));
 +
 
 +
 
 +
    ProcessField();
 +
 
 +
    }
 +
 
 +
}
 +
 
 +
 
 +
int ProcessField() {
 +
 
 +
      int SflCtl;
 +
      int SizeIdx;
 +
      int FldIdx;
 +
      int NumFlds;
 +
      char ScrnSize[1];
 +
      char Attrib[1];
 +
      char X01    =  0x01 ;
 +
 
 +
      /*  record header  */
 +
      p_QDFFRINF = (QDFFRINF_t *)((char *) p_QDFFINFO + p_QDFARFTE->WDFARFOF);
 +
      /*  record dev dept  */
 +
      p_QDFFRDPD = (QDFFRDPD_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFRAOF);
 +
      /*  SFLCTL                                                              */
 +
      /* 12  C      BIN(31) WDFFRFLG    Miscellaneous record contents.      */
 +
      /* 12  C  0  BIT(1)  WDFFUDDS    If on, USRDFN keyword is specified.  */
 +
      /* 12  C  1  BIT(1)  WDFFSFL If on, SFL keyword is specified (next rec*/
 +
      /* 12  C  2  BIT(1)  WDFFSFLC    If on, SFLCTL keyword is specified (p*/
 +
      SflCtl = 0;
 +
      if (p_QDFFRINF->WDFFRFLG.WDFFSFLC)
 +
        {  SflCtl = 1;
 +
    p_QDFFSFCR  = (QDFFSFCR_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFRAOF);
 +
    p_QDFFSFHR  = (QDFFSFHR_t *)((char *) p_QDFFSFCR + sizeof(QDFFSFCR_t));
 +
        }
 +
 
 +
    for (SizeIdx=0; SizeIdx<p_QDFFBASE->WDFFSCR -1; ++SizeIdx) {
 +
    p_QDFFSCRA  = (QDFFSCRA_t *)((char *) p_QDFFBASE + sizeof(QDFFBASE_t)
 +
                          + sizeof(QDFFSCRA_t) * SizeIdx    ) ;
 +
    *ScrnSize =  p_QDFFSCRA->WDFFSCIA ;
 +
    }
 +
    /* Find RowColumn table. Note: this is the first row/col table */
 +
    /* so this code only works for the PRIMARY DISPLAY SIZE. */
 +
    /* See QDFFRDPD.WDFFDRCO field description for finding the */
 +
    /* correct QDFFRCTB structure if more than one screen size is */
 +
    /* used. */
 +
      p_QDFFRCTB = (QDFFRCTB_t *)((char *) p_QDFFRINF + p_QDFFRDPD->WDFFDRCO);
 +
 
 +
    /********  HERE include code for Record Keywords ********/
 +
 
 +
    /*  PROCESS THE RECORDS FIELDS    */
 +
        /* Find where used section */
 +
 
 +
      p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWRLEN);
 +
      p_QDFFFITB = (QDFFFITB_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFOFIT
 +
                  +  ( p_QDFWFLDI->WDFWRRDX -1) * sizeof(QDFFFITB_t));
 +
 
 +
 
 +
    for (FldIdx=0; FldIdx < p_QDFFRINF->WDFFFLD; ++FldIdx) {
 +
 
 +
    p_QDFFFINF = (QDFFFINF_t *)((char *) p_QDFFRINF + p_QDFFFITB->WDFFFOFS);
 +
 
 +
    memmove(Attrib,p_QDFFFINF->WDFFFIOA, 1);
 +
    if (strncmp(Attrib,X01, 1) == 0) {
 +
      NumFlds += 1;
 +
    }
 +
 
 +
 
 +
 
 +
 
 +
 
 +
  /***********  HERE include code for Field KEYWORDS **********/
 +
 
 +
      if (FldIdx < p_QDFFRINF->WDFFFLD -1) {
 +
      p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWFLDI + p_QDFWFLDI->WDFWFLDL);
 +
      p_QDFFFITB = (QDFFFITB_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFOFIT
 +
                  +  ( p_QDFWFLDI->WDFWRRDX -1) * sizeof(QDFFFITB_t));
 +
      }
 +
 
 +
      NumFlds += 1;
 +
 
 +
 
 +
 
 +
    }
 +
 
 +
}
 +
 
 +
 
 +
 
 +
int FindRec() {
 +
        int i;
 +
    /* Access returned structures. The base structure starts at */
 +
    /* the begining of the returned space. */
 +
        p_QDFFBASE = (QDFFBASE_t *)ReturnVar;
 +
        p_QDFFINFO = (QDFFINFO_t *)((char *) p_QDFFBASE + p_QDFFBASE->WDFFINOF);
 +
        p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFDFLO);
 +
    /* While there are records, look for the requested record name */
 +
    /* in the QDFARFTE structure. */
 +
    for (i=0; i<p_QDFFBASE->WDFFRCS; ++i) {
 +
    if (strncmp(p_QDFARFTE->WDFARFNM,MyRec,10) == 0) {
 +
        RecIndex = i + 1; /* Entry in QDFARFTE table for the requested name*/
 +
 
 +
    /* Access additional structures. */
 +
        p_QDFFRINF = (QDFFRINF_t *)((char *) p_QDFFINFO + p_QDFARFTE->WDFARFOF);
 +
        p_QDFFRDPD = (QDFFRDPD_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFRAOF);
 +
    /* Find RowColumn table. Note: this is the first row/col table */
 +
    /* so this code only works for the PRIMARY DISPLAY SIZE. */
 +
    /* See QDFFRDPD.WDFFDRCO field description for finding the */
 +
    /* correct QDFFRCTB structure if more than one screen size is */
 +
    /* used. */
 +
        p_QDFFRCTB = (QDFFRCTB_t *)((char *) p_QDFFRINF + p_QDFFRDPD->WDFFDRCO);
 +
            FindField(); /* Find the requested field */
 +
        return(0); /* Task is done. */
 +
}
 +
    else
 +
        p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFARFTE + sizeof(QDFARFTE_t));
 +
}
 +
    /* If this point is reached, there was no match for the requested */
 +
    /* record. */
 +
        printf("\nThe requested record was not found %s",MyRec);
 +
        return(0);
 +
}
 +
 
 +
 
 +
int FindField () {
 +
    int j;
 +
    int k;
 +
    int NtblIndex;
 +
    char *NamePtr;
 +
    int RCIndex;
 +
    int RecNumber;
 +
    /* Find where used section */
 +
      p_QDFWFLEI = (QDFWFLEI_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFWUOF);
 +
    /* Find name table. There is one entry for each unique field */
 +
    /* name used in the file. A given name may be used in more than */
 +
    /* one record format. */
 +
      p_QDFFNTBL = (QDFFNTBL_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWNTBO);
 +
    /* Prepare to search table. Start search after the fixed portion. */
 +
        NamePtr = (char *) p_QDFFNTBL + sizeof(QDFFNTBL_t);
 +
        NtblIndex = 0;
 +
    /* Find requested name */
 +
    for (j=0; j<p_QDFFNTBL->WDFFNMS; ++j) {
 +
        if (strncmp(NamePtr,MyField,10) == 0) {
 +
            NtblIndex = j + 1;
 +
    /* The requested name was found  Get first QDFWRCDI structure. */
 +
  p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWFLEI +p_QDFWFLEI->WDFWXLEN);
 +
            RecNumber = 1;
 +
 
 +
    /* For each record, find the first field structure.          +
 +
    Then, find a match for the field name table index            +
 +
    If found, the field structure containing the matched index  +
 +
    also contains the row/column index. */
 +
 
 +
    for (j=0; j<p_QDFFBASE->WDFFRCS; ++j) {
 +
    /* Make sure the field matching is for the correct record. */
 +
        if (RecNumber == RecIndex) {
 +
        p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWRLEN);
 +
    /* Search for the correct field structure */
 +
        for (k=0; k<p_QDFFRINF->WDFFFLD; ++k) {
 +
    /* Find the correct structure by finding a match for the */
 +
    /* index into the field name table. */
 +
        if (NtblIndex == p_QDFWFLDI->WDFWNMEI) {
 +
            RCIndex = p_QDFWFLDI->WDFWRRDX; /* Row/Col index */
 +
    /* Point to first Row/Col Entry */
 +
    p_QDFFRCTE = (QDFFRCTE_t *)((char *) p_QDFFRCTB + sizeof(QDFFRCTB_t));
 +
    /* Point to correct Row/Col Entry. Each entry is 2 bytes. */
 +
    p_QDFFRCTE = (QDFFRCTE_t *)((char *) p_QDFFRCTE + ((RCIndex - 1) * 2 ));
 +
        printf("\n%s %s Row and column (hex) %02x %02x",MyRec,MyField,
 +
            *(char *) p_QDFFRCTE,*((char *) p_QDFFRCTE+1));
 +
        return(0); /* Task is done */
 +
    }
 +
    else
 +
        p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWFLDI + p_QDFWFLDI->WDFWFLDL);
 +
    }
 +
    }
 +
    else {
 +
    /* Bump ptr to next record structure */
 +
        p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWNXTR);
 +
    RecNumber = RecNumber + 1;
 +
        }
 +
    }
 +
    }
 +
    else
 +
        NamePtr = NamePtr + 10; /* Size of field name*/
 +
    }
 +
    /* If this point is reached, the field was not found */
 +
        printf("\nThe requested field was not found %s %s",MyRec,MyField);
 +
    return (0);
 +
}
 +
 
 +
</pre>

Revision as of 07:55, 19 August 2014


Contents

Introduction

C version of the RPG prpgram DSPINFO. (in development) is a work in progress



 /* Function: This program uses the QDFRTVFD API to return the */
 /* structure of a display file.  */


 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include "QSYSINC/H/QUSEC"
 #include "QSYSINC/H/QDFRTVFD"

 #define EQ      ==

 #define fail() do { printf("\nLine %d FAILED in file %s", \
 __LINE__,__FILE__); \
 } while(0)

/* Pointers to structures required to be used by this program. */
 QDFFBASE_t *p_QDFFBASE;
 QDFFINFO_t *p_QDFFINFO;
 QDFARFTE_t *p_QDFARFTE;
 QDFFRINF_t *p_QDFFRINF;
 QDFFRDPD_t *p_QDFFRDPD;
 QDFFRCTB_t *p_QDFFRCTB;
 QDFWFLEI_t *p_QDFWFLEI;
 QDFFNTBL_t *p_QDFFNTBL;
 QDFWRCDI_t *p_QDFWRCDI;
 QDFWFLDI_t *p_QDFWFLDI;
 QDFFRCTE_t *p_QDFFRCTE;
 QDFFSFCR_t *p_QDFFSFCR;
 QDFFSFHR_t *p_QDFFSFHR;
 QDFFSCRA_t *p_QDFFSCRA;
 QDFFFITB_t *p_QDFFFITB;
 QDFFFINF_t *p_QDFFFINF;


    /* Global variables */

    typedef struct inputArguments
    {
        char *pgmname;
        char *Lib;
        char *File;
    } main_args_t;

    int FindRec (void);
    int FindField (void);

    int ProcessRec (void);
    int ProcessField (void);

    int RecIndex;

   /* Area into which the QDFRTVFD returns  the requested data.*/
    char *ReturnVar;

    char Format[8];
    char FileName[20] = "                    ";
    char RecordName[10];

 /* DSPF information TEST ONLY  */
    char MyRec[] = "C01       "; /* Test name */
    char MyField[] = "SRS01     "; /* Test name */

    /* 4 bytes WDFFRETN Length of the returned data. */
    /* 4 bytes WDFFSIZE Size of the display file description */
    typedef struct RtvSizeInfo
    {
        int ReturnLen;
        int ReturnSiz;
    } RtvSizeInfo_t;



   /* ########################################################  */
 int main(int argc, main_args_t *main_args)
 {

    RtvSizeInfo_t *RtvSize;
    Qus_EC_t Error_Code = {0};


    char *p_file ;
    char *p_lib ;
    int  API_Len;

    p_file =  main_args->File;
    p_lib  =  main_args->Lib;


/* Define the API format requested and the display file to access */
    memcpy(Format,"DSPF0100",8);

/* Point to your DSPF */
    memmove(FileName,p_file, strlen(p_file));
    memmove(FileName + 10 ,p_lib, strlen(p_lib ));


 /* Invoke the API. */
    RtvSize =  malloc(8);
    QDFRTVFD (RtvSize,
                8,
                Format,
                FileName,
                &Error_Code);
    if ( Error_Code.Bytes_Available != 0 ) {
            fail();
            exit (1);
    }
    API_Len  =  RtvSize->ReturnSiz;
    free(RtvSize);

    ReturnVar =  malloc(API_Len);
    QDFRTVFD (ReturnVar,
                API_Len,
                Format,
                FileName,
                &Error_Code);
    if ( Error_Code.Bytes_Available != 0 ) {
            fail();
            printf( "\nExcId: %s" , Error_Code.Exception_Id );
            exit (1);
    }

    FindRec();
        printf("\nEnd of test");

    ProcessRec();


   free(ReturnVar);
 }

int ProcessRec() {

       int i;
    /* Access returned structures. The base structure starts at */
    /* the begining of the returned space. */
     p_QDFFBASE = (QDFFBASE_t *)ReturnVar;
     p_QDFFINFO = (QDFFINFO_t *)((char *) p_QDFFBASE + p_QDFFBASE->WDFFINOF);
     p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFDFLO);
     p_QDFWFLEI = (QDFWFLEI_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFWUOF);
     p_QDFFRDPD = (QDFFRDPD_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFRAOF);
     p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWXLEN);
     p_QDFFNTBL = (QDFFNTBL_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWNTBO);

    /*  here is the place to retreive File Keywords */

     for (i=0; i<p_QDFFBASE->WDFFRCS; ++i) {

         /* Bump ptr to next record structure */
      if  (i  != 0)
     {p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWNXTR);
      p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFARFTE + sizeof(QDFARFTE_t));   }

     memcpy(RecordName,p_QDFARFTE->WDFARFNM,sizeof(p_QDFARFTE->WDFARFNM));


     ProcessField();

    }

 }


int ProcessField() {

      int SflCtl;
      int SizeIdx;
      int FldIdx;
      int NumFlds;
      char ScrnSize[1];
      char Attrib[1];
      char X01     =  0x01 ;

      /*  record header   */
       p_QDFFRINF = (QDFFRINF_t *)((char *) p_QDFFINFO + p_QDFARFTE->WDFARFOF);
      /*  record dev dept  */
       p_QDFFRDPD = (QDFFRDPD_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFRAOF);
      /*  SFLCTL                                                              */
      /* 12  C       BIN(31) WDFFRFLG    Miscellaneous record contents.       */
      /* 12  C   0   BIT(1)  WDFFUDDS    If on, USRDFN keyword is specified.  */
      /* 12  C   1   BIT(1)  WDFFSFL If on, SFL keyword is specified (next rec*/
      /* 12  C   2   BIT(1)  WDFFSFLC    If on, SFLCTL keyword is specified (p*/
       SflCtl = 0;
       if (p_QDFFRINF->WDFFRFLG.WDFFSFLC)
        {  SflCtl = 1;
     p_QDFFSFCR  = (QDFFSFCR_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFRAOF);
     p_QDFFSFHR  = (QDFFSFHR_t *)((char *) p_QDFFSFCR + sizeof(QDFFSFCR_t));
         }

     for (SizeIdx=0; SizeIdx<p_QDFFBASE->WDFFSCR -1; ++SizeIdx) {
     p_QDFFSCRA  = (QDFFSCRA_t *)((char *) p_QDFFBASE + sizeof(QDFFBASE_t)
                          + sizeof(QDFFSCRA_t) * SizeIdx    ) ;
    *ScrnSize =  p_QDFFSCRA->WDFFSCIA ;
     }
    /* Find RowColumn table. Note: this is the first row/col table */
    /* so this code only works for the PRIMARY DISPLAY SIZE. */
    /* See QDFFRDPD.WDFFDRCO field description for finding the */
    /* correct QDFFRCTB structure if more than one screen size is */
    /* used. */
      p_QDFFRCTB = (QDFFRCTB_t *)((char *) p_QDFFRINF + p_QDFFRDPD->WDFFDRCO);

    /********  HERE include code for Record Keywords ********/

    /*  PROCESS THE RECORDS FIELDS    */
        /* Find where used section */

      p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWRLEN);
      p_QDFFFITB = (QDFFFITB_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFOFIT
                   +  ( p_QDFWFLDI->WDFWRRDX -1) * sizeof(QDFFFITB_t));


    for (FldIdx=0; FldIdx < p_QDFFRINF->WDFFFLD; ++FldIdx) {

     p_QDFFFINF = (QDFFFINF_t *)((char *) p_QDFFRINF + p_QDFFFITB->WDFFFOFS);

    memmove(Attrib,p_QDFFFINF->WDFFFIOA, 1);
     if (strncmp(Attrib,X01, 1) == 0) {
      NumFlds += 1;
     }





   /***********  HERE include code for Field KEYWORDS **********/

      if (FldIdx < p_QDFFRINF->WDFFFLD -1) {
       p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWFLDI + p_QDFWFLDI->WDFWFLDL);
       p_QDFFFITB = (QDFFFITB_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFOFIT
                   +  ( p_QDFWFLDI->WDFWRRDX -1) * sizeof(QDFFFITB_t));
       }

      NumFlds += 1;



    }

 }



int FindRec() {
        int i;
    /* Access returned structures. The base structure starts at */
    /* the begining of the returned space. */
        p_QDFFBASE = (QDFFBASE_t *)ReturnVar;
        p_QDFFINFO = (QDFFINFO_t *)((char *) p_QDFFBASE + p_QDFFBASE->WDFFINOF);
        p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFDFLO);
    /* While there are records, look for the requested record name */
    /* in the QDFARFTE structure. */
    for (i=0; i<p_QDFFBASE->WDFFRCS; ++i) {
    if (strncmp(p_QDFARFTE->WDFARFNM,MyRec,10) == 0) {
        RecIndex = i + 1; /* Entry in QDFARFTE table for the requested name*/

    /* Access additional structures. */
        p_QDFFRINF = (QDFFRINF_t *)((char *) p_QDFFINFO + p_QDFARFTE->WDFARFOF);
        p_QDFFRDPD = (QDFFRDPD_t *)((char *) p_QDFFRINF + p_QDFFRINF->WDFFRAOF);
    /* Find RowColumn table. Note: this is the first row/col table */
    /* so this code only works for the PRIMARY DISPLAY SIZE. */
    /* See QDFFRDPD.WDFFDRCO field description for finding the */
    /* correct QDFFRCTB structure if more than one screen size is */
    /* used. */
        p_QDFFRCTB = (QDFFRCTB_t *)((char *) p_QDFFRINF + p_QDFFRDPD->WDFFDRCO);
            FindField(); /* Find the requested field */
        return(0); /* Task is done. */
 }
    else
        p_QDFARFTE = (QDFARFTE_t *)((char *) p_QDFARFTE + sizeof(QDFARFTE_t));
 }
    /* If this point is reached, there was no match for the requested */
    /* record. */
        printf("\nThe requested record was not found %s",MyRec);
        return(0);
 }


int FindField () {
    int j;
    int k;
    int NtblIndex;
    char *NamePtr;
    int RCIndex;
    int RecNumber;
    /* Find where used section */
       p_QDFWFLEI = (QDFWFLEI_t *)((char *) p_QDFFINFO + p_QDFFINFO->WDFFWUOF);
    /* Find name table. There is one entry for each unique field */
    /* name used in the file. A given name may be used in more than */
    /* one record format. */
       p_QDFFNTBL = (QDFFNTBL_t *)((char *) p_QDFWFLEI + p_QDFWFLEI->WDFWNTBO);
    /* Prepare to search table. Start search after the fixed portion. */
        NamePtr = (char *) p_QDFFNTBL + sizeof(QDFFNTBL_t);
        NtblIndex = 0;
    /* Find requested name */
    for (j=0; j<p_QDFFNTBL->WDFFNMS; ++j) {
        if (strncmp(NamePtr,MyField,10) == 0) {
            NtblIndex = j + 1;
    /* The requested name was found   Get first QDFWRCDI structure. */
   p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWFLEI +p_QDFWFLEI->WDFWXLEN);
            RecNumber = 1;

    /* For each record, find the first field structure.          +
    Then, find a match for the field name table index            +
     If found, the field structure containing the matched index  +
     also contains the row/column index. */

     for (j=0; j<p_QDFFBASE->WDFFRCS; ++j) {
    /* Make sure the field matching is for the correct record. */
        if (RecNumber == RecIndex) {
        p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWRLEN);
    /* Search for the correct field structure */
        for (k=0; k<p_QDFFRINF->WDFFFLD; ++k) {
    /* Find the correct structure by finding a match for the */
    /* index into the field name table. */
        if (NtblIndex == p_QDFWFLDI->WDFWNMEI) {
            RCIndex = p_QDFWFLDI->WDFWRRDX; /* Row/Col index */
    /* Point to first Row/Col Entry */
    p_QDFFRCTE = (QDFFRCTE_t *)((char *) p_QDFFRCTB + sizeof(QDFFRCTB_t));
    /* Point to correct Row/Col Entry. Each entry is 2 bytes. */
    p_QDFFRCTE = (QDFFRCTE_t *)((char *) p_QDFFRCTE + ((RCIndex - 1) * 2 ));
         printf("\n%s %s Row and column (hex) %02x %02x",MyRec,MyField,
            *(char *) p_QDFFRCTE,*((char *) p_QDFFRCTE+1));
         return(0); /* Task is done */
    }
    else
        p_QDFWFLDI = (QDFWFLDI_t *)((char *) p_QDFWFLDI + p_QDFWFLDI->WDFWFLDL);
    }
    }
    else {
    /* Bump ptr to next record structure */
        p_QDFWRCDI = (QDFWRCDI_t *)((char *) p_QDFWRCDI + p_QDFWRCDI->WDFWNXTR);
    RecNumber = RecNumber + 1;
        }
    }
    }
    else
        NamePtr = NamePtr + 10; /* Size of field name*/
    }
    /* If this point is reached, the field was not found */
        printf("\nThe requested field was not found %s %s",MyRec,MyField);
    return (0);
 }