Lets say I have a file main.pl
with the following content
/* I tried these one at a time, not all at once... */
[externalFile].
['externalFile'].
['externalFile.pl'].
['./externalFile.pl']./*this was an answer to a similar SO question*/
consult(externalFile).
/*... etc ...*/
now lets use it...
$ swipl -l externalFile.pl
/* 12 second loading delay */
/* everything works perfect! */
$ swipl -l main.pl
/* 0 second loading delay */
/* let's try anything from externalFile... */
ERROR: toplevel: Undefined procedure: [...]
/* main.pl might as well be empty */
?- consult(externalFile).
/* 0 second loading delay */
true.
/* true? oh my bad! Lets try again... */
ERROR: toplevel: Undefined procedure: [...]
?- [externalFile].
/* 12 second loading delay... seems better... */
true.
/* been lied to before... */
/* and yet every thing works perfect now! */
note: consult(externalFile).
only has no effect when consult(externalFile).
is in main.pl
. Otherwise, consult(externalFile).
does succeed in importing the file while in a terminal session.
So how do I write source code without resorting to having to copy and paste my whole program into the terminal (or just have all my program source code have a file size of 15+ MEGA bytes worth of manual inclusions!) if the terminal is the only place where import commands will work?
note: I have also checked the line separator encoding (dos vs windows) (this was the answer to another question)
note: independent clauses defined directly within main.pl work fine
[]
in this context is same asconsult()
. These are directives. Directives require:-
. So, for example,:- [externalFile].
or:- consult(externalFile).
. – lurker