searching AA

lurker lurker at lurker.com
Sun Mar 23 13:58:34 PDT 2008


ok all that worked. how do i  find for ex. "(0002,0000)" and get HASHTAG back??

thanks for any help

Frits van Bommel Wrote:

> lurker wrote:
> > hi,
> > 
> > i try to have a hash and initialize it. it doesn't work. can anybody please 
> > tell me how to initialize the below with many values such as 
> > 
> > 
> >       key                      struct values
> > "(0002,0000)"     "UL","N","Group Length",
> > "(0002,0001)"     "OB","N","File Meta Information Version",
> > 
> >                        ....
> > 
> > 
> > struct HASHTAG {
> >   //string Tag;
> >   string VR;
> >   string RET;
> >   string NAME;
> > }
> > 
> > HASHTAG[string] tags = [
> >   "(0002,0000)": {"UL","N","Group Length"},
> > ]
> > 
> > this does not work. many thanks in advance.
> 
> A variation on a common theme here: AA literals aren't constants and can 
> therefore not be used as initializers for global variables.
> Also, struct literals not directly used as initializers can't use the '{ 
> <members> }' syntax.
> 
> Try this instead:
> ---
> HASHTAG[string] tags;
> static this() {
>      tags = ["(0002,0000)": HASHTAG("UL","N","Group Length")];
> }
> ---



More information about the Digitalmars-d-learn mailing list