Adding a Field to an Anonymous Structure Array

QUESTION: I have an anonymous structure array, say, A. Each structure in the array has fields B, C, and D. I want to add a new field, E, to each of the structures in the array. How do I do that in IDL?

I tried this, but it failed. Apparently, this will work only for an individual structure variable, not for a structure array.

   myStruct = Create_Struct(A, 'E', 0) 

This can be easily done in Matlab. But I'm not sure if IDL provides straightforward method to do it or not.

ANSWER: Wayne Landsman provides this answer.

I wouldn't call this straightforward but the task can be accomplished by something like this in IDL. First, create a new structure with the new field and replicate it the proper number of times.

   myStruct = Replicate( Create_Struct(A[0], 'E', 0), N_Elements(A) )  

Then, fill the newly created structures with values from the original structure.

    Struct_Assign, A, myStruct     

Version of IDL used to prepare this article: IDL 7.0.1.

Google
 
Web Coyote's Guide to IDL Programming