hemant.b...@gmail.com wrote:
> Hi Les,
>
> Thanks for your reply..
>
> I see what you are doing. You are mapping command lines arguments into an associative array.
>
> Question,
> How do i get these variables into script itself? I tried below code but that does not seem to be worked out for me.
>
> array set options $::argv
> parray options ;# Printing into the standard output
> set golden $options("gold")
> set revised $options("rev")
> set exact $options("exact")
>
>
> puts "Golden: $golden\n";
> puts "Revised: $revised\n";
>
> Again.. Thanks.
> - Hemant
>
>
See Eugene's reply - he's got it. Lose the " marks.
In Tcl there is a risk of "quoting hell". You have to know
where you are to know when things are substituted and how:
http://wiki.tcl.tk/1726
Also, had you designed this to use -gold ... -rev ... -exact, it's
easier to see what is an option name and what is a value for the
option on a command line. You can always strip the dash characters
after.
>>
>>
>> array set options $::argv
>>
>>
>>
>> parray options
>>
>>
>>
>> C:\c\usenet>tclsh85 args.tcl -foo bar -fee fi
>>
>> options(-fee) = fi
>>
>> options(-foo) = bar
>>
--
Les Cargill