Somewhat more generic - you want to be working with the "action" of the tile. If you have a single-purpose DCL you can state it in the DCL file e.g.
action = "(setq count_var (atoi $value))";
Not necessary to use global variables for this, as long as you know what the variable name is. The "$value" is the current value of the tile, which is always a string - you need to convert (and possibly test) it if you need to work on it as another data type.
If the dialog is more general purpose, or if you want more control over the action from your code, you can call the (action_tile ...) function. This will do the same thing as above. Mind the quoted strings, using escapes ( \ ) where needed.