[racket] Need help with running racket from the command-line
P.S. In your case, you'll probably just use
(current-command-line-arguments) to get the value.
If your program uses many command line arguments, you may prefer using
`command-line':
http://docs.racket-lang.org/reference/Command-Line_Parsing.html.
On Mon, Aug 20, 2012 at 8:40 AM, Greg Hendershott
<greghendershott at gmail.com> wrote:
> Racket has the idea of `parameters'. By convention, these are named
> current-xyz. Examples include current-input-port, current-output-port,
> and current-command-line-arguments.
>
> Parameters are functions you can call to set or get a value. To get
> the current value, call with no arguments. To set, call with the new
> value. (That's why you're seeing the function documented both ways.)
>
> Parameters are an alternative to using a global variable and `set!'.
> There is a `parameterize' form to make it easier to temporarily change
> the value and have it restored. Also they are per thread.
>
> Parameters are described here:
> http://docs.racket-lang.org/guide/parameterize.html
>
> On Mon, Aug 20, 2012 at 3:00 AM, Rouben Rostamian <rostamian at umbc.edu> wrote:
>> Oh, the use of (current-command-line-arguments) is a terrific
>> idea and a great improvement over what I was trying to do.
>> Thanks for pointing it out.
>>
>> This brings me to a tangentially related question.
>>
>> I am using Racket v5.1.3. Searching the manuals for
>> current-command-line-arguments leads to the following:
>>
>> | (current-command-line-arguments)
>> | -> (vectorof (and/c string? immutable?))
>> |
>> | (current-command-line-arguments argv) -> void?
>> | argv : (vectorof (and/c string? immutable?))
>> |
>> | A parameter that is initialized with command-line arguments
>> | when Racket starts (not including any command-line arguments
>> | that were treated as flags for the system).
>>
>> That's all it says. I understand the first form: it says
>> (current-command-line-arguments) returns the command-line
>> arguments in a vector. I don't understand the second form.
>> What is (current-command-line-arguments argv) supposed to do?
>>
>> -- Rouben
>>
>> On Mon, Aug 20, 2012 at 07:50:00AM +0200, Rüdiger Asche wrote:
>>>
>>> Do you need to run echo.rkt under control of racket? If you compile
>>> it as a standalone, you can use
>>>
>>> (current-command-line-arguments)
>>>
>>> within echo.rkt to access the vector or command line arguments.
>>>
>>> ----- Original Message ----- From: "Rouben Rostamian"
>>> <rostamian at umbc.edu>
>>> To: <users at racket-lang.org>
>>> Sent: Monday, August 20, 2012 12:42 AM
>>> Subject: [racket] Need help with running racket from the command-line
>>>
>>>
>>> >I am having difficulty in interpreting Racket's command-line
>>> >options described in the User Guide. Please help if you can.
>>> >
>>> >I want to do something like this:
>>> >
>>> > racket -t echo.rkt -e '(echo "hi")'
>>> >
>>> >The file echo.rkt (which is given at the end of this message)
>>> >is a module that provides a function "echo" which simply prints
>>> >its argument to the terminal.
>>> >
>>> >I expect the Unix command
>>> >
>>> > racket -t echo.rkt -e '(echo "hi")'
>>> >
>>> >to print "hi" to the terminal and exit. But it doesn't; it complains
>>> >about an unbound identifier. This is Racket v5.1.3, if it matters.
>>> >
>>> >Here is the content of the file echo.rkt:
>>> >
>>> >;; echo.rkt ------------
>>> >
>>> >#lang racket
>>> >
>>> >(provide echo)
>>> >
>>> >(define (echo x)
>>> > (display x)
>>> > (newline))
>>> >
>>> >;; end of echo.rkt -----
>>> >
>>> >
>>> >--
>>> >Rouben Rostamian
>> ____________________
>> Racket Users list:
>> http://lists.racket-lang.org/users