Re: SWI-prolog, runtime, how-to
From: Jan Wielemaker (jan_at_ct.xs4all.nl)
Date: 04/13/04
- Next message: reader: "Re: Any Crossword puzzle example?"
- Previous message: Cesar Rabak: "Re: SWI-prolog, runtime app -- how?"
- In reply to: Will Briggs: "SWI-prolog, runtime, how-to"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 13 Apr 2004 19:15:49 GMT
In article <b2180865.0404130833.39392a4c@posting.google.com>, Will Briggs wrote:
> Sorry, I tried a different search term after posting my query (which I
> can't make this a reply to on Google groups). Here was the answer:
>
> main :-
>|> unix(argv(Argv)), % still Quintus compatibility
You can also use current_prolog_flag(argv, Argv), which is the basic
mechanism to get the argument vector. There are a few other Prolog
systems using this API.
This, like qsave_program/2, generates a saved-state. On Linux the default
is to use a little /bin/sh script. Using the option --stand_alone=true
(or stand_alone(true) for qsave_program/2) the emulator itself is added
in front of the saved-state, resulting in a single-file executable that
requires no other files at runtime (unless you explictely try to load
Prolog resources during the execution of your program of course).
For small things on systems where it is no problem to have Prolog
installed, use scripts using the #! notation. Smaller and easier!
--- Jan
>|> append(_, [--|AppArgs], Argv), !,
>|> parse(AppArgs),
>|> halt.
>|>
>|> parse(Argv) :-
>|> format('Called with argv ~w~n', [Argv]).
>
>|> % pl -o test -f none -g main -c load.pl
>|> load.pl compiled, 0.00 sec, 1,312 bytes.
>|> /staff/jan/lib/pl-3.2.8/library/quintus compiled into quintus,
>|> 0.00 sec, 9,792 bytes.
>|> % ./test hello world
>|> Called with argv [hello, world]
>|> %
>
> from http://groups.google.com/groups?q=swi-prolog+executable&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=7kv9jp%245rr%40news-rocq.inria.fr&rnum=1
- Next message: reader: "Re: Any Crossword puzzle example?"
- Previous message: Cesar Rabak: "Re: SWI-prolog, runtime app -- how?"
- In reply to: Will Briggs: "SWI-prolog, runtime, how-to"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|