禁用 Fn 键 Dspf Rpgle

Disable Fn Keys Dspf Rpgle

我使用 Screen Design Aid 创建了一个显示文件,其中包含一个子文件和一个 window,用于弹出并向子文件添加记录。 在window上我只是单纯的想要两个控制函数。

-回车添加记录并关闭window -F3 返回上一个子文件页面。

我遇到一个问题,每当我打开 window 并按下除那些已定义按钮之外的任何其他 Fn 键时,我的程序似乎会无限循环。

在 WRKACTJOB 中查看我的作业占用了 CPU

的负载

我想以某种方式禁用所有其他键的输入,以防止用户出现此错误并占用系统资源。

这是我的 DDS 代码

A*%%TS  SD  20210608  183039  JAL         REL-V7R3M0  5770-WDS
     A*%%EC
     A                                      DSPSIZ(27 132 *DS4)
     A          R PRTWNDW
     A*%%TS  SD  20190630  072251  JAL         REL-V7R2M0  5770-WDS
     A                                      WINDOW(6 14 8 85)
     A            PRTMSG#       80   O  4  3
     A            PRTMSG2#      80   O  5  3
     A                                  1 31'Print Message Window'
     A          R ADDWNDW
     A*%%TS  SD  20210608  183039  JAL         REL-V7R3M0  5770-WDS
     A                                      CA03(03 'Previous')
     A                                      CA02(02 'Add/Update')
     A                                      WINDOW(2 12 22 105)
     A                                  2 36'ADD COST DISTRIBUTION RECORD'
     A                                  5  4'Supplier:'
     A                                  7  4'Brand:'
     A                                  9  4'Exp A/c:'
     A                                 11  4'Sub-Total:'
     A                                 14  4'ASB:'
     A                                 15  4'Supplier:'
     A                                 13  4'Cost Split'
     A                                 17  4'Check:'
     A            CSSUPC#        6A  B  5 18
     A            CSEXCD#        3A  B  9 18
     A            CSSTTL#        9Y 2B 11 18EDTCDE(2)
     A            CSASST#        3Y 0B 14 18EDTCDE(2)
     A            CSSPST#        3Y 0B 15 18EDTCDE(2)
     A            CSCHCK#        3A  B 17 18
     A            CSSUPN#       30A  O  5 32
     A            CSBRNM#       30A  O  7 32
     A            CSEXNM#       30A  O  9 32
     A            CSCHNM#       30A  O 17 32
     A            CSBRNO#        3A  B  7 18
     A            ADDMSG#       80A  O 19  4COLOR(WHT)
     A                                 21  4'F2 = Add/Update Record'
     A                                      COLOR(WHT)
     A                                 21 31'F12 = Previous'
     A                                      COLOR(WHT)
     A          R DUMMY                     ASSUME
     A                                      OVERLAY
     A                                  1  2' '
     A          R CMTDATA                   SFL
     A*%%TS  SD  20210608  152830  JAL         REL-V7R3M0  5770-WDS
     A            ACNAME    R        O  7  4REFFLD(APVENDR/ACNAME R50FILES/VAPV-
     A                                      END)
     A            BRBRDSC   R        O  7 37REFFLD(ANPBRNDR/BRBRDSC ANPLIB/ANPB-
     A                                      RND)
     A            CMEXCD    R        O  7 69REFFLD(ANPCSTCMTR/CMEXCD ANPTEST/AN-
     A                                      PCSTCMT)
     A            CMSTTL    R        O  7 92REFFLD(ANPCSTCMTR/CMSTTL ANPTEST/AN-
     A                                      PCSTCMT)
     A            CMBCSP    R        O  7109REFFLD(ANPCSTCMTR/CMBCSP ANPTEST/AN-
     A                                      PCSTCMT)
     A            CMSCSP    R        O  7117REFFLD(ANPCSTCMTR/CMSCSP ANPTEST/AN-
     A                                      PCSTCMT)
     A          R CMTCTL                    SFLCTL(CMTDATA)
     A*%%TS  SD  20210608  175516  JAL         REL-V7R3M0  5770-WDS
     A                                      CA12(12 'Previous')
     A                                      CA02(02 'Add')
     A                                      CA06(06 'Modify')
     A                                      CA07(07 'Delete')
     A                                      CA09(09 'Print')
     A                                      OVERLAY
     A  42                                  SFLDSP
     A  41                                  SFLDSPCTL
     A  40                                  SFLCLR
     A  45                                  SFLEND(*MORE)
     A                                      SFLSIZ(0100)
     A                                      SFLPAG(0015)
     A                                  1 56'PO Cost Distribution'
     A                                  3  4'PO Number:'
     A            FLD001        11A  O  3 16
     A                                  3 37'PO Sub-total:'
     A            FLD003         9Y 2O  3 52EDTCDE(2)
     A                                  3 69'Current Sub-total:'
     A            FLD004         9Y 2O  3 89EDTCDE(2)
     A                                  5  4'Supplier'
     A                                  5 37'Brand'
     A                                  5 69'Exp A/C'
     A                                  5 92'Sub-total'
     A                                  5109'BPI'
     A                                  5117'Supplier'
     A          R CMTFOOT
     A*%%TS  SD  20210608  173541  JAL         REL-V7R3M0  5770-WDS
     A                                      KEEP
     A                                 25  3'F2 = Add Record'
     A                                      COLOR(WHT)
     A                                 25 22'F6 = Modify Record'
     A                                      COLOR(WHT)
     A                                 25 44'F7 = Delete Record'
     A                                      COLOR(WHT)
     A                                 25 66'F9 = Print Supplier Copy'
     A                                      COLOR(WHT)
     A                                 25 94'F12 = Previous'
     A                                      COLOR(WHT)

这是到目前为止的角色扮演游戏

     FANPPORCMT CF   E             WorkStn
     F                                     SFILE(CMTDATA:RRN#)
     FVAPVEND   IF A E           K Disk

     D FileInfo        DS
     D KeyPressed            369    369

     D EnterKey        C                   CONST(x'F1')
      ***
      /free

       // Internal Procedure Prototypes
       dcl-pr ClrVndSfile end-pr;
       dcl-pr LoadVndSfile end-pr;
       dcl-pr DspVndSfile end-pr;

       // Stand alone variables
       dcl-s RRN# packed(4);

       //Main Program--------------------------------//

       // Initialize
       *in40 = *off;
       *in41 = *off;
       *in42 = *off;
       *in45 = *off;

       // While F12 is not pressed display screen
       DoW *in12 = *off;

         ClrCmtSfile();
         LoadCmtSfile();
         DspCmtSfile();
         
         if *in02 = *on; 
            *in02 = *off; 
            
            exfmt addwndw; 
            
            dow *in03 = *off;
                
                if KeyPressed = EnterKey;
                    *in03 = *on; 
                    
                endif;
            
            enddo;
            
         endif; 

       EndDo;

       *Inlr = *On;

       //End Main**************************************//

       //Clear Subfile Procedure---------------//
       dcl-proc ClrCmtSfile;

         *in40 = *on;
         write cmtctl;
         *in40 = *off;
         RRN# = 0;

       end-proc;
       //*********************************************//

       //Load Subfile Procedure----------------//
       dcl-proc LoadCmtSfile;

         RRN# = RRN# + 1;
         acname = ' Supplier Testing';
         brbrdsc = 'Brand Testing';
         cmexcd = ' Expense testing';
         cmsttl = 1333330;
         cmbcsp = 50;
         cmscsp = 50;
         write cmtdata;

       end-proc;
       //*********************************************//

       //Display Subfile Procedure-------------//
       dcl-proc DspCmtSfile;

         *in41 = *on;
         *in42 = *on;
         write cmtfoot;
         exfmt cmtctl;
         *in41 = *off;
         *in42 = *off;

       end-proc;
       //*********************************************//

      /end-free

在这个循环中,如果循环开始时KeyPressed不等于EnterKey,*in03将永远保持*off。我猜你在循环中需要另一个 EXFMT。

    dow *in03 = *off;
        
        if KeyPressed = EnterKey;
            *in03 = *on; 
            
        endif;
    
    enddo;

试试这个

if *in02 = *on; //Window requested
  *in02 = *off; 
  dow *in03 = *off;
    exfmt addwndw;        //show window until enter or f3 are used
    if KeyPressed = EnterKey;
      *in03 = *on; 
    endif;
    if *in03 = *on;      //F3 used
      leave; 
    endif;
  enddo;
endif;