Subject: Re: Building runtimes on WinNT 4

From: Jan Wielemaker <[email-masked]>
Date: Wed, 9 Aug 2000 12:41:58 +0200

On Tue, 08 Aug 2000, Lionel Ains wrote:
>
>OK, here is the command-line:
>
> "C:\Program Files\SWI-Prolog\bin\plcon" -g "load_files(['prog']), write_ln('Program
>loaded'), qsave_program('prog.exe', [goal=go, toplevel=none, stand_alone=true]), write_ln('Program
>Successfully saved')" -t halt.
>
>Here is the explaination:
>"C:\Program Files\SWI-Prolog\bin\plcon" is the name of the command-line executable version of
>SWI-Prolog. It's surrounded by double quotes because of the space in the directory name
>
>The first parameter is the goal executed by Prolog (-g option).
>The toplevel goal being "halt." (-t option), plcon will exit after executing the Prolog commands
>put inside the -g goal.
>
>Here is the detail about the goal executed by plcon, that is to say, the followin Prolog call:
>("load_files(['prog']), write_ln('Program loaded'), qsave_program('prog.exe', [goal=go, toplevel=none,
>stand_alone=true]), write_ln('Program Successfully saved')
>
>I give there a succession of Prolog predicate to execute (that's exactly the same as the user command
>inside from Prolog prompt).
>First, I load the program in memory with consult ([program_name]).
>Then, I write a "Program loaded" message.
>I call qsave_program/2 predicate to create an executable (because of the stand_alone=true
>option).
>The other options are:
>toplevel=none. I don't need a toplevel goal because I run the program by putting the main program's
>predicate in the goal= options.
>goal=go means that go/0 will be called when the resulting executable file (the saved state) is loaded.
>That is the case if your program is started with
>?- go
>Otherwise, you have to adapt the name of the main goal (the goal= option) to your personal use.
>
>After that, just print a message to check if qsave_program/2 succeeded.
>
>When reading again this email, I start to think that I'm not clear at all...

Well, it is a bit complicated.  First of all, toplevel=none isn't a
good idea.  It will make Prolog call none/0 as toplevel.  If you don't
want a toplevel use halt/0.

Generally a better idea is to do

go :-
	<do my work>
	halt.

and don't change the toplevel.  That way you can use Control-C and
break for (some) debugging.  If you don't want the user doing this,
toplevel=halt is indeed a way to prevent it.

To create executables, just do

	plcon -g go -o myprog -c prog.pl

which will create myprog(.exe on Windows).

	Regards --- Jan

P.s.	Is the problem loading your dll into the interactive plcon
	resolved.  It should not make any difference.  So if the
	problem remains, please send me the stuff needed to reproduce
	it.

P.s.s.	If you think your interface is useful for others, please
	consider providing it as a SWI-Prolog package.