[thelist] cf structures

.jeff jeff at members.evolt.org
Wed May 1 19:35:01 CDT 2002


> From: Erik Mattheis
> I'm trying to figure out how to create a CF structure
> like
> animals.dogs.bessie.sex
> and store 'female' in that node.
> ... and can't find anything in the documentation or
> in a quick google search ... do you _have_ to say
> animals=StructNew()
> StructInsert(animals,'dogs',StructNew())
> StructInsert(animals.dogs,'bessie',StructNew())
> StructInsert(animals.dogs.bessie,'sex','female')

no, you can do it like this too:

  animals = StructNew();
  animals.dogs = StructNew();
  animals.dogs.bessie = StructNew();
  animals.dogs.bessie.sex = 'female';

> Maybe I don't even want a structure, but it seems like
> it would be the best thing ... I need to create a
> multi-dimentional array type deal that can be populated
> by a query, form, cookie or url or combination of any
> of those.

i'm guessing that you'll be dealing with many different types of animals,
with many different individuals for each type, and gender/sex for each one?

the one thing you'l have to be careful of is the order of the keys.  if
order isn't important to you then no worries.  however, if it is, keep in
mind that structs don't store the order you created the keys.  instead, they
store the keys in alphabetical order.  so, if order is important you'll have
to come up with a some sort of mechanism for storing the proper order of
types and individuals within types.  probably the easiest thing to do would
be to have a "keylist" property for each structure that held the keys in the
order you need/want them.

hope this helps,


jeff at members.evolt.org

More information about the thelist mailing list