1. Phix Question
- Posted by lgregg May 15, 2021
- 1040 views
I was trying out Phix on Linux and ran the following from the phix documentation
object line
puts(1, "What is your name?\n")
line = gets(0)
line = line[1..length(line)-1]
puts(1, '\n')
puts(1, line & " is a nice name.\n")
output to screen
What is your name? Larry Larry Larry is a nice name.
- the first Larry I typed
- why is gets(0) typing Larry to the screen?
- third Larry is expected
2. Re: Phix Question
- Posted by petelomax May 15, 2021
- 1058 views
I think that's one that has defeated me, maybe something to do with linux terminal modes?
I'll try and find some time to look at this, but I'm pretty swamped right now.
3. Re: Phix Question
- Posted by ChrisB (moderator) May 16, 2021
- 965 views
Hi
I remember this was a perennial pain in the rear for me when I wrote my console based database on Linux. It's something to do with the console / terminal echoing back the input. There might be a way to turn it off, but I wrote a work around, which doesn't use gets()
object line object c line = "" while 1 do c = wait_key() if c = 10 then exit end if puts(1, c) --to echo the character --printf(1, " %d\n", {c}) --uncomment to echo the character number line &= c --to append the character to line end while puts(1, line & " is a nice name! Also works with Chris.")
Cheers
Chris