Stream does not exist

Hey, first of all:
Sorry, i think i will have many question in the future :smiley:
This question might be so easy that i couldnt find an explanation for this:
I need a simple script, that asks users for their preferences to show the perfect car for them.

I started with this basic script, but im getting an error: “stream ‘tiguan’ does not exist”.

my code:

car(vw,'SUV',tiguan,2010,benzin).
read_car:-
   write("Which car brand do you prefer?"),nl,
   read(Carbrand),nl,
   write("Which type do you prefer?(SUV,Coupe)"),nl,
   read(Type),nl,
   write("Which fuel do you prefer?"),nl,
   read(Fuel),nl,
   car(Carbrand,Type,Output1,Output2,Fuel),nl,
   write(Output1,Output2).

And is this the best logic for my needs? Or do you guys have any better idea to this?

Stream does not exist

The reason for the error is from this line

write(Output1,Output2)

write/2 - write(+Stream, +Term)

Output1 is unified with tiguan and then passed to write/2 which expects it to be a stream.

If you use two consecutive write/1 it should work, I.e.

write(Output1),write(Output2).

I prefer to use read_string/5.

See StackOverflow answers. (search).

If you want to get more involved then you can switch to parsing input with DCGs but your example doesn’t warrant that.


See: Best practices for printing


HTH