Home > Archive > Prolog > September 2007 > Getting from command line
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Getting from command line
|
|
| andrea 2007-09-02, 8:48 am |
| How can I get input from a command line?
I found current_prolog_flag/2 on the manual which could be fine, but
how can I tell which goal is the first??
I have main/0 but it doesn't work, and is it /usr/bin/env swipl
alright to make it executables?
| |
| Chip Eastham 2007-09-02, 8:48 am |
| On Sep 2, 8:22 am, andrea <kerny...@gmail.com> wrote:
> How can I get input from a command line?
>
> I found current_prolog_flag/2 on the manual which could be fine, but
> how can I tell which goal is the first??
>
> I have main/0 but it doesn't work, and is it /usr/bin/env swipl
> alright to make it executables?
It looks like you are using the Ubuntu
version of SWI-Prolog.
I'm not expert, but from searching the
documentation, it appears that you can
access the commandline arguments by a
user-written main/1 predicate as shown
here:
http://gollem.science.uva.nl/SWI-Pr...library/main.pl
In effect the usual array argv[] of the
commandline arguments is treated as a
list of strings parameter passed to your
main/1 predicate.
Hopefully Jan will correct any mistake
in my understanding.
regards, chip
| |
| andrea 2007-09-02, 7:13 pm |
| On 2 Set, 15:25, Chip Eastham <hardm...@gmail.com> wrote:
> On Sep 2, 8:22 am, andrea <kerny...@gmail.com> wrote:
>
>
>
>
> It looks like you are using the Ubuntu
> version of SWI-Prolog.
>
> I'm not expert, but from searching the
> documentation, it appears that you can
> access the commandline arguments by a
> user-written main/1 predicate as shown
> here:
>
> http://gollem.science.uva.nl/SWI-Pr.../pl-5.6.39/l...
>
> In effect the usual array argv[] of the
> commandline arguments is treated as a
> list of strings parameter passed to your
> main/1 predicate.
>
> Hopefully Jan will correct any mistake
> in my understanding.
>
> regards, chip
Ok great I'll try now.
No I have swi prolog compiled on a Tiger powered macbook...
| |
| andrea 2007-09-02, 7:13 pm |
| On 2 Set, 16:28, andrea <kerny...@gmail.com> wrote:
> On 2 Set, 15:25, Chip Eastham <hardm...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
> Ok great I'll try now.
> No I have swi prolog compiled on a Tiger powered macbook...
It works :)
It's not very easy because I need to write to file and consult it to
have the predicates I want, but anyway
#!/usr/bin/env swipl -q -g main -s
main([]) :-
writeln('usage ./nav.pl <stradario> <percorso>').
main([Stradario, Percorso]) :-
dist_file(D), tell(D),
write_pred(stradario,[Stradario]), write_pred(percorso,[Percorso]),
told, consult(D) ... etc etc
Thanks a lot
| |
|
|
|
|
|