POV-Ray : Newsgroups : povray.beta-test : Dictionary 'reassign' : Re: Dictionary 'reassign' Server Time
15 Jun 2021 08:57:37 EDT (-0400)
  Re: Dictionary 'reassign'  
From: ingo
Date: 5 Dec 2018 01:40:51
Message: <XnsA9AF4E22035EBseed7@news.povray.org>
in news:5c0750c1$1@news.povray.org clipka wrote:

> Am 04.12.2018 um 16:59 schrieb ingo:
>> Don't know the proper word for what I do, but the code below fails.
>> Should it? Can it be made not to fail?
>> 
>> #declare T = dictionary {
>>    ["Index"] : array[2]{"Base1", "Base2"},
>>    ["Base1"] : <1,2,3>,
>>    ["Base2"] : <0,1,2>
>> };
>> 
>> #declare Chain = T["Index"][0];
>> #declare Vec = T.Chain;
>> 
>> Parse Error: Cannot pass uninitialized identifier to non-optional
>> LValue. 
> 
> `T.Chain` is shorthand for `T["Chain"]`. You don't have a key "Chain"
> in your dictionary.
> 
> What you want is
> 
>     #declare Vec = T[Chain];
> 
> Notice the use of square brackets without quotes. This tells POV-Ray 
> that the key to use is the content of the variable `Chain`.

Ah, the result of T["Index"][0] is a string, so why quote it again. 
Being a bit blind sometimes.

Thanks,

ingo


Post a reply to this message

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.