An easy thing for anyone but me. 
Author Message
 An easy thing for anyone but me.

Hi, it's me the newbie again :)

I'm trying to feed input from the user to my program.
Example:

get_position :- write('Enter position on X axis'),nl,read(POSITION),
                      print_position(POSITION).

Since I'm really new to this, I  have no idea what's going on. When I
run get_position, I get the write output, and a prompt to enter a value.

When I enter something (anything), the program just stalls, and I have
to abort the execution.   ...Can anyone tell me what's wrong? I have no
idea if read is correct to use here, but I dont know of anything else to
use.

PS! If I call for example print_position(3), it works, so the error is
not in that function.

Fast help appreciated :)

Terje



Mon, 10 May 2004 21:23:30 GMT  
 An easy thing for anyone but me.
: When I enter something (anything), the program just stalls, and I have
: to abort the execution.   ...Can anyone tell me what's wrong? I have no
: idea if read is correct to use here, but I dont know of anything else to
: use.

Try ending your input with '.'

Remko



Mon, 10 May 2004 21:46:48 GMT  
 An easy thing for anyone but me.
Thanks alot :) Worked out well.
Quote:

> : When I enter something (anything), the program just stalls, and I have
> : to abort the execution.   ...Can anyone tell me what's wrong? I have no
> : idea if read is correct to use here, but I dont know of anything else to
> : use.

> Try ending your input with '.'

> Remko



Mon, 10 May 2004 21:55:41 GMT  
 An easy thing for anyone but me.

Quote:
> Hi, it's me the newbie again :)

> I'm trying to feed input from the user to my program.
> Example:

> get_position :- write('Enter position on X axis'),nl,read(POSITION),
>                       print_position(POSITION).

> Since I'm really new to this, I  have no idea what's going on. When I
> run get_position, I get the write output, and a prompt to enter a value.

> When I enter something (anything), the program just stalls, and I have
> to abort the execution.   ...Can anyone tell me what's wrong?

"read/1" expects you to enter a prolog term (e.g. a number)
terminated by a fullstop then the Return key.

Look to see if your version of Prolog has "read_atom/1"
or "read_string/1".  These read in an atom (or a string) rather than
a Prolog term.  This atom/string doesn't need to be terminated
by a fullstop.

But if the user types in something with a space,
such as "23 "   or " 23", then this could cause problems.
If it does, look to see if your version of Prolog
has any special built-in commands to remove unwanted characters
such as spaces.  (You probably don't have to write one yourself.)

--
Martin Sondergaard.



Tue, 11 May 2004 02:34:40 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Does anyone read these things!!

2. Does anyone recognize this VAXish thing?

3. Anyone have a good coding style example for coding up FIR FILTER?(EASY METHOD)

4. HELP, EASY EASY QUESTION

5. HELP, EASY EASY QUESTION

6. How do I love ruby? [Because it's easy to fix things!]

7. It's a terrible thing to forget the simple things.....

8. Nwe thing at Watserv1

9. Things We'd Like to See

10. Adding things to the Main Palette

 

 
Powered by phpBB® Forum Software