views:

64

answers:

1

I'm having trouble trying to figure out how to get prolog to spit out a text file where I want it to. I'm currently doing a bunch of operations and then using

tell('output.txt')

to record the output. Now the problem is that when I do this, it creates this file in the SWI \bin\ folder. I was wondering if there's a way to make it create this file in the directory containing the actual .pl file. So even if the file was moved (and it will be), the text file gets created right where the source file is.

Long story short, is there a way to get the location of the source file once the source file has been consulted?

Many Thanks!

A: 

You can get the names of all the loaded files using source_file/1.

From the SWI-Prolog manual:

source_file(?File)

True if File is a loaded Prolog source file. File is the absolute and canonical path to the source-file.

Kaarel
Thanks! I'll just have to parse it now ^^
Bharat