STRUCT_ASSIGN [message #12622] |
Sat, 22 August 1998 00:00 |
mallors
Messages: 76 Registered: November 1997
|
Member |
|
|
Hi all,
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 statement is
STRUCT_ASSIGN, data, a.f2
This fails with the error
% STRUCT_ASSIGN: Expression must be named variable
in this context: <STRUCT Array[1]>.
because a.f2 is an <Expression>, not a "named variable".
So, must I resort to field-by-field copy? The problem
is that "a" is actually an object ("self"), which has
some member variables that are large structures.
A field-by-field copy would be tedious, as each
structure has on the order of 30 fields, or so.
I wanted to write a generic "set" method that will
initialize the object's structures with some data.
If I must do a field-by-field copy, I would then
have to have several "set" methods, each of which is
specialized for each of the different stuctures
within the object.
Regards,
-bob m.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
Robert S. Mallozzi 256-544-0887
Mail Code ES 84
Work: http://crazyhorse.msfc.nasa.gov/ Marshall Space Flight Center
Play: http://cspar.uah.edu/~mallozzir/ Huntsville, AL 35812
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
|
|
|