restoreErrorLine(); setStatus(STATUS_ERROR_CODE,STATUS_VALUE_OFF,""); isInField(lastPos); simulated = true; updateDirty();
if (isStatusErrorCode()) { restoreErrorLine(); setStatus(STATUS_ERROR_CODE,STATUS_VALUE_OFF,""); isInField(lastPos); updateDirty(); } setKBIndicatorOff(); simulated = true;
   protected boolean simulateMnemonic(int mnem){      boolean simulated = false;      switch (mnem) {         case AID_CLEAR :         case AID_ENTER :         case AID_PF1 :         case AID_PF2 :         case AID_PF3 :         case AID_PF4 :         case AID_PF5 :         case AID_PF6 :         case AID_PF7 :         case AID_PF8 :         case AID_PF9 :         case AID_PF10 :         case AID_PF11 :         case AID_PF12 :         case AID_PF13 :         case AID_PF14 :         case AID_PF15 :         case AID_PF16 :         case AID_PF17 :         case AID_PF18 :         case AID_PF19 :         case AID_PF20 :         case AID_PF21 :         case AID_PF22 :         case AID_PF23 :         case AID_PF24 :         case AID_ROLL_DOWN :         case AID_ROLL_UP :         case AID_ROLL_LEFT :         case AID_ROLL_RIGHT :            sendAid(mnem);            simulated  = true;            break;         case AID_HELP :            sessionVT.sendHelpRequest();            simulated  = true;            break;         case AID_PRINT :            sessionVT.hostPrint(1);            simulated  = true;            break;         case BACK_SPACE :            if (screenFields.getCurrentField() != null &&               screenFields.withinCurrentField(lastPos)               && !screenFields.isCurrentFieldBypassField()) {               if (screenFields.getCurrentField().startPos() == lastPos)                  displayError(ERR_CURSOR_PROTECTED);               else {                  setCursorOff();                  screenFields.getCurrentField().getKeyPos(lastPos);                  screenFields.getCurrentField().changePos(-1);                  resetDirty(screenFields.getCurrentField().getCurrentPos());                  shiftLeft(screenFields.getCurrentField().getCurrentPos());                  updateDirty();                  setCursorOn();                  screenFields.setCurrentFieldMDT();                  simulated  = true;               }            }            else {               displayError(ERR_CURSOR_PROTECTED);            }            break;         case BACK_TAB :            if (screenFields.getCurrentField() != null && screenFields.isCurrentFieldHighlightedEntry()) {               resetDirty(screenFields.getCurrentField().startPos);               gotoFieldPrev();               updateDirty();            }            else               gotoFieldPrev();            if (screenFields.isCurrentFieldContinued()) {               do {                  gotoFieldPrev();               }               while (screenFields.isCurrentFieldContinuedMiddle() ||                  screenFields.isCurrentFieldContinuedLast());            }            isInField(lastPos);            simulated  = true;            break;         case UP :         case MARK_UP :            process_XY(lastPos - numCols);            simulated = true;            break;         case DOWN :         case MARK_DOWN :            process_XY(lastPos + numCols);            simulated = true;            break;         case LEFT :         case MARK_LEFT :            process_XY(lastPos - 1);            simulated = true;            break;         case RIGHT :         case MARK_RIGHT :            process_XY(lastPos + 1);            simulated = true;            break;         case NEXTWORD :            gotoNextWord();            simulated = true;            break;         case PREVWORD :            gotoPrevWord();            simulated = true;            break;         case DELETE :            if (screenFields.getCurrentField() != null &&               screenFields.withinCurrentField(lastPos)               && !screenFields.isCurrentFieldBypassField()) {                  setCursorOff();                  resetDirty(lastPos);                  screenFields.getCurrentField().getKeyPos(lastPos);                  shiftLeft(screenFields.getCurrentFieldPos());                  screenFields.setCurrentFieldMDT();                  updateDirty();                  setCursorOn();                  simulated  = true;            }            else {               displayError(ERR_CURSOR_PROTECTED);            }            break;         case TAB :            if (screenFields.getCurrentField() != null && !screenFields.isCurrentFieldContinued()) {               if (screenFields.isCurrentFieldHighlightedEntry()) {                  resetDirty(screenFields.getCurrentField().startPos);                  gotoFieldNext();                  updateDirty();               }               else                  gotoFieldNext();            }            else {               do {                  gotoFieldNext();               }               while (screenFields.getCurrentField() != null && (screenFields.isCurrentFieldContinuedMiddle() ||                     screenFields.isCurrentFieldContinuedLast()));            }            isInField(lastPos);            simulated  = true;            break;         case EOF :            if (screenFields.getCurrentField() != null &&               screenFields.withinCurrentField(lastPos)               && !screenFields.isCurrentFieldBypassField()) {               int where = endOfField(screenFields.getCurrentField().startPos(),true);               if (where > 0) {                  goto_XY((where / numCols) + 1,(where % numCols) + 1);               }               simulated = true;            }            else {               displayError(ERR_CURSOR_PROTECTED);            }            resetDirty(lastPos);            break;         case ERASE_EOF :            if (screenFields.getCurrentField() != null &&               screenFields.withinCurrentField(lastPos)               && !screenFields.isCurrentFieldBypassField()) {               setCursorOff();               int where = lastPos;               resetDirty(lastPos);               if (fieldExit()) {                  screenFields.setCurrentFieldMDT();                  if (!screenFields.isCurrentFieldContinued()) {                     gotoFieldNext();                  }                  else {                     do {                        gotoFieldNext();                        if (screenFields.isCurrentFieldContinued())                           fieldExit();                     }                     while (screenFields.isCurrentFieldContinuedMiddle() ||                        screenFields.isCurrentFieldContinuedLast());                  }               }               updateDirty();               goto_XY(where);               setCursorOn();               simulated  = true;            }            else {                  displayError(ERR_CURSOR_PROTECTED);            }            break;         case ERASE_FIELD :            if (screenFields.getCurrentField() != null &&               screenFields.withinCurrentField(lastPos)               && !screenFields.isCurrentFieldBypassField()) {               setCursorOff();               int where = lastPos;               lastPos = screenFields.getCurrentField().startPos();               resetDirty(lastPos);               if (fieldExit()) {                  screenFields.setCurrentFieldMDT();                  if (!screenFields.isCurrentFieldContinued()) {                     gotoFieldNext();                  }                  else {                     do {                        gotoFieldNext();                        if (screenFields.isCurrentFieldContinued())                           fieldExit();                     }                     while (screenFields.isCurrentFieldContinuedMiddle() ||                        screenFields.isCurrentFieldContinuedLast());                  }               }               updateDirty();               goto_XY(where);               setCursorOn();               simulated  = true;            }            else {                  displayError(ERR_CURSOR_PROTECTED);            }            break;         case INSERT :            setCursorOff();            // we toggle it            insertMode = insertMode ? false : true;            setCursorOn();            break;         case HOME :            // position to the home position set            if (lastPos + numCols + 1 != homePos) {               goto_XY(homePos - numCols - 1);               // now check if we are in a field               isInField(lastPos);            }            else               gotoField(1);            break;         case KEYPAD_0 :            simulated = simulateKeyStroke('0');            break;         case KEYPAD_1 :            simulated = simulateKeyStroke('1');            break;         case KEYPAD_2 :            simulated = simulateKeyStroke('2');            break;         case KEYPAD_3 :            simulated = simulateKeyStroke('3');            break;         case KEYPAD_4 :            simulated = simulateKeyStroke('4');            break;         case KEYPAD_5 :            simulated = simulateKeyStroke('5');            break;         case KEYPAD_6 :            simulated = simulateKeyStroke('6');            break;         case KEYPAD_7 :            simulated = simulateKeyStroke('7');            break;         case KEYPAD_8 :            simulated = simulateKeyStroke('8');            break;         case KEYPAD_9 :            simulated = simulateKeyStroke('9');            break;         case KEYPAD_PERIOD :            simulated = simulateKeyStroke('.');            break;         case KEYPAD_COMMA :            simulated = simulateKeyStroke(',');            break;         case KEYPAD_MINUS :            if (screenFields.getCurrentField() != null &&               screenFields.withinCurrentField(lastPos)               && !screenFields.isCurrentFieldBypassField()) {               int s = screenFields.getCurrentField().getFieldShift();               if (s == 3 || s == 5 || s == 7) {                  screen[lastPos].setChar('-');                  resetDirty(lastPos);                  advancePos();                  if (fieldExit()) {                     screenFields.setCurrentFieldMDT();                     if (!screenFields.isCurrentFieldContinued()) {                        gotoFieldNext();                     }                     else {                        do {                           gotoFieldNext();                        }                        while (screenFields.isCurrentFieldContinuedMiddle() ||                              screenFields.isCurrentFieldContinuedLast());                     }                     simulated  = true;                     updateDirty();                     if (screenFields.isCurrentFieldAutoEnter())                        sendAid(AID_ENTER);                  }               }               else {                  displayError(ERR_FIELD_MINUS);               }            }            else {               displayError(ERR_CURSOR_PROTECTED);            }            break;         case FIELD_EXIT :            if (screenFields.getCurrentField() != null &&               screenFields.withinCurrentField(lastPos)               && !screenFields.isCurrentFieldBypassField()) {               setCursorOff();               resetDirty(lastPos);               if (fieldExit()) {                  screenFields.setCurrentFieldMDT();                  if (!screenFields.isCurrentFieldContinued()) {                     gotoFieldNext();                  }                  else {                     do {                        gotoFieldNext();                        if (screenFields.isCurrentFieldContinued())                           fieldExit();                     }                     while (screenFields.isCurrentFieldContinuedMiddle() ||                        screenFields.isCurrentFieldContinuedLast());                  }               }               updateDirty();               setCursorOn();               simulated  = true;               if (screenFields.isCurrentFieldAutoEnter())                  sendAid(AID_ENTER);            }            else {               displayError(ERR_CURSOR_PROTECTED);            }            break;         case FIELD_PLUS :            if (screenFields.getCurrentField() != null &&               screenFields.withinCurrentField(lastPos)               && !screenFields.isCurrentFieldBypassField()) {               setCursorOff();               resetDirty(lastPos);               if (fieldExit()) {                  screenFields.setCurrentFieldMDT();                  if (!screenFields.isCurrentFieldContinued()) {                     gotoFieldNext();                  }                  else {                     do {                        gotoFieldNext();                     }                     while (screenFields.isCurrentFieldContinuedMiddle() ||                           screenFields.isCurrentFieldContinuedLast());                  }               }               updateDirty();               setCursorOn();               simulated  = true;               if (screenFields.isCurrentFieldAutoEnter())                  sendAid(AID_ENTER);            }            else {               displayError(ERR_CURSOR_PROTECTED);            }            break;         case FIELD_MINUS :            if (screenFields.getCurrentField() != null &&               screenFields.withinCurrentField(lastPos)               && !screenFields.isCurrentFieldBypassField()) {               int s = screenFields.getCurrentField().getFieldShift();               if (s == 3 || s == 5 || s == 7) {                  setCursorOff();                  screen[lastPos].setChar('-');                  resetDirty(lastPos);                  advancePos();                  if (fieldExit()) {                     screenFields.setCurrentFieldMDT();                     if (!screenFields.isCurrentFieldContinued()) {                        gotoFieldNext();                     }                     else {                        do {                           gotoFieldNext();                        }                        while (screenFields.isCurrentFieldContinuedMiddle() ||                              screenFields.isCurrentFieldContinuedLast());                     }                  }                  updateDirty();                  setCursorOn();                  simulated  = true;                  if (screenFields.isCurrentFieldAutoEnter())                     sendAid(AID_ENTER);               }               else {                  displayError(ERR_FIELD_MINUS);               }            }            else {               displayError(ERR_CURSOR_PROTECTED);            }            break;         case BOF :            if (screenFields.getCurrentField() != null &&               screenFields.withinCurrentField(lastPos)               && !screenFields.isCurrentFieldBypassField()) {               int where = screenFields.getCurrentField().startPos();               if (where > 0) {                  goto_XY(where);               }               simulated = true;            }            else {               displayError(ERR_CURSOR_PROTECTED);            }            resetDirty(lastPos);            break;         case SYSREQ :            sessionVT.systemRequest();            simulated = true;            break;         case RESET :            restoreErrorLine();            setStatus(STATUS_ERROR_CODE,STATUS_VALUE_OFF,"");            isInField(lastPos);            simulated = true;            updateDirty();            break;         case COPY :            copyMe();            break;         case PASTE :            pasteMe(false);            break;         case ATTN :            sessionVT.sendAttentionKey();            simulated  = true;            break;         default :            System.out.println(" Mnemonic not supported " + mnem);            break;      }      return simulated;   }