Hi guys,
In C language, you can type arguments at the command line and have your
program pick them up and use them. For example, I could write a dos2unix
program and have the name of the file to be cleaned, passed into main
via array argv.
At the command prompt I would type:
dos2unix[.exe] filename
and the file would be cleaned of carriage-returns.
The code would look something like:
int main (char *argv[])
{
FILE *fi;
fi=open(argv[[1],"r");
etc.
FORTRAN now allows this, except that you access the arguments by using
the getarg intrinsic procedure.
Perl, an interpreted language, also allows this. The arguments are in
@argv and you use shift @argv to access each one.
Can I do something similar in Common Lisp?
Thanks,
Dave
From: drewc
Subject: Re: Newbie question: Command line arguments in Common Lisp?
Date:
Message-ID: <7HYAd.621502$%k.406417@pd7tw2no>
David Buchan wrote:
> I forgot to mention that I'm using Clisp.
There is this really cool new service on teh intarweb... they call it
'google' ... rather then being a one with one hundred zeros, it is in
fact a 'search engine', which lets you find items in a vast information
store known as 'the World Wide Web'
Anyways, if one were to use this 'google' , and search for, say:
"clisp command line args"
and then read the results that come up, an amazing thing happens! The
third result is entitled :
"25.2. The Environment Dictionary [CLHS-25.2]"
And if one were to further read into this, one may notice that, at the
bottom of this page, the following section appears :
25.2.14. Function EXT:ARGV
This function will return a fresh SIMPLE-VECTOR of STRING command line
arguments passed to the runtime, including those already processed by
CLISP. Use EXT:*ARGS* instead of this function to get the arguments for
your program.
Amazing!
Now, just for future reference, this service, 'google', is freely
available at http://google.ca. It can be a great time saver!
For example, asking this question on c.l.l took (in your first post),
748 characters. Asking google took me only 24. And i got my answer right
away.
Save those chars for when you really need them.
drewc
David Buchan <·····@pdbuchan.com> writes:
> I forgot to mention that I'm using Clisp.
See:
common-lisp:*load-pathname*
ext:*args*
--
__Pascal Bourguignon__ http://www.informatimago.com/
This is a signature virus. Add me to your signature and help me to live
From: Philippe Brochard
Subject: Re: Newbie question: Command line arguments in Common Lisp?
Date:
Message-ID: <87d5wrzjdq.fsf@grigri.elcforest>
David Buchan writes:
> I forgot to mention that I'm using Clisp.
>
With Clisp you can use ext:*args*
http://clisp.cons.org/impnotes.html#script-exec
Or you can have a look here:
http://groups-beta.google.com/group/comp.lang.lisp/search?group=comp.lang.lisp&q=command+line+arguments&qt_g=1&searchnow=Search+this+group
Philippe
--
Philippe Brochard <·····@free.fr>
http://hocwp.free.fr
-=-= http://www.gnu.org/home.fr.html =-=-
From: Svein Ove Aas
Subject: Re: Newbie question: Command line arguments in Common Lisp?
Date:
Message-ID: <cr19h3$lfe$1@services.kq.no>
start quoting David Buchan :
> Can I do something similar in Common Lisp?
>
Of course you can, in an implementation-defined manner.
*Which* Lisp?