I'm writting a swi-prolog program which reads a file name, opens it, and write some stuff.
main :- read(FileName),
tell(FileName),
write("Some stuff"),
told.
It works, but I must put the name of the file as '«name».«type»', like this:
?- main.
|: 'Hello.txt'.
true.
I need the program to receive the name this way, without the single-cuotes:
?- main.
|: Hello.
true.
And the file's type must be put by me:
$ ls
Hello.«whatever»
Any ideas? Thanks
Given that you're using SWI-Prolog, you can use the
readutil:read_line_to_codes/2library predicate:If you also need to add a file name extension to the file name you read, use the standard
atom_concat/3predicate.