comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: STRUCT_ASSIGN
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: STRUCT_ASSIGN [message #12621 is a reply to message #12620] Sat, 22 August 1998 00:00 Go to previous message
rivers is currently offline  rivers
Messages: 228
Registered: March 1991
Senior Member
In article <6rn2tk$nne$1@hammer.msfc.nasa.gov>, mallors@crazyhorse.msfc.nasa.gov (Robert S. Mallozzi) writes:

> I have a structure defined as follows:
>
> a = { f1: 0, f2: { x: 0, y: 0}}
>
> I want to initialize the substructure f2
> in a subroutine by having an instance of the f2
> structure, then copying it field-by-field to
> a.f2. STRUCT_ASSIGN seemed ideal for this,
> except one problem - it doesn't work :-)
>
> Assuming I have initialized an instance of
> f2 (called data) with some values
>
> data = {x: 10, y: 20}

The problem is that data is NOT an instance of f2, but rather another anonymous
structure, which IDL does not realize is the same as f2. If IDL did realize
this then you could simply type:
a.f2 = data

There are 2 ways to get this to work:
1) Use named structures rather than anonymous ones.
a = { f1: 0, f2: {f2, x: 0, y: 0}}
data = {f2, x: 10, y: 20}
a.f2 = data
2) Create data from a
a = { f1: 0, f2: { x: 0, y: 0}}
data = a.f2 & data.x=10 & data.y=20
a.f2 = data

____________________________________________________________
Mark Rivers (773) 702-2279 (office)
CARS (773) 702-9951 (secretary)
Univ. of Chicago (773) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars.uchicago.edu (e-mail)

or:
Argonne National Laboratory (630) 252-0422 (office)
Building 434A (630) 252-0405 (lab)
9700 South Cass Avenue (630) 252-1713 (beamline)
Argonne, IL 60439 (630) 252-0443 (FAX)
[Message index]
 
Read Message
Read Message
Previous Topic: STRUCT_ASSIGN
Next Topic: Plotting lines between two polygons

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 05:46:22 PDT 2025

Total time taken to generate the page: 1.03639 seconds