%M_SIGNAL

Signal a menu entry

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
status = %M_SIGNAL(entry_name, [operation], {reserved})

or

xcall M_SIGNAL(entry_name, [operation], {reserved})

status

If you pass D_SIGNAL (or if you omit operation), %M_SIGNAL returns true (1) if entry_name is non-blank or false (0) if it is blank. If you specify D_REMOVE, %M_SIGNAL returns true if an entry is returned or false if there is no menu entry to cancel. (^VAL)

entry_name

The menu entry name to signal or the returned name of the canceled menu entry. (a)

operation

(optional) One of the following: (n)

D_REMOVE

Cancel the previously signaled menu entry.

D_SIGNAL

Signal a menu entry for future processing. (default)

{reserved}

Reserved for internal use. (n)

%M_SIGNAL provides a standardized way of signaling or canceling a signaled menu entry. See Simulating a menu entry or canceling a signaled menu entry for recommendations on when to use %M_SIGNAL, and note the following:

Signaling a menu entry from a method

The following example, which is a change method, uses the “CUST_OK” menu entry to indicate whether a customer account could be found. The first call to %M_SIGNAL, which is in the read_customer subroutine, signals “CUST_OK” if it can read the account. The next call attempts to cancel the last signaled menu entry. If there’s no menu entry to cancel, the method informs the user that the record cannot be found (“Invalid customer code”). If the call is able to cancel a menu entry, the method then checks the value returned in g_entnam. If this is “CUST_OK”, the method proceeds to determine if there’s a credit hold on the account or if the account is closed. If g_entnam is set to any other value, the method informs the user that the record cannot be found and then resignals the canceled entry.

; Customer Change Method
function cust_change ,^val ,reentrant
    a_data_entered      ,a      ; A buffer containing the field data as entered by user.
    a_data_stored       ,a      ; A buffer for the final storage of the data.
    a_pending_status    ,n      ; The result of Toolkit's field validations.
.include "WND:inpinf.def"       ; Group argument of input info
.include 'INPUT_DATA' REPOSITORY , group='input'
                                ; The data_area argument passed to the calling input routine.
    ; a_method_data     ,a      ; Optional method data argument.
.include "WND:tools.def"
.include 'CUSTOMER_MASTER' REPOSITORY ,record='cusmas'
proc
    clear cusmas
    cusmas.customer = input.customer
    xcall read_customer(cusmas)
    clear g_entnam
    ;Is there a menu signal waiting to be processed?
    if (%m_signal(g_entnam, D_REMOVE)) then
        begin
        ;Is the menu signal a "customer record read OK"?
        if(g_entnam.eq.'CUST_OK') then
            begin
            using cusmas.status select
            ('CH '),
                begin ; CREDIT HOLD status
                xcall u_message("Customer on credit hold")
                a_pending_status = D_EMITTEDERR
                end
            ('C '),
                begin ; CLOSED status
                xcall u_message("Customer account has been closed")
                a_pending_status = D_EMITTEDERR
                end
            endusing
            end
        else
            begin
            xcall u_message("Invalid customer code")
            a_pending_status = D_EMITTEDERR
            ;Resignal the menu entry canceled above
            xcall m_signal(g_entnam, D_SIGNAL)
            end
        end
    else
        begin
        xcall u_message("Invalid customer code")
        a_pending_status = D_EMITTEDERR
        end
    freturn a_pending_status
endfunction
subroutine read_customer
    .include 'CUSTOMER_MASTER' REPOSITORY ,group='a_cusmas'
proc
    read(chan, a_cusmas, a_cusmas.customer, LOCK=Q_NO_LOCK) [ERR=nocust]
    ;Signal that customer record was read OK.
    xcall m_signal('CUST_OK', D_SIGNAL)
nocust,
    xreturn
endsubroutine