POV-Ray : Newsgroups : povray.beta-test : Dictionary 'reassign' : Re: Dictionary 'reassign' Server Time
4 Jul 2025 05:23:38 EDT (-0400)
  Re: Dictionary 'reassign'  
From: jr
Date: 4 Dec 2018 17:45:00
Message: <web.5c07026fa98f76e2e43b71790@news.povray.org>
hi,

ingo <ing### [at] tagpovrayorg> wrote:
> 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.

heh, turns out there is a way (thanks to the Kenneth + clipka exchange :-))

#version 3.8;

global_settings {assumed_gamma 1}

#include "strings.inc"

#declare T = dictionary {
  ["Index"] : array[2]{"Base1", "Base2"},
  ["Base1"] : <1,2,3>,
  ["Base2"] : <0,1,2>
};

#declare Chain = T["Index"][1];
#declare Vec = Parse_String(concat("T.",Chain));

#debug concat("Vec: <",vstr(3,Vec,",",0,0),">\n")


:-)


regards, jr.


Post a reply to this message

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