From jan@swi.psy.uva.nl  Wed Aug  9 12:55:42 2000
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id MAA12505;
	Wed, 9 Aug 2000 12:55:37 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id MAA20472;
	Wed, 9 Aug 2000 12:55:43 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: Lionel Ains <lains@caramail.com>, "Marcos Rebelo" <marcos@mind.pt>,
        prolog@swi.psy.uva.nl
Subject: Re: Building runtimes on WinNT 4
Date: Wed, 9 Aug 2000 12:41:58 +0200
X-Mailer: KMail [version 1.0.28]
Content-Type: text/plain
References: <965747370026218@caramail.com>
In-Reply-To: <965747370026218@caramail.com>
MIME-Version: 1.0
Message-Id: <00080912554307.20043@gollem>
Content-Transfer-Encoding: 8bit

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.

