1

I have two files, file1 and file2 with prolog extension, in file1 in some cases file2 is appended with new predicates, so I have to consult file2 in some specific area in file1, I did check this question question, but I want a different behavior, what I want to do is :

in file1

consult_File:-
                  consult('C:/Users/../Prolog/file2.pl').

and under specific condition, I can call consult_File, but unfortunately if I call consult_File within other codes in File1, it doesn't work, and if you call it explicitly from the command, it works. I appreciate if someone can help me.

Thanks

Community
  • 1
  • 1
Yasmin
  • 931
  • 3
  • 14
  • 35
  • `consult_File` should work. Do you know how to debug your code? – CapelliC Jan 03 '13 at 19:41
  • I did trace the code,but it didn't consult the file, Does it make difference if trace or debug ? – Yasmin Jan 03 '13 at 22:12
  • yes, but trace is ok. Can't you understand why consult_File isn't called? If you do unconditionally, with a directive (i.e. `:- consult('C:/Users/../Prolog/file2.pl').` ) it's ok? – CapelliC Jan 03 '13 at 22:20
  • I did discover the error, and I would like to share it with you, it's supposed to work fine, but I have in my file: `code` start:- read_from_file,consult_new_File. `code` and in read from file, there is a condition which checks if each character isn't equal to end of file, and once it's reached to end of file, it fails and I didn't handle else of if statement, that's why each time, it fails, the code inside read_from_file is done correctly but fails once reached to end of file, so I handle it by putting true in else of if statement Thanks, – Yasmin Jan 03 '13 at 22:28
  • 1
    By all means: Use SWI's module system instead! I cannot see a good reason why you want what you describe. If you structure your code cleanly you will benefit using SWI's `make` and cross-referencer! – false Jan 03 '13 at 22:47

0 Answers0