0

Is there a way in SWI Prolog to ask for consulted files? For example, I consulted two files with:

consult('load.pl').

consult('main.pl').

Now I need a predicate that give me all consulted files, because I want to check, if they are already loaded or not. At the moment, I'm building a gui for consulting files and I don't want that the user have to add one, if it is not necessary.

peter.cyc
  • 1,763
  • 1
  • 12
  • 19
Studiosus
  • 143
  • 1
  • 11

1 Answers1

1

The predicate you need is the built-in source_file/1, documented together with consult/1. You can also look at source_file/2 on the same page.

Note that depending on the libraries you are using in your code you will get a list of many files you did not consult directly.

Anyway, if you want to only load if not loaded yet, you should also look into ensure_loaded/1 documented on the same page.

  • `ensure_loaded/1` does not check dates in SWI - so it cannot be used to reload a file. In SICStus and YAP it can be used to this end. – false Sep 30 '14 at 10:12