Subject: Re: Embedding troubles

From: Jan Wielemaker <[email-masked]>
Date: Wed, 2 Jun 1999 14:44:10 +0200

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