Deutsch English Français Italiano |
<vdpf0d$b0pd$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: et99 <et99@rocketship1.me> Newsgroups: comp.lang.tcl Subject: Re: How do I correctly access this variable? Date: Fri, 4 Oct 2024 12:17:33 -0700 Organization: A noiseless patient Spider Lines: 38 Message-ID: <vdpf0d$b0pd$1@dont-email.me> References: <20241004033648.47f809d1@lud1.home> <1728029702-7@cmacleod.me.uk> <ygay134fdhs.fsf@akutech.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 04 Oct 2024 21:17:33 +0200 (CEST) Injection-Info: dont-email.me; posting-host="28c088774217a6f327d659d454a08502"; logging-data="361261"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/YNiJIwDaXUpYsDnDcA03k" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:tYhU7cEFqjlyyzR1r6Rmmi9CAeg= Content-Language: en-US In-Reply-To: <ygay134fdhs.fsf@akutech.de> On 10/4/2024 2:01 AM, Ralf Fassel wrote: > * Colin Macleod <user7@cmacleod.me.uk.invalid> > | Luc <luc@sep.invalid> posted: >> > | > I am stumped by this: > | > > | > array set CONTROL { > | > InitialStartUpDir "$env(HOME)" > | > } > --<snip-snip>-- > | > What am I doing wrong? >> > | Variable references do not get expanded inside braces {}. > | Try: > | array set CONTROL " > | InitialStartUpDir $env(HOME) > | " > > Or safer, in case the expanded value contains spaces: > > array set CONTROL [list InitialStartUpDir $env(HOME)] > > HTH > R' One wonders why Luc wouldn't just simply use array notation: set ::CONTROL(InitialStartUpDir) $env(HOME) [array set] with a list is useful when the list has more than one key/value pair, while with just a single pair takes about twice the time (as determined with [time]} to run. BTW I have one little nitpick with the docs on this one. It states: "Each odd-numbered element in list is treated as an element name within arrayName ..." In Tcl, list indices invariably begin at 0, and yet odd-numbered here would indicate beginning at 1, and oddity in itself :)