From jan@swi.psy.uva.nl  Wed Jun  2 14:50:58 1999
Received: from gollem.swi.psy.uva.nl (jan@gollem.swi.psy.uva.nl [145.18.114.15])
	by swi.swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id OAA19073
	for <prolog@swi.psy.uva.nl>; Wed, 2 Jun 1999 14:50:57 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.8.8/8.8.8) id OAA19219;
	Wed, 2 Jun 1999 14:52:15 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
To: prolog@swi.psy.uva.nl, Luis Iraola Moreno <liraola@opera.dia.fi.upm.es>
Subject: Re: Embedding troubles
Date: Wed, 2 Jun 1999 14:44:10 +0200
X-Mailer: KMail [version 0.7.9]
Content-Type: text/plain
References: <Pine.SOL.3.95.990602111119.1161A-100000@opera>
MIME-Version: 1.0
Message-Id: <99060214521402.15139@gollem>
Content-Transfer-Encoding: 8bit

On Wed, 02 Jun 1999, Luis Iraola Moreno wrote:

>> How do you relate the state?  Basically, there are two options.  One is
>> to append the state to the main .exe file and the other is to pass 
>> -x <path-to-state> to PL_initialise().  Both are supposed to work.
>
>Well, up to now, I related my saved state just naming it as my main
>application. So, if my C++ app. is called "myapp.exe", I just name the
>saved state "myapp.qlf".
>
>Regarding the arguments of PL_initialise(), I just passed in the argv[0]
>the address of the string "myapp.exe".
>
>Given that this way of relating the saved state is not one of the two
>options Jan mentioned, I have first tried to change to one of the standard
>options, hoping this will solve my major problem or at lest I will learn
>something new in the way. 
>
>The -x way is the one I would prefer, but I have not succeeded in my first
>attempts. So my question is: 
>
>How should I pass the "-x path-to-state" to PL_initialise()? 
>
>I have tried first to concatenate it in argv[0], something like:
>
>argv[0]="myapp.exe -x mystate.qlf"
>
>Then I have tried to put the -x option in a second argv[]:
>
>argv[0]="myapp.exe";
>argv[1]="-x mystate.qlf";
>
>But in both cases libpl.dll (version 2.9.7) exits the app. with code 1.

Weren't you working with 3.2.7?  Anyway, as long as the state is from
the same version as the DLL, you should be fine.

Anyhow, this is what you do:

	{ char *av[5];
	  int  ac = 0;

	  av[ac++] = argv[0];   /* argv[0] is from the commandline */
				/* if not around, pass name of program */
	  av[ac++] = "-x";
	  av[ac++] = "mystate.qlf";
	  av[ac]   = NULL;

	  if ( !PL_initialise(ac, av) )
	    PL_halt(1);

	  ...

Actually, the preferred way is to append the state to the main .exe
file, in Windows using

	  copy /b main.exe+mystate.qlf myapp.exe

Or in Unix
	
	  cat main mystate > myapp
	  chmod +x myapp

Or use the plld program.

	Regards --- Jan

