Re: gets(0) quibble...

new topic     » goto parent     » topic index » view thread      » older message » newer message

in getPipe(), you need to use getc instead of gets.

EUPHORIA at LISTSERV.MUOHIO.EDU wrote:

> I'm still with 2.0 here, so again, it might have been fixed in 2.1...
> Try the following program:
>
> sequence File
>
> procedure getPipe() -- Get input from pipe. e.g. dir | ex thiscode.ex
>     integer c
>
>     File = {}
>     c = gets(0)
>
>     while c >= 0 do
>         File = File & c
>         c = gets(0)
>     end while
> end procedure
>
> function input(sequence prompt)
>     sequence out
>
>     puts(1, prompt)
>
>     out = gets(0)
>     return out[1..length(out)-1]
> end function
>
> sequence name
>
> getPipe()
>
> name = input("What is your name?: ") -- Crashes here!!
>
> The solution is to do this for input():
>
> function input(sequence prompt)
>     sequence out
>     integer fh
>
>     puts(1, prompt)
>
>     fh = open("CON","r") -- The keyboard CONsole
>     out = gets(0)
>     close(fh)
>     return out[1..length(out)-1]
> end function
>
> Question: Which style of input() has Rob used in prompt_string() in the
> new library files? Or does he avoid gets() altogether?
>
> --
> Carl R White -- Final Year Computer Science at the University of Bradford
> E-mail........: cyrek- at -bigfoot.com -- Remove hyphens. Ta :)
> URL...........: http://www.bigfoot.com/~cyrek/
> Uncrackable...: "19.6A.23.38.52.73.45 25.31.1C 3C.53.44.39.58"

--
Jeffrey Fielding
JJProg at cyberbury.net
http://members.tripod.com/~JJProg/

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu