[Scilab-users] How to use a string variable as a childname in a structure?
Rafael Guerra
jrafaelbguerra at hotmail.com
Thu Dec 1 19:09:20 CET 2016
Hi,
Please check code:
// START OF CODE
function myvalue = getchild(myparent,mychild)
execstr("myvalue=myparent"+"."+mychild);
endfunction
s = struct('a',[1 2 3],'b', [4 5 6]);
x = getchild(s,'a'); // equivalent for x = s.a;
y = getchild(s,'b'); // equivalent for y = s.b;
// END OF CODE
Regards,
Rafael
-----Original Message-----
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of christophk
Sent: Thursday, December 01, 2016 6:26 PM
To: users at lists.scilab.org
Subject: [Scilab-users] How to use a string variable as a childname in a structure?
Hi there,
is there a way to use a string variable during a children-call in a scilab
structure?
Here is an example for what i want to do:
function myvalue = getchild(myparent,mychild)
//this function doesn't work and is just meant to show the idea of what
I want to do:
//"mychild" is a string to call for a childname of "myparent", which is a
struct. Is this at all possible?
myvalue = myparent.mychild;
endfunction
s = struct('a',[1 2 3],'b', [4 5 6]);
//how do I change my getchlidren function for this to work
x = getchild(s,'a'); // equivalent for x = s.a;
y = getchild(s,'b'); // equivalent for y = s.b;
Thanks all!
--
View this message in context: http://mailinglists.scilab.org/How-to-use-a-string-variable-as-a-childname-in-a-structure-tp4035161.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
_______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
More information about the users
mailing list