Re: phantom carriage return bug
- Posted by Jacques Deschenes <desja at GLOBETROTTER.QC.CA> Aug 14, 1997
- 618 views
>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