1. Phix Question

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
new topic     » topic index » view message » categorize

2. Re: Phix Question

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.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Phix Question

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu