1

在这个程序中,如果您选择项目代码,它将显示 3 个字段并要求更新,如果您更新它将更新记录。直到这个程序很好。

我添加了一个条件,如果用户按下Ctrl+D它要求删除问题是或否,是的,你更新的字段应该是空白的,否则什么都不做,它尝试了一些东西,但我不能这样做。

/*Sample Item master Maintenance Program*/                                      
/* DISPLAY TITLE */   
{us/mf/mfdtitle.i "3+ "}
def var l_qad like pt__qad13.
def var l_draw like pt_draw.
def var l_group like pt_group.
def var ans as logical no-undo. 
form
    pt_part colon 25
    with frame a side-labels width 80.
/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

form
   "Enter the Value of" l_qad colon 30 skip(1)
   "Enter the Value of" l_draw   colon 30 skip(1)
   "Enter the Value of" l_group  colon 30 skip(1)
    with frame b side-labels width 80.
setFrameLabels(frame b:handle).
view frame a.                                                                   
repeat with frame a:                                                            
      prompt-for pt_part                                                           
       editing:                                                                  
      /* FIND NEXT/PREVIOUS RECORD */                                     
        {us/mf/mfnp.i pt_mstr pt_part "pt_mstr.pt_domain = global_domain and pt_part" pt_part pt_part pt_part }                            
        if recno <> ? then                                                        
             do:                                                                   
              display pt_part.  
          end.
        end.
        for first pt_mstr exclusive-lock where pt_domain = global_domain and pt_part = input pt_part:
        assign l_qad= pt__qad13
              l_draw= pt_draw
            l_group= pt_group.
        disp l_qad l_draw l_group with frame b.
        update l_qad l_draw l_group with frame b.
            assign pt__qad13 = input l_qad
                   pt_draw = input l_draw
                   pt_group = input l_group.

        end.
        hide frame b.
        on CTRL-D ANYWHERE
        do:
        message "Please confirm delete" view-as alert-box question buttons yes-no update ans as logical.
        if ans= true then 
            message "yes".
            assign pt__qad13 = ""
                   pt_draw = ""
                   pt_group = "".

        else
            message "no".
        end.    
end.
4

1 回答 1

1

您的触发器需要放在代码的前面。

查看这个基本示例,您可以尝试注释/取消注释这两个触发器以查看会发生什么:

DEFINE VARIABLE cUpdate AS CHARACTER   NO-UNDO.

/* Placing the trigger here works! */
ON 'ctrl-d':U ANYWHERE DO:
    MESSAGE "You rang sir?" VIEW-AS ALERT-BOX INFORMATION TITLE "Early trigger".
    RETURN.
END.


UPDATE cUpdate.

/* Placing the trigger here wont work! */
/*
ON 'ctrl-d':U ANYWHERE DO:
    MESSAGE "You rang sir?" VIEW-AS ALERT-BOX INFORMATION TITLE "Late trigger".    
    RETURN.
END.
*/

Progress 只在编译时通过代码一次。因此,它永远不会知道您现在所在位置的任何“前方”(FUNCTIONS 声明为 FORWARD 是一个例外)。

于 2016-05-20T10:57:04.520 回答