You can retrieve values from a custom dialog box while the dialog box is displayed, using the dynamic dialog boxes feature.
9.1
Sample script for a dynamic dialog box.
9.2
Make a dialog box dynamic.
More information
Dialog Editor.