1. phantom carriage return bug
Could this be a bug with Euphoria?
If the cursor is on last line of screen, Euphoria adds a
<CR> before calling gets().
Test file follows:
---
--phantom carriage return bug
--author doug edmunds
--file date (m/d/y) 8/13/1997
include wildcard.e
constant
QUIT = 0,
KEYBOARD = 0
integer x
sequence y
--test 1
x = 1
while x != QUIT do
puts(1,"\nTest: Press <CR> over and over..Suddenly an EXTRA <CR> appears
!!!\n(press q to quit...)")
--same results using printf
y = upper(gets(KEYBOARD))
if y[1] = 'Q' then
x = QUIT
else
x = 1
end if
end while
--test 2
for z = 1 to 150 do
puts(1,"\nThis doesn't happen without the 'gets(KEYBOARD)' clause.")
end for
puts(1,"\n")
2. Re: phantom carriage return bug
Doug Edmunds writes:
> Could this be a bug with Euphoria?
> If the cursor is on last line of screen, Euphoria adds a
> <CR> before calling gets().
I've been aware of this for many years now.
Euphoria is not trying to do anything special on the last line.
It seems to be due to some funny behavior of DOS.
I know it's kind of annoying, but I don't have
any plans to "correct" this behavior.
If you need better cursor control, you can always use
position().
Regards,
Rob Craig
Rapid Deployment Software
3. Re: phantom carriage return bug
>Doug Edmunds writes:
>> Could this be a bug with Euphoria?
>> If the cursor is on last line of screen, Euphoria adds a
>> <CR> before calling gets().
What is curious here is not the skipped line when the cursor reach the
last line but
the fact that there are no skipped line anywhere on screen.
explanation:
Each time gets() is called and the user press <ENTER> to confirm the entry
the
cursor is sent to the beginning of next line. then your code use a puts() with
a '\n' character at beginning of the prompt. As the cursor is already at
the beginning of the next line this '\n' should send it on second to next
line, efectively skipping a line.
It seem that puts() doesn't recognise the gets() cursor update. it does
put string where the last puts() leave it instead.
Try the following code which first use puts() and then dos_puts() to see
the difference.
NOTE: dos function 9 (Output String to Console) doesn't see
'\n' character the same way as does puts() it doesn't do a carriage return
with the
new line.
---- code begin here ---------------
include machine.e
sequence s
puts(1,"test puts() with gets()\n")
puts(1,"\nentrez un chaine: ")
s= gets(0)
while get_key() = -1 do en while -- see the cursor on the next line
puts(1,"entrez un chaine:") -- the cursor come back where last puts() leaved it.
s=gets(0)
procedure dos_puts(sequence str)
atom buffer
sequence r
buffer = allocate_low(length(str)+1)
poke(buffer,str&'$')
r = repeat(0,10)
r[REG_AX] = #900
r[REG_DS] = floor(buffer/16)
r[REG_DX] = remainder(buffer,16)
r = dos_interrupt(#21,r)
free_low(buffer)
end procedure
puts(1,"\n\ntest dos_puts() with gets()\n")
dos_puts("entrez un chaine:")
s= gets(0)
dos_puts("entrez un chaine:")
s=gets(0)
while get_key() = -1 do end while
---- code end -------------------
To conclude, the bug is not in gets() but in puts() which doesn't see
gets() cursor
update.
Jacques Deschenes
Baie-Comeau, Quebec
Canada
desja at globetrotter.qc.ca