[racket] Getting program options/arguments?

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Sep 16 09:59:31 EDT 2010

On Sep 16, Matthias Felleisen wrote:
> If so, to develop the program, open the language dialog in DrRacket
> (cmd L) and ask for details.  In the text box for "command line
> arguments ..." enter some strings between the parentheses, like
> this:
> 
>   #("hello" "1" "#t")
> 
> and click OK In the definitions window, enter
> 
>   #lang racket 
>   (define argv (current-command-line-arguments)) 
>   (displayln argv)
> 
> Click RUN. Look at argv, and it will print the argv vector -- just
> like in other PLs.

Quick note: since this can be inconvenient to do if you're playing
with lots of different command lines, another way to do it is to
include it in the code:

   #lang racket
   (current-command-line-arguments #("hello" "1" "#t"))
   (define argv (current-command-line-arguments)) 
   (displayln argv)

... as long as you remember to remove it when you're done.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the users mailing list.