1. get_key problem in DOS fullscreen
- Posted by Donald <macdon at es.co.nz> Jun 18, 2007
- 588 views
Does anyone know what the problem may be with the following? It may be my system but wondering if anyone else has had anything similar or can help. This code works fine when run in a window but if I go to fullscreen (using Alt-enter before running) it seems to hang. I have to use alt-enter which minimises the window and then close the window
integer c,i i=0 while (1) do c = get_key() if c=' ' then exit else if c!=-1 then i=i+1 end if end if end while ? {i,c}
2. Re: get_key problem in DOS fullscreen
- Posted by DB James <larches at comcast.net> Jun 18, 2007
- 541 views
Donald wrote: > > Does anyone know what the problem may be with the following? > It may be my system but wondering if anyone else has had anything similar or > can help. > > This code works fine when run in a window but if I go to fullscreen (using > Alt-enter > before running) it seems to hang. > I have to use alt-enter which minimises the window and then close the window > > }}} <eucode> > integer c,i > i=0 > > while (1) do > c = get_key() > if c=' ' then > exit > else if c!=-1 then > i=i+1 > end if > end if > end while > > ? {i,c} > </eucode> {{{ Hi Donald, I moved one of your lines and it works in either a window or fullscreen:
integer c,i i=0 while (1) do c = get_key() if c=' ' then exit else if c!=-1 then i=i+1 ? {i,c} end if end if end while
To keep the window from disappearing immediately, put something like while get_key()=-1 do end while as the last line. --Quark
3. Re: get_key problem in DOS fullscreen
- Posted by Donald <macdon at es.co.nz> Jun 18, 2007
- 582 views
DB James wrote: > > Donald wrote: > > > > Does anyone know what the problem may be with the following? > > It may be my system but wondering if anyone else has had anything similar or > > can help. > > > > This code works fine when run in a window but if I go to fullscreen (using > > Alt-enter > > before running) it seems to hang. > > I have to use alt-enter which minimises the window and then close the window > > > > Hi Donald, > > I moved one of your lines and it works in either a window or fullscreen: > > }}} <eucode> > integer c,i > i=0 > > while (1) do > c = get_key() > if c=' ' then > exit > else if c!=-1 then > i=i+1 > ? {i,c} > end if > end if > end while > </eucode> {{{ > > To keep the window from disappearing immediately, put something like > while get_key()=-1 do end while > as the last line. > > --Quark You code gives the same problem on my system!? Maybe it's to do with the NVidia GEforce6150 driver or the Dell 1707 LCD screen. I don't know why they would affect the get_key routine though. Presumably PS2 keyboard is fine? Windows XP pro should be ok? thanks anyway
4. Re: get_key problem in DOS fullscreen
- Posted by ChrisBurch2 <crylex at freeuk.co.uk> Jun 18, 2007
- 572 views
Donald wrote: > > DB James wrote: > > > > Donald wrote: > > > > > > Does anyone know what the problem may be with the following? > > > It may be my system but wondering if anyone else has had anything similar > > > or > > > can help. > > > > > > This code works fine when run in a window but if I go to fullscreen (using > > > Alt-enter > > > before running) it seems to hang. > > > I have to use alt-enter which minimises the window and then close the > > > window > > > > > > Hi Donald, > > > > I moved one of your lines and it works in either a window or fullscreen: > > > > }}} <eucode> > > integer c,i > > i=0 > > > > while (1) do > > c = get_key() > > if c=' ' then > > exit > > else if c!=-1 then > > i=i+1 > > ? {i,c} > > end if > > end if > > end while > > </eucode> {{{ > > > > To keep the window from disappearing immediately, put something like > > while get_key()=-1 do end while > > as the last line. > > > > --Quark > You code gives the same problem on my system!? > > Maybe it's to do with the NVidia GEforce6150 driver or the Dell 1707 LCD > screen. > I don't know why they would affect the get_key routine though. > Presumably PS2 keyboard is fine? Windows XP pro should be ok? > > thanks anyway Hi It initially gave similar results on mine too, (incidentally I put ? {i,c} ? 1/0 at the end, to produce the srroe, and get a readable display. But if you repeatedly press space, or wait, then the program stops. I think this has something to do with keyboard polling speeds in that very fast while loop - the loop is going to fast to read the keys - or something. Obviusly this has something to do with full screen dos mode, as opposed to windowed mode. Exactly what though is a bit of a mystery. Try slowing the loop down a bit, using ex or exc instead of exw, and running from the command line (cmd instead of command - I think these are slightly different) Chris
5. Re: get_key problem in DOS fullscreen
- Posted by Donald <macdon at es.co.nz> Jun 19, 2007
- 525 views
I think I've found the problem! It seems to work if I run it in DOSBox in fullscreen! WinXP Dos emulation must not be too good. I have found some info on the web to indicate it might be to do with the LCD screen. Oh well thanks anyway
6. Re: get_key problem in DOS fullscreen
- Posted by Greg Haberek <ghaberek at ssoe.com> Jun 19, 2007
- 524 views
Donald, What I would suggest here to slow down the loop, is to make use of the built-in tasking features of Euphoria. Here is a quick example I mocked up.
procedure check_key() while 1 do if get_key() = ' ' then -- user pressed space bar exit end if task_yield() end while -- simpler version: --while get_key() != ' ' do -- task_yield() --end while end procedure integer check_key_task -- create the task, no parameters required check_key_task = task_create( routine_id("check_key"), {} ) -- adjust timing here: -- (this would be one hald to a whole second) task_schedule( check_key_task, {0.50,1.00} ) -- loop while the task is 'active' while task_status(check_key_task) = 1 do -- do important stuff here, -- this loop will automatically exit -- when the user presses the space bar task_yield() end while
-Greg