# DLGSETRETURN (W*S)

Dialog Subroutine: Sets the return value for the DLGMODAL function from within a callback subroutine.

## Module

USE IFLOGM

CALL DLGSETRETURN (dlg,retval)

dlg | (Input) Derived type `dialog`. Contains dialog box parameters. The components of the type `dialog` are defined with the PRIVATE attribute, and cannot be changed or individually accessed by the user.
retval | (Input) Integer. Specifies the return value for DLGMODAL upon exiting.

DLGSETRETURN overrides the default return value with retval. You can set your own value as a means of determining the condition under which the dialog box was closed. The default return value for an error condition is -1, so you should not use -1 as your return value.

DLGSETRETURN should be called from within a callback routine, and is generally used with DLGEXIT, which causes the dialog box to be exited from a control callback rather than the user selecting the OK or Cancel button.

## Example

    SUBROUTINE SETRETSUB (dlg, button_id, callbacktype)
    USE IFLOGM
    INCLUDE "MYDLG.FD"
    TYPE (DIALOG) dlg
    LOGICAL     is_checked, retlog
    INTEGER     return, button_id, callbacktype
    ...
    retlog = DLGGET(dlg, IDC_CHECKBOX4, is_checked, dlg_state)
    IF (is_checked) THEN
       return = 999
    ELSE
       return = -999
    END IF
    CALL DLGSETRETURN (dlg, return)
    CALL DLGEXIT (dlg)
    END SUBROUTINE SETRETSUB

Parent topic: Dialog Library Routines

## See Also

DLGEXIT
DLGMODAL