1. Help wanted! -- Reply -- Reply

To Robert Craig and all others interested:

I found out the answer to at least one of my questions. The while statement
in the input-loop should read: while input[1] != GET_SUCCESS do ...

Now the program behaves the same under DOS as from ed.ex.
There is still the question: what is returned when you answer the
statement:
input = get(0)   with a single <ENTER>.
It looks like nothing is returned. Maybe get(0) should be replaced by a
function that also sees the enter key as invalid input. In ed.ex there is a
function, I think it is called get_num_keys or something like that, which
would be better for the above mentioned purpose.

Maybe later you will hear more from me!

Ad Rienks.

new topic     » topic index » view message » categorize

2. Help wanted! -- Reply -- Reply

Ad Rienks writes:
> There is still the question: what is returned when you answer the
> statement:
> input = get(0)   with a single <ENTER>.
> It looks like nothing is returned. Maybe get(0) should be replaced by ...

get(0) keeps reading from standard input (the keyboard) until
it has some non-"whitespace" to deal with. i.e. it ignores
blanks, tabs and the Enter key, looking for digits or other characters.
You can hit Enter as many times as you like, but get(0) won't be
satisfied until you really type something.

It sounds like you should call gets(0),
and then feed the resulting string into value().
e.g.
   input = value(gets(0))
gets(0) will read exactly one line of input. value() returns the
same error codes as get(). In this way you will see a GET_EOF error
code if the person just hits Enter, a GET_FAIL if the number is
badly formed, and a GET_SUCCESS for a valid number. [Note that the
user could also type a string like "ABCDEF", or a numeric sequence like
{1,2,3} and value() would handle that too.]


Regards,
   Rob Craig
   Rapid Deployment Software

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

Search



Quick Links

User menu

Not signed in.

Misc Menu