FAQ-VARPG

The RPGIV for the Windows FAQ Screen
      ********************************************************************
     FUtlFAQ10P IF   e           k disk    remote

      * Declare %NewHeight, and %NewWidth event attributes. These will
      * contain the width and height of the window after it is has been
      * resized.
     D%NEWHEIGHT       S              4  0
     D%NEWWIDTH        S              4  0
     D%NewMode         S              1  0
     D%COLNUMBER       S              4  0

      * NewRcd
     D   RecordID      S              6  0
     D   Parent        S              6
     D   LastRecordID  S                   Like(RecordID)
     D                                     INZ(*zeros)

      *Container icons:
      *use *.gif file for Java
      /If defined(COMPILE_JAVA)
     D Box             C                   'DashBox.GIF'
     D Check           C                   'CHECKOFF.GIF'
     D Note            C                   'STICKY.GIF'
      /Else
     D Box             C                   'DashBox.ICO'
     D Check           C                   'CHECKOFF.ICO'
     D Note            C                   'STICKY.ICO'
      /EndIf

     DWTITLE           C                   'FAQ'
     D SavedSubject    S                   Like(FAQSubject)
     D SavedParent     S                   Like(Parent)

     D Tmp7            S              7

      *Container columns:
     D VaryingField    S            480    Varying

      *********************************************************************
     C     CT1           BEGACT    CREATE        MAIN
     C                   EXSR      FRESHSR
     C                   ENDACT
      *********************************************************************
      * To add a record to the container file you'll need to get "GetNewID"
      * for the new container item.  What I do then is to add the record with
      * nothing much in it and modify the contents before displaying it.
      *
      *   As an example,
      *     Eval %SetAtr('Main':'CT1':'Addrcd') =
      *          %Trim(%EditC((RecordID):'3'))+' icon_text icon_file parent'
      *   is the AddRcd action.
      *   The AddRcd action needs the following fields, in this order:
      *      RecordID              1      6
      *      FileName              8     64
      *      Parent                1      6    INZ(0)
      *      Text                  8     20    INZ('Next record')
      *
      * All fields are character, no numeric  There is no required length for
      * the fields, only that they exist and be separated by a blank.  Since
      * all of the fields are separated by a space care must be taken that
      * all embedded blanks are replaced with a character (usually a "_").
      * Please notice the definition of the work field "VaryingField".
      * This is the easiest way I could find so that fields didn't have their
      * trailing blanks replaced by a long string of underbars.
      * Adding fields for the "Details" view:  You'll need to set the
      * column number and then SetRcdFld.
      * Parent/child: indents under a parent occur when the Parent field has a
      * RecordID in it. (The Parent field would of course have the RecordID
      * of the record you wish to have as the parent.)
      *
      *********************************************************************
      * Refresh/fill the canvas:
     C     FRESHSR       BEGSR

     C                   Eval      %SetAtr('Main':'Main':'MouseShape') = 2
      * Clear container 1:
     C                   Eval      %SetAtr('Main':'CT1':'RemoveRcd') = 0

      * Read the records:
     C     SavedSubject  SetLL     UtlFAQ10P
     C                   Read (E)  UtlFAQ10P
     C
      * Load-all; do til eof
     C                   DoW       Not %EOF
     C                   Eval      RecordID =
     C                             %GetAtr('Main':'CT1':'GetNewID')
     C                   Eval      %SetAtr('Main':'CT1':'RecordID') = RecordID
      * Duplicate Subject?
     C                   If        SavedSubject <> FAQSubject
      * New subject:
     C                   Eval      SavedSubject = FAQSubject
     C                   Eval      SavedParent = %editC(RecordID:'3')
     C                   Eval      Parent = *Zeros
     C                   Eval      %SetAtr('Main':'CT1':'Addrcd')=%Trim(%EditC(
     C                             (RecordID):'3'))+' icontext ' + Note + ' '
     C                             + %Trim(parent)

      * set the icon to display:
     C                   Eval      VaryingField = %TrimR(FAQSubject)
     C     ' ':'_'       Xlate     VaryingField  VaryingField
     C                   Eval      %SetAtr('Main':'CT1':'SetRcdText')=
     C                             %Trim(VaryingField)
     C*                   EVAL      %SetAtr('Main':'CT1':'SetRcdIcon')=
     C*                             Note

     C                   Eval      RecordID =
     C                             %GetAtr('Main':'CT1':'GetNewID')
     C                   Eval      %SetAtr('Main':'CT1':'RecordID') = RecordID
     C                   EndIf

      * Set the Question Line:
     C*                   Eval      Parent = SavedParent
     C                   Eval      %SetAtr('Main':'CT1':'Addrcd')=%Trim(%EditC((
     C                             RecordID):'3'))+' icontext ' + Box + ' '
     C                             + %Trim(Savedparent)
     C                   Eval      VaryingField = %TrimR(FAQQuest)

     C     ' ':'_'       Xlate     VaryingField  VaryingField
     C                   Eval      %SetAtr('Main':'CT1':'SetRcdText')=
     C                             %Trim(VaryingField)
     C                   Eval      %SetAtr('Main':'CT1':'SetRcdIcon')
     C                             = Box
      * Set Column 2: (no blanks are allowed in the field, replace with _
     C                   Eval      VaryingField = %TrimR(FAQLine)
     C     ' ':'_'       Xlate     VaryingField  VaryingField
     C                   Eval      %SetAtr('Main':'CT1':'ColNumber')= 2
     C                   Eval      %SetAtr('Main':'CT1':'SetRcdFld')
     C                             = %Trim(VaryingField)

     C                   Read (E)  UtlFAQ10P
     C                   EndDo

     C                   Eval      %SetAtr('Main':'Main':'MouseShape') = 1
     C                   ENDSR
      *********************************************************************
      * User action:
     C     MAIN          BEGACT    RESIZE        MAIN
      /If defined(COMPILE_JAVA)
      /Else
     C                   If        %NewMode <> 2
      * Set new height & width of container:
      *  top container
     C                   Eval      %SetAtr('Main':'CT1':'Height')
     C                             = (%NewHeight / 2) - 30
     C                   Eval      %SetAtr('Main':'CT1':'Left') = 2
     C                   Eval      %SetAtr('Main':'CT1':'Width')=%NewWidth - 13

      * Set new height & width of Multiline edit
      *  Bottom part
     C                   Eval      %SetAtr('Main':'Question':'Height')
     C                             = (%NewHeight / 2) - 65
     C                   Eval      %SetAtr('Main':'Question':'Bottom')
     C                             = %NewHeight - 86
     C                   Eval      %SetAtr('Main':'Question':'Left') = 2
     C                   Eval      %SetAtr('Main':'Question':'Width')=
     C                             %NewWidth - 13

      *  Set bottom of pushbuttons:
     C                   Eval      %SetAtr('Main':'PBExit':'Bottom')
     C                             = %NewHeight- 44
     C                   Eval      %SetAtr('Main':'PBExit':'Left')
     C                             = %NewWidth - 90

     C                   Eval      %SetAtr('Main':'PSBEdit':'Bottom')
     C                             = %NewHeight- 44
     C                   Eval      %SetAtr('Main':'PSBEdit':'Left')
     C                             = %NewWidth - 180

     C                   EndIf

      /EndIf
     C                   ENDACT
      *********************************************************************
      * Subroutine . . :                                                  *
     C     *INZSR        BEGSR
     C                   ENDSR
      *********************************************************************
      * User Action:
     C     MAIN          BEGACT    CLOSE         MAIN
     C                   MOVE      *ON           *INLR
     C                   ENDACT
      *-------------------------------------------------------------------=
      *    Exit push button:                                              =
      *-------------------------------------------------------------------=
     C     PBEXIT        BEGACT    PRESS         MAIN
     C                   Eval      *InLR = *On
     C                   ENDACT
      *-------------------------------------------------------------------=
      *    An Item is selected:                                           =
      *-------------------------------------------------------------------=
     C     CT1           BEGACT    SELECT        MAIN
      * uncheck the last box:
     C                   If        LastRecordID > 0
     C                   Eval      %SetAtr('Main':'CT1':'RecordID')=
     C                             LastRecordID
     C                   Eval      %SetAtr('Main':'CT1':'SetRcdIcon')
     C                             = Box
     C                   Eval      LastRecordID = *Zeros
     C                   EndIf
      * Get the container record ID, create the record structure
     C                   Eval      %SetAtr('Main':'CT1':'RecordID')=
     C                             %GetAtr('Main':'CT1':'FirstSel')

     C                   Select
     C                   When      %GetAtr('Main':'CT1':'GetRcdIcon')
     C                             = Box
      /If defined(COMPILE_JAVA)
      /Else
     C                   Eval      %SetAtr('Main':'CT1':'SetRcdIcon')
     C                              = Check
      /EndIf

     C                   Eval      %SetAtr('Main':'CT1':'ColNumber')= 2
     C                   Eval      VaryingField = %Trim(
     C                             %GetAtr('Main':'CT1':'GetRcdFld'))
     C     '_':' '       Xlate     VaryingField  VaryingField
     C                   Eval      %SetAtr('Main':'Question':'Text')
     C                             = %TrimR(VaryingField)
      * Save RecordID for next click:
     C                   Eval      LastRecordID =
     C                             %GetAtr('Main':'CT1':'RecordID')
      * nothing if selected item is clicked again:
     C                   When      %GetAtr('Main':'CT1':'GetRcdIcon')
     C                             = Check

      * If header clicked:
     C                   Other
     C                   Eval      %SetAtr('Main':'Question':'Text')
     C                             = *Blanks
     C                   Eval      LastRecordID = *Zeros
     C                   EndSl
     C                   ENDACT
      *-------------------------------------------------------------------=     
 







The Java Code generated from the RPGIV code Above

import java.math.BigDecimal;
import com.ibm.varpg.rpgruntime.*;
import com.ibm.varpg.hostservices.runtime.RemoteServerTable;
import com.ibm.as400.evarpg.*;
import com.ibm.varpg.guiruntime.engine.PartObject;
import com.ibm.varpg.guiruntime.engine.VEventObject;
import com.ibm.varpg.guiruntime.engine.OimRt;
import com.ibm.varpg.guiruntime.engine.LanguageRC;
import VisualAgeRPG;

public class FAQ implements com.ibm.varpg.guiruntime.engine.ILanguage
{

   private byte[] indicators;
   private GuiComponent component;
   private ExceptionHandler exceptionHandler;
   private int lineNum;
   private RemoteServerTable rstFile;


   private RpgPacked _COLNUMBER;
   private byte BIF_Eof;
   private RpgPacked _NEWHEIGHT;
   private RpgPacked _NEWMODE;
   private RpgPacked _NEWWIDTH;
   private byte[] _WINDOW;
   private byte[] FAQLINE;
   private byte[] FAQQUEST;
   private byte[] FAQSUBJECT;
   private RpgPacked LASTRECORDID;
   private byte[] PARENT;
   private RpgPacked RECORDID;
   private byte[] SAVEDPARENT;
   private byte[] SAVEDSUBJECT;
   private byte[] TMP7;
   private RemoteKeyedDiskFile UTLFAQ10P;
   private VarLenFld VARYINGFIELD;


   // -----------------------------------------------------
   // 
   //  FAQ::main
   // 
   // -----------------------------------------------------
   public final static void main(String[] args) 
   {
      VisualAgeRPG.main("FAQ", args);

   }

   // -----------------------------------------------------
   // 
   //  FAQ::UTLFAQ10P_iFlds
   // 
   // -----------------------------------------------------
   private void UTLFAQ10P_iFlds()
      throws RpgException, RpgFileException
   {
      if (UTLFAQ10P.compareInputFormatNames("RUTLFAQ10P"))
      {
         // FAQSUBJECT
         UTLFAQ10P.getBytesField(FAQSUBJECT,0,30,37);

         // FAQQUEST
         UTLFAQ10P.getBytesField(FAQQUEST,30,60,37);

         // FAQLINE
         UTLFAQ10P.getBytesField(FAQLINE,90,480,37);

      }
      else
      UTLFAQ10P.throwFileError(1011);

   }

   // -----------------------------------------------------
   // 
   //  FAQ::CT1_CREATE_MAIN
   // 
   // -----------------------------------------------------
   private void CT1_CREATE_MAIN(
   PartObject part, VEventObject event, LanguageRC languageRC)
   
      throws RpgException, RpgFileException
   {
      component.actionSubroutineInit();

      lineNum = 42;

      // EXSR
      FRESHSR(part,event);

      component.setPmAction(LanguageRC.do_default_processing);

   }

   // -----------------------------------------------------
   // 
   //  FAQ::FRESHSR
   // 
   // -----------------------------------------------------
   private void FRESHSR(
   PartObject part, VEventObject event)
      throws RpgException, RpgFileException
   {
      lineNum = 76;

      // EVAL
      Integer intObj1;

      intObj1 = new Integer(2);

      PartObject partObj2;

      partObj2 = component.getPartHandle(part,"MAIN","MAIN");

      component.setObjectAttribute(partObj2,"MOUSESHAPE",intObj1,4,(byte) 0,
      false);

      lineNum = 78;

      // EVAL
      intObj1 = new Integer(0);

      partObj2 = component.getPartHandle(part,"MAIN","CT1");

      component.setObjectAttribute(partObj2,"REMOVERCD",intObj1,4,(byte) 0,false
      );

      lineNum = 81;

      // SETLL
      UTLFAQ10P.resetKeyedValues();

      UTLFAQ10P.addKeyValue(SAVEDSUBJECT);

      UTLFAQ10P.completeKeyValues();

      try
      {
         UTLFAQ10P.setxx(null,true);

      }
      catch(RpgFileException e)
      {
         exceptionHandler.setStatus(e.status,lineNum,false,e.msgData);

         if (e.status > 100)
         {
            throw e;

         }

      }

      lineNum = 82;

      exceptionHandler.clearStatus(lineNum);

      // READ
      BIF_Eof = (byte) '0';

      try
      {
         UTLFAQ10P.read(null,false);

         UTLFAQ10P_iFlds();

      }
      catch(RpgFileException e)
      {
         exceptionHandler.setStatus(e.status,lineNum,false,e.msgData);

         if (e.status > 100)
         {
         }

         if (e.status == 11)
         {
            BIF_Eof = (byte) '1';

         }
      }

      lineNum = 85;

      // DOW
      boolean bool3;

      bool3 = true;

      while (bool3)
      {
         boolean bool4;

         bool4 = !(BIF_Eof == (byte) '1') ? true : false;

         bool3 = bool4;

         if (bool3)
         {
            try
            {
               if (false)
               {
                  throw new RpgBreak();

               }

               lineNum = 86;

               // EVAL
               int int5;

               partObj2 = component.getPartHandle(part,"MAIN","CT1");

               int5 = component.getObjectAttributeInt(false,partObj2,"GETNEWID",
               4,10,0);

               RECORDID.assign(int5,false);

               lineNum = 88;

               // EVAL
               partObj2 = component.getPartHandle(part,"MAIN","CT1");

               component.setObjectAttribute(partObj2,"RECORDID",RECORDID,2,
               (byte) 0,false);

               lineNum = 90;

               // IF
               int5 = RpgLang.byteCompare(SAVEDSUBJECT,FAQSUBJECT);

               bool4 = int5 != 0;

               if (bool4)
               {
                  lineNum = 92;

                  // EVAL
                  RpgLang.moveToCharFixed(FAQSUBJECT,SAVEDSUBJECT,true,true);

                  lineNum = 93;

                  // EVAL
                  byte[] byteArr6;

                  byteArr6 =  RpgEditNumeric.editNumericField( RECORDID.
                  zonedValue(),(short) 6,(short) 0,(short) 6,false,"3.,/ "
                  .getBytes(),null);

                  RpgLang.moveToCharFixed(byteArr6,SAVEDPARENT,true,true);

                  lineNum = 94;

                  // EVAL
                  byteArr6 = RpgLang.fillWithPattern(6,(byte) '0');

                  RpgLang.moveToCharFixed(byteArr6,PARENT,false,true);

                  lineNum = 95;

                  // EVAL
                  byteArr6 =  RpgEditNumeric.editNumericField( RECORDID.
                  zonedValue(),(short) 6,(short) 0,(short) 6,false,"3.,/ "
                  .getBytes(),null);

                  byte[] byteArr7;

                  byteArr7 = RpgLang.charTrimx(byteArr6);

                  byteArr6 = RpgLang.charCatExpr(byteArr7," icontext ");

                  byteArr7 = RpgLang.charCatExpr(byteArr6,"STICKY.GIF");

                  byteArr6 = RpgLang.charCatExpr(byteArr7," ");

                  byteArr7 = RpgLang.charTrimx(PARENT);

                  byte[] byteArr8;

                  byteArr8 = RpgLang.charCatExpr(byteArr6,byteArr7);

                  partObj2 = component.getPartHandle(part,"MAIN","CT1");

                  component.setObjectAttribute(partObj2,"ADDRCD",byteArr8,0,
                  (byte) 0,false);

                  lineNum = 100;

                  // EVAL
                  byteArr8 = RpgLang.charTrimr(FAQSUBJECT);

                  VARYINGFIELD.setDataAndLen(byteArr8,true,true);

                  lineNum = 101;

                  // XLATE
                  RpgLang.charXlate(" ","_",1,VARYINGFIELD.getData(),
                  VARYINGFIELD,false);

                  lineNum = 102;

                  // EVAL
                  byteArr7 = RpgLang.charTrimx(VARYINGFIELD.getData());

                  partObj2 = component.getPartHandle(part,"MAIN","CT1");

                  component.setObjectAttribute(partObj2,"SETRCDTEXT",byteArr7,0,
                  (byte) 0,false);

                  lineNum = 107;

                  // EVAL
                  partObj2 = component.getPartHandle(part,"MAIN","CT1");

                  int5 = component.getObjectAttributeInt(false,partObj2,"GETNEWID"
                  ,4,10,0);

                  RECORDID.assign(int5,false);

                  lineNum = 109;

                  // EVAL
                  partObj2 = component.getPartHandle(part,"MAIN","CT1");

                  component.setObjectAttribute(partObj2,"RECORDID",RECORDID,2,
                  (byte) 0,false);

               }
               lineNum = 114;

               // EVAL
               byte[] byteArr9;

               byteArr9 =  RpgEditNumeric.editNumericField( RECORDID.zonedValue
               (),(short) 6,(short) 0,(short) 6,false,"3.,/ ".getBytes(),null);

               byte[] byteArr10;

               byteArr10 = RpgLang.charTrimx(byteArr9);

               byteArr9 = RpgLang.charCatExpr(byteArr10," icontext ");

               byteArr10 = RpgLang.charCatExpr(byteArr9,"DashBox.GIF");

               byteArr9 = RpgLang.charCatExpr(byteArr10," ");

               byteArr10 = RpgLang.charTrimx(SAVEDPARENT);

               byte[] byteArr11;

               byteArr11 = RpgLang.charCatExpr(byteArr9,byteArr10);

               partObj2 = component.getPartHandle(part,"MAIN","CT1");

               component.setObjectAttribute(partObj2,"ADDRCD",byteArr11,0,
               (byte) 0,false);

               lineNum = 117;

               // EVAL
               byteArr11 = RpgLang.charTrimr(FAQQUEST);

               VARYINGFIELD.setDataAndLen(byteArr11,true,true);

               lineNum = 119;

               // XLATE
               RpgLang.charXlate(" ","_",1,VARYINGFIELD.getData(),VARYINGFIELD,
               false);

               lineNum = 120;

               // EVAL
               byteArr10 = RpgLang.charTrimx(VARYINGFIELD.getData());

               partObj2 = component.getPartHandle(part,"MAIN","CT1");

               component.setObjectAttribute(partObj2,"SETRCDTEXT",byteArr10,0,
               (byte) 0,false);

               lineNum = 122;

               // EVAL
               partObj2 = component.getPartHandle(part,"MAIN","CT1");

               component.setObjectAttribute(partObj2,"SETRCDICON","DashBox.GIF",
               0,(byte) 0,false);

               lineNum = 125;

               // EVAL
               byteArr10 = RpgLang.charTrimr(FAQLINE);

               VARYINGFIELD.setDataAndLen(byteArr10,true,true);

               lineNum = 126;

               // XLATE
               RpgLang.charXlate(" ","_",1,VARYINGFIELD.getData(),VARYINGFIELD,
               false);

               lineNum = 127;

               // EVAL
               intObj1 = new Integer(2);

               partObj2 = component.getPartHandle(part,"MAIN","CT1");

               component.setObjectAttribute(partObj2,"COLNUMBER",intObj1,4,
               (byte) 0,false);

               lineNum = 128;

               // EVAL
               byteArr9 = RpgLang.charTrimx(VARYINGFIELD.getData());

               partObj2 = component.getPartHandle(part,"MAIN","CT1");

               component.setObjectAttribute(partObj2,"SETRCDFLD",byteArr9,0,
               (byte) 0,false);

               lineNum = 131;

               exceptionHandler.clearStatus(lineNum);

               // READ
               BIF_Eof = (byte) '0';

               try
               {
                  UTLFAQ10P.read(null,false);

                  UTLFAQ10P_iFlds();

               }
               catch(RpgFileException e)
               {
                  exceptionHandler.setStatus(e.status,lineNum,false,e.msgData);

                  if (e.status > 100)
                  {
                  }

                  if (e.status == 11)
                  {
                     BIF_Eof = (byte) '1';

                  }
               }

            }
            catch(RpgBreak e)
            {
            }
         }
      }
      lineNum = 134;

      // EVAL
      intObj1 = new Integer(1);

      partObj2 = component.getPartHandle(part,"MAIN","MAIN");

      component.setObjectAttribute(partObj2,"MOUSESHAPE",intObj1,4,(byte) 0,
      false);

   }

   // -----------------------------------------------------
   // 
   //  FAQ::MAIN_RESIZE_MAIN
   // 
   // -----------------------------------------------------
   private void MAIN_RESIZE_MAIN(
   PartObject part, VEventObject event, LanguageRC languageRC)
   
      throws RpgException, RpgFileException
   {
      component.actionSubroutineInit();

      if (false)
      {
         throw new RpgFileException(0);

      }

      if (false)
      {
         throw new RpgException(0);

      }

      component.setPmAction(LanguageRC.do_default_processing);

   }

   // -----------------------------------------------------
   // 
   //  FAQ::_INZSR
   // 
   // -----------------------------------------------------
   private void _INZSR(
   PartObject part, VEventObject event)
      throws RpgException, RpgFileException
   {
      if (false)
      {
         throw new RpgFileException(0);

      }

      if (false)
      {
         throw new RpgException(0);

      }

   }

   // -----------------------------------------------------
   // 
   //  FAQ::MAIN_CLOSE_MAIN
   // 
   // -----------------------------------------------------
   private void MAIN_CLOSE_MAIN(
   PartObject part, VEventObject event, LanguageRC languageRC)
   
      throws RpgException, RpgFileException
   {
      component.actionSubroutineInit();

      if (false)
      {
         throw new RpgFileException(0);

      }

      if (false)
      {
         throw new RpgException(0);

      }

      lineNum = 150;

      // MOVE
      byte[] byteArr1;

      byteArr1 = RpgLang.fillWithPattern(1,(byte) '1');

      RpgLang.moveToCharFixed(byteArr1,100 - 1,1,indicators,false,false);

      component.setPmAction(LanguageRC.do_default_processing);

   }

   // -----------------------------------------------------
   // 
   //  FAQ::PBEXIT_PRESS_MAIN
   // 
   // -----------------------------------------------------
   private void PBEXIT_PRESS_MAIN(
   PartObject part, VEventObject event, LanguageRC languageRC)
   
      throws RpgException, RpgFileException
   {
      component.actionSubroutineInit();

      if (false)
      {
         throw new RpgFileException(0);

      }

      if (false)
      {
         throw new RpgException(0);

      }

      lineNum = 156;

      // EVAL
      byte[] byteArr1;

      byteArr1 = RpgLang.fillWithPattern(1,(byte) '1');

      indicators[99] = byteArr1[0];

      component.setPmAction(LanguageRC.do_default_processing);

   }

   // -----------------------------------------------------
   // 
   //  FAQ::CT1_SELECT_MAIN
   // 
   // -----------------------------------------------------
   private void CT1_SELECT_MAIN(
   PartObject part, VEventObject event, LanguageRC languageRC)
   
      throws RpgException, RpgFileException
   {
      component.actionSubroutineInit();

      if (false)
      {
         throw new RpgFileException(0);

      }

      lineNum = 163;

      // IF
      boolean bool1;

      int int2;

      int2 = LASTRECORDID.compare((new RpgPacked(0,1,0)));

      bool1 = int2 == 1;

      if (bool1)
      {
         lineNum = 164;

         // EVAL
         component.setObjectAttribute(part,"RECORDID",LASTRECORDID,2,(byte) 0,
         false);

         lineNum = 166;

         // EVAL
         component.setObjectAttribute(part,"SETRCDICON","DashBox.GIF",0,(byte) 0
         ,false);

         lineNum = 168;

         // EVAL
         LASTRECORDID.assign(0,false);

      }
      lineNum = 171;

      // EVAL
      int2 = component.getObjectAttributeInt(false,part,"FIRSTSEL",4,10,0);

      Integer intObj3;

      intObj3 = new Integer(int2);

      component.setObjectAttribute(part,"RECORDID",intObj3,4,(byte) 0,false);

      lineNum = 174;

      // SELECT
      bool1 = true;

      if (bool1)
      {
         byte[] byteArr4;

         byteArr4 = component.getObjectAttributeBA(false,part,"GETRCDICON",0,0,0
         );

         boolean bool5;

         int2 = RpgLang.byteCompare(byteArr4,"DashBox.GIF");

         bool5 = int2 == 0;

         if (bool5)
         {
            bool1 = false;

            lineNum = 181;

            // EVAL
            intObj3 = new Integer(2);

            component.setObjectAttribute(part,"COLNUMBER",intObj3,4,(byte) 0,
            false);

            lineNum = 182;

            // EVAL
            byteArr4 = component.getObjectAttributeBA(false,part,"GETRCDFLD",0,0
            ,0);

            byte[] byteArr6;

            byteArr6 = RpgLang.charTrimx(byteArr4);

            VARYINGFIELD.setDataAndLen(byteArr6,true,true);

            lineNum = 184;

            // XLATE
            RpgLang.charXlate("_"," ",1,VARYINGFIELD.getData(),VARYINGFIELD,
            false);

            lineNum = 185;

            // EVAL
            byteArr4 = RpgLang.charTrimr(VARYINGFIELD.getData());

            PartObject partObj7;

            partObj7 = component.getPartHandle(part,"MAIN","QUESTION");

            component.setObjectAttribute(partObj7,"TEXT",byteArr4,0,(byte) 0,
            false);

            lineNum = 188;

            // EVAL
            int2 = component.getObjectAttributeInt(false,part,"RECORDID",4,10,0);

            LASTRECORDID.assign(int2,false);

         }
      }
      if (bool1)
      {
         byte[] byteArr8;

         byteArr8 = component.getObjectAttributeBA(false,part,"GETRCDICON",0,0,0
         );

         boolean bool9;

         int2 = RpgLang.byteCompare(byteArr8,"CHECKOFF.GIF");

         bool9 = int2 == 0;

         if (bool9)
         {
            bool1 = false;

         }
         else
         {
            lineNum = 196;

            // EVAL
            PartObject partObj10;

            partObj10 = component.getPartHandle(part,"MAIN","QUESTION");

            component.setObjectAttribute(partObj10,"TEXT",null,0,(byte) 6,false);

            lineNum = 198;

            // EVAL
            LASTRECORDID.assign(0,false);

         }
      }
      component.setPmAction(LanguageRC.do_default_processing);

   }

   // -----------------------------------------------------
   // 
   //  FAQ::FAQ
   // 
   // -----------------------------------------------------
   public FAQ() 
   {
      indicators = new byte[100];

      rstFile = new RemoteServerTable("FAQ.RST",this);

      int int1;

      for (int1 = 0; int1 < 100; int1++)
      {
         indicators[int1] = (byte) '0';

      }

      _COLNUMBER = new RpgPacked(4,0);

      BIF_Eof = (byte) '0';

      _NEWHEIGHT = new RpgPacked(4,0);

      _NEWMODE = new RpgPacked(1,0);

      _NEWWIDTH = new RpgPacked(4,0);

      _WINDOW = new byte[10];

      RpgLang.moveCharBlanks(_WINDOW,0);

      FAQLINE = new byte[480];

      RpgLang.moveCharBlanks(FAQLINE,0);

      FAQQUEST = new byte[60];

      RpgLang.moveCharBlanks(FAQQUEST,0);

      FAQSUBJECT = new byte[30];

      RpgLang.moveCharBlanks(FAQSUBJECT,0);

      LASTRECORDID = new RpgPacked(0,6,0);

      PARENT = new byte[6];

      RpgLang.moveCharBlanks(PARENT,0);

      RECORDID = new RpgPacked(6,0);

      SAVEDPARENT = new byte[6];

      RpgLang.moveCharBlanks(SAVEDPARENT,0);

      SAVEDSUBJECT = new byte[30];

      RpgLang.moveCharBlanks(SAVEDSUBJECT,0);

      TMP7 = new byte[7];

      RpgLang.moveCharBlanks(TMP7,0);

      VARYINGFIELD = new VarLenFld(480);

      UTLFAQ10P = new RemoteKeyedDiskFile("UTLFAQ10P".getBytes(),570,(byte) 0,
      null,rstFile,false,false,false);

      RecordFormat RUTLFAQ10PFormat = new RecordFormat("RUTLFAQ10P");

      RUTLFAQ10PFormat.addFieldDescription(new CharacterFieldDescription(
      new AS400Text(30, 37), "FAQSUBJECT","FAQSUBJECT"));

      RUTLFAQ10PFormat.addFieldDescription(new CharacterFieldDescription(
      new AS400Text(60, 37), "FAQQUEST","FAQQUEST"));

      RUTLFAQ10PFormat.addFieldDescription(new CharacterFieldDescription(
      new AS400Text(480, 37), "FAQLINE","FAQLINE"));

      RUTLFAQ10PFormat.addKeyFieldDescription("FAQSUBJECT");

      RUTLFAQ10PFormat.addKeyFieldDescription("FAQQUEST");

      UTLFAQ10P.addRecordFormat(RUTLFAQ10PFormat);

   }

   // -----------------------------------------------------
   // 
   //  FAQ::initializeComponent
   // 
   // -----------------------------------------------------
   public void initializeComponent( 

      String componentType, String componentInstance, boolean primaryComponent, 
         OimRt rt, String[] args, LanguageRC languageRC)
   {
      try
      {
         component = new GuiComponent(rt, primaryComponent, componentType,
            componentInstance);

         exceptionHandler = new ExceptionHandler(null,component);

         UTLFAQ10P.open(false,(byte) '0',null,false);

         _INZSR(null, null);

         if (false)
         {
            throw new RpgFileException(0);

         }

         if (false)
         {
            throw new RpgException(0);

         }

      }
      catch(RpgFileException e)
      {
         exceptionHandler.setStatus(e.status,lineNum,false,e.msgData);

         if (e.status > 0)
         {
            exceptionHandler.defaultHandler();
         }
      }
      catch(RpgException e)
      {
         exceptionHandler.setStatus(e.status,lineNum,true,e.msgData);

         if (e.status > 0)
         {
            exceptionHandler.defaultHandler();
         }
      }
      catch(Throwable e)
      {
         handleException(e, true, null, null);

      }
      finally
      {
         component.makeComponentActive();

         languageRC.rc = component.getEpRc();

      }
   }

   // -----------------------------------------------------
   // 
   //  FAQ::componentInitialized
   // 
   // -----------------------------------------------------
   public void componentInitialized(LanguageRC languageRC) 
   {
      languageRC.rc = 0;

   }

   // -----------------------------------------------------
   // 
   //  FAQ::closingComponentObjects
   // 
   // -----------------------------------------------------
   public void closingComponentObjects(LanguageRC languageRC) 
   {
      try
      {
         component.makeComponentClosing();

         UTLFAQ10P.close(false);

         languageRC.rc = 0;

         if (false)
         {
            throw new RpgException(0);

         }

         if (false)
         {
            throw new RpgFileException(0);

         }

      }
      catch(RpgFileException e)
      {
         if (component.getRpgRc() != 99)
         {
            exceptionHandler.setStatus(e.status,lineNum,false,e.msgData);

            if (e.status > 0)
            {
               exceptionHandler.defaultHandler();
            }
         }
      }
      catch(RpgException e)
      {
      }
      catch(Throwable e)
      {
         if (component.getRpgRc() != 99)
         {
            handleException(e, true, null, null);

         }
      }
      if (component.isPrimaryComponent("FAQ"))
      {
         RpgRemoteCall.destroyAS400Objects();

      }
   }

   // -----------------------------------------------------
   // 
   //  FAQ::terminatingComponent
   // 
   // -----------------------------------------------------
   public void terminatingComponent(LanguageRC languageRC) 
   {
      component.makeComponentTermination();

      languageRC.rc = 0;

   }

   // -----------------------------------------------------
   // 
   //  FAQ::queryVersion
   // 
   // -----------------------------------------------------
   public int queryVersion(LanguageRC languageRC) 
   {
      return 600;

   }

   // -----------------------------------------------------
   // 
   //  FAQ::processActionSubroutine
   // 
   // -----------------------------------------------------
   public void processActionSubroutine( 
      int index, String name, PartObject part, VEventObject event,
       LanguageRC languageRC)
   {
      try
      {
         switch (index)
         {
            case 1: CT1_CREATE_MAIN(part, event, languageRC); break;

            case 2: CT1_SELECT_MAIN(part, event, languageRC); break;

            case 3: MAIN_CLOSE_MAIN(part, event, languageRC); break;

            case 5: MAIN_RESIZE_MAIN(part, event, languageRC); break;

            case 4: PBEXIT_PRESS_MAIN(part, event, languageRC); break;

            default:
            String[] msgData = new String[1];

            msgData[0] = name;

            exceptionHandler.setStatus(2101,0,true,msgData);

            exceptionHandler.defaultHandler();
            break;

         }
      }
      catch(RpgFileException e)
      {
         exceptionHandler.setStatus(e.status,lineNum,true,e.msgData);

         if (e.status > 0)
         {
            exceptionHandler.defaultHandler();
         }
      }
      catch(RpgException e)
      {
         exceptionHandler.setStatus(e.status,lineNum,true,e.msgData);

         if (e.status > 0)
         {
            exceptionHandler.defaultHandler();
         }
      }
      catch(Throwable e)
      {
         handleException(e, true, part, event);

      }
      finally
      {
         component.setReturnCodes(indicators[99]);

         languageRC.rc = component.getEpRc();

      }
   }

   // -----------------------------------------------------
   // 
   //  FAQ::handleException
   // 
   // -----------------------------------------------------
   private void handleException( 
   Throwable e, boolean handleIt,
      PartObject part, VEventObject event)
   {
      String[] strArr1;

      int int2;

      strArr1 = new String[1];

      int2 = 0;

      strArr1[0] = e.getClass().getName();

      if (strArr1[0].equals("com.ibm.varpg.rpgruntime.RpgException"))
      {
         return;

      }
      else if (strArr1[0].equals("java.lang.NullPointerException"))
      {
         int2 = 222;

      }
      else
      {
         int2 = 9999;

         strArr1[0] = "(" + strArr1[0] + " : " + e.getMessage() + ")";

      }
      exceptionHandler.setStatus(int2,lineNum,true,strArr1);

      if (handleIt)
      {
         exceptionHandler.defaultHandler();
      }
   }
}