docs: public void writeSetupKey(CodeType codeType, boolean bAutoCounterField)
      { // Now, write the key setup method
          Record recClassInfo = this.getMainRecord();
          try   {
              String strKeyName = DBConstants.BLANK;
              String strRecordClass = recClassInfo.getField(ClassInfo.CLASS_NAME).getString();
              
              Record recKeyInfo = this.getRecord(KeyInfo.KEY_INFO_FILE);
              recKeyInfo.close();
              if (codeType == CodeType.THICK)
                  if (!recKeyInfo.hasNext())
              {
                  recKeyInfo.close();
                  return;
              }
          
              if (codeType == CodeType.THICK)
              {
                  this.writeMethodInterface(null, "setupKey", "KeyArea", "int iKeyArea", "", "Add this key area description to the Record.", null);
                  m_StreamOut.setTabs(+1);
                  m_StreamOut.writeit("KeyArea keyArea = null;\n");
              }
              else
              {  // Thin
                  // Now write out the setupkey method.
                  m_StreamOut.writeit("/**\n");
                  m_StreamOut.writeit("* Set up the key areas.\n");
                  m_StreamOut.writeit("*/\n");
                  m_StreamOut.writeit("public void setupKeys()\n");
                  m_StreamOut.writeit("{\n");
                  m_StreamOut.setTabs(+1);
                  m_StreamOut.writeit("KeyAreaInfo keyArea = null;\n");
              }
          
              int count = 0;
              recKeyInfo.close();
              while (recKeyInfo.hasNext())
              {
                  recKeyInfo.next();
                  String finalKeyName = "";
                  strKeyName = recKeyInfo.getField(KeyInfo.KEY_NAME).getString();
                  if (strKeyName.length() == 0)
                  {
                      strKeyName = recKeyInfo.getField(KeyInfo.KEY_FIELD_1).getString();
                      if (count == 0)
                          finalKeyName = DBConstants.PRIMARY_KEY;
                      else
                      {   // No key name, use the field name!
                          FieldData recFieldData = (FieldData)this.getRecord(FieldData.FIELD_DATA_FILE);
                          recFieldData.initRecord(false);
                          String strFieldName, strBaseFieldName;
                          strFieldName = strKeyName;
                          strBaseFieldName = "";
                          m_BasedFieldHelper.getBasedField(recFieldData, strRecordClass, strFieldName, strBaseFieldName);  // Get the field this is based on
                          finalKeyName = recFieldData.getField(FieldData.FIELD_NAME).getString();
                      }
                  }
  
                  String strKeyType = recKeyInfo.getField(KeyInfo.KEY_TYPE).getString();
                  finalKeyName = this.fixSQLName(finalKeyName);
                  String strUnique = "UNIQUE";
                  if (strKeyType.equalsIgnoreCase(KeyTypeField.UNIQUE))
                      strUnique = "UNIQUE";
                  else if (strKeyType.equalsIgnoreCase(KeyTypeField.NOT_UNIQUE))
                      strUnique = "NOT_UNIQUE";
                  else if (strKeyType.equalsIgnoreCase(KeyTypeField.SECONDARY))
                      strUnique = "SECONDARY_KEY";
                  else
                  {   // Not specified.
                      if (strKeyName.equalsIgnoreCase(DBConstants.PRIMARY_KEY))
                          strUnique = "UNIQUE";
                      else
                          strUnique = "NOT_UNIQUE";
                  }
  
                  if (finalKeyName.length() == 0)
                      finalKeyName = strKeyName;
                  if (strKeyName.equalsIgnoreCase(DBConstants.PRIMARY_KEY))
                      strKeyName = strRecordClass + "Primary";    // To avoid re-defining kPrimaryKey
                  else
                  {
                      if (count == 0)
                          if (recKeyInfo.getField(KeyInfo.KEY_NUMBER).isNull())
                          {   // Special case, no sequence, first key is not the primary key... first key must be primary key
                              recKeyInfo.addNew();
                              strUnique = "UNIQUE";
                              recKeyInfo.getField(KeyInfo.KEY_FIELD_1).setString(DBConstants.PRIMARY_KEY);
                              recKeyInfo.close();
                          }
                  }
                  if (codeType == CodeType.THICK)
                  {
                      m_StreamOut.writeit("if (iKeyArea == " + count + ")\n");
                      m_StreamOut.writeit("{\n");
                      m_StreamOut.setTabs(+1);
                  }
                  count++;
                  if (codeType == CodeType.THICK)
                      m_StreamOut.writeit("keyArea = this.makeIndex(DBConstants." + strUnique + ", " + this.convertNameToConstant(finalKeyName + "Key") + ");\n");
                  else    // Thin
                      m_StreamOut.writeit("keyArea = new KeyAreaInfo(this, Constants." + strUnique + ", " + this.convertNameToConstant(finalKeyName + "Key") + ");\n");                    
  
                  boolean bAscending = true;
                  if (recKeyInfo.getField(KeyInfo.KEY_FIELD_9).getString().equalsIgnoreCase("D"))
                      bAscending = false;     // *Fix this to allow Ascending/Descending on each key area!*
                  for (int i = recKeyInfo.getFieldSeq(KeyInfo.KEY_FIELD_1); i <= recKeyInfo.getFieldSeq(KeyInfo.KEY_FIELD_9); i++)
                  {
                      String strKeyFieldName = recKeyInfo.getField(i).getString();
                      if (strKeyFieldName.length() == 0)
                          break;
                      String strAscending = "ASCENDING";
                      if (!bAscending)
                          strAscending = "DESCENDING";
                      if (codeType == CodeType.THICK)
                          m_StreamOut.writeit("keyArea.addKeyField(" + this.convertNameToConstant(strKeyFieldName) + ", DBConstants." + strAscending + ");\n");
                      else // Thin
                          m_StreamOut.writeit("keyArea.addKeyField(" + this.convertNameToConstant(strKeyFieldName) + ", Constants." + strAscending + ");\n");
                  }
                  if (codeType == CodeType.THICK)
                  {
                      m_StreamOut.setTabs(-1);
                      m_StreamOut.writeit("}\n");
                  }
              }
              recKeyInfo.close();
              if (codeType == CodeType.THICK)
              {
                  m_StreamOut.writeit("if (keyArea == null)\n");
                  m_StreamOut.setTabs(+1);
                  m_StreamOut.writeit("keyArea = super.setupKey(iKeyArea);\t\t\n");
                  m_StreamOut.setTabs(-1);
                  m_StreamOut.writeit("return keyArea;\n");
                  m_StreamOut.setTabs(-1);
                  m_StreamOut.writeit("}\n");
              }
              else
              {  // Thin
                  if (count == 0)
                      m_StreamOut.writeit("super.setupKeys();\n");
                  
                  m_StreamOut.setTabs(-1);
                  m_StreamOut.writeit("}\n");
                  
                  if (!bAutoCounterField)
                  {
                      m_StreamOut.writeit("/**\n");
                      m_StreamOut.writeit("* This is not an auto-counter record.\n");
                      m_StreamOut.writeit("*/\n");
                      m_StreamOut.writeit("public boolean isAutoSequence()\n");
                      m_StreamOut.writeit("{\n");
                      m_StreamOut.setTabs(+1);
                      m_StreamOut.writeit("return false;\n");
                      m_StreamOut.setTabs(-1);
                      m_StreamOut.writeit("}\n");
                  }               
              }
          } catch (DBException ex)   {
              ex.printStackTrace();
          }
      }