Compiling that with 0.18.5b and running it, DOSBox crashes with either an error about a pagefault or "stack segment zero" (the exact message varies from version to version). It crashes for me when you enter a 2nd character.
It crashes here for me with a SIGSEGV as soon as I hit a key at the input prompt with DOSBox 0.72; it seems to be crashing inside __dpmi_int in __dpmi_yield, but I don't see any reason why it should. Could be a DOSBox bug, as I can't reproduce it elsewhere. For some reason a selector value (the error= part in a General Protection Fault) is actually the ASCII value of the character I just entered masked off in some way...
Report it as a bug (e.g. on Freenode.net in #dosbox), but if no game uses it, they may not fix it (why??). Then again, aren't there plenty of example FreeBASIC games which could be compiled for DOS with a little effort? ;-)
I know this is old but I found a solution. The program works when HDPMI32.exe is used instead of CWSDMPI.exe. Maybe someone should post this on the wiki for those emulating DOS.
Rather surprising, considering how critical the issue, that this page is the only mention of this issue I could find on the entire Internet. Kudos to rCX for the solution, I would have been dead in the water without it. But it would have been nice had he also described HOW to implement it.
After some experimentation, I concluded that all that is necessary is to load HDPMI32.EXE into memory using "HDPMI32.EXE -r" by manually typing in, or in a batch file, or in the DOSBox .conf file [autoexec} section for Input to work instead of causing the program to freeze. "HDPMI32.EXE -u" unloads it. Both of course without the double quotes. It consumes just 13 Kb of conventional memory.