| Embedded IDE Link™ CC | ![]() |
objname2 = getmember(objname,membername)
objname2 = getmember(objname,index,membername)
objname2 = getmember(objname,membername) returns the object objname2 that represents membername, a member of the structure that objname accesses. membername must be a string and objname must represent a structure in memory. Once you create objname2, it becomes the object you use to read and write membername. Along with createobj, these are the only functions that create objects in the product.
The class of objname2 depends on the data type of membername — numeric structure members return numeric objects, enumerated members return enum objects, pointers return pointer objects, and so on:
objname2 = getmember(objname,index,membername)
Suppose you have declared a structure in your source code called testdeepstr, using code like this:
struct testdeepstr {
int x_int;
struct mystructa x_str;
struct mystructa z_str[2];
} str_recur;
Now, getmember creates objects that directly access members of str_recur:
str_recur=createobj(cc,'str_recur') STRUCTURE Object: Symbol Name : str_recur Address : [ 2147500816 0] Address Units per value : 224 AU Size : [ 1 ] Total Address Units : 224 AU Array ordering : row-major Members : 'x_int', 'x_str', 'z_str' x_str=getmember(structtest,'x_str') STRUCTURE Object: Symbol Name : x_str Address : [ 2147500824 0] Address Units per value : 72 AU Size : [ 1 ] Total Address Units : 72 AU Array ordering : row-major Members : 's_int', 'a_int', 's_double', 'a_char'
Even when the structure member is itself a structure, getmember provides access directly to the nested structure, or to members within the nested structure:
s_double=getmember(nestx_str,'s_double') NUMERIC Object Symbol Name : s_double Address : [ 2147500872 0] Wordsize : 64 bits Address Units per value : 8 AU Representation : float Binary point position : 0 Size : [ 1 ] Total address units : 8 AU Array ordering : row-major Endianness : little
Numeric object s_double is now your handle to write to or read from member s_double:
read(s_double)
ans =
-1.4938e+059
write(s_double,2)
read(s_double)
ans =
2
![]() | getinput | getoutput | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |