Subject: Re: [SWIPL] fail to consult if I click on the file.

From: Jonathan D Johnston <[email-masked]>
Date: Fri, 28 Sep 2001 19:15:21 -0400

Hi, Armando & Jan. May I offer another diagnosis?

[Earlier e-mails reordered]
[Armando Stellato]
> Hi, I've installed SWI Prolog on Win 98SE and Win2000.
> On the first one, it automatically consults the files that I click 
> with the mouse.
> On win2000, it fails to consult saying: 'Impossible to find file
> "<PATH>\file" or one of its components, verify correctness of path 
> and availability of libraries'.

I get a very similar error message on Win98se if I try to execute a
DDE command and there is no DDE server for that command.

[Armando Stellato]
> This is the configuration associated to the pl files (for the
> operation consult):
[snip] 
> use DDE (checked)
[snip]
 
[Jan Wielemaker]
> Was the installation fine? I.e. did the installation error described
> here recently trick you?  If installation was fine, what exactly is
> registered with the filetype "Prolog Source", associated with .PL
> (or whatever you choose)?

As of SWI-Prolog 4.0.1 (couldn't say as far as the newer versions),
plwin does *not* automatically register itself as a DDE server.  In
order to use the context menu commands (consult & edit), plwin must
have been previously started & code executed to register itself as a
DDE server.  Therefore, I have the following code in my pl.ini: 

<Code>
:- dde_register_service(prolog(control, Message), do_msg(Message)).

do_msg(Msg) :- back_to_fwd(Msg,Msg1), atom_to_term(Msg1,T,_), call(T).

% Substitute a forward slash (/) for each backslash (\).
% Makes the path easier to work with within SWI-Prolog.
back_to_fwd([],[]).
back_to_fwd(Ain, Aout) :-
    sub_atom(Ain, Start, 1, Len, '\\'),
    sub_atom(Ain, 0, Start, _, Aleft),
    Rem is Start+1,
    sub_atom(Ain, Rem, Len, _, ArightIn),
    back_to_fwd(ArightIn, ArightOut),
    concat_atom([Aleft, ArightOut], '/', Aout).
back_to_fwd(A, A).
</Code>

Not the prettiest Prolog code, but it does the job.  With this in
place, it's easy to select multiple .pl files in Windows Explorer to
be used with one plwin listener.  Double-click on the first file,
which launches plwin, implicitly consults pl.ini (which registers
plwin as a DDE server), & consults the selected file (No DDE needed).
For any other .pl files, simply right-click on each & select 'consult'
from the context menu.

HTH,
Jonathan D Johnston
________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today!  For your FREE software, visit:
http://dl.www.juno.com/get/web/.