The best way would probably just to use if/then like Ugilick said. As in:
%DIEROLL = 1D50
IF %DIEROLL = 1 THEN %FINALNUM := 1D6 + 4
IF %DIEROLL = 2 THEN %FINALNUM := 1D8 + 6
This is a lot of code for what you want, so you may prefer to use some different system. Or just put it in the global script. Alternatively, others may know a faster way of doing it.
To get a number between 15 and 50, do 1D35 + 15