Get the value associated with a structure field
x = get_struct_field_value (Struct_Type s, String field_name)
The get_struct_field_value
function the value of the field
whose name is specified by field_name
of the structure s
.
The following example illustrates how this function may be used to to print the value of a structure.
define print_struct (s)
{
variable names, i, num;
variable name, value, dims;
names = get_struct_field_names (s);
(dims,,) = array_info (names);
num = dims[0];
for (i = 0; i < num; i++)
{
name = names[i];
value = get_struct_field_value (s, name);
vmessage ("s.%s = %s\n", name, string(value));
}
}
get_struct_field_names, _push_struct_field_values, array_info