View unanswered posts | View active topics It is currently Thu Mar 28, 2024 10:18 pm



Reply to topic  [ 13 posts ]  Go to page Previous  1, 2
 Languages, Softwares and code 
Author Message
Rank 12
Rank 12

Joined: Sun Oct 05, 2014 11:34 am
Posts: 82
Ah okay, that makes sense. Sometimes if you only want specific features that is the way to go. Thanks for sharing your design decision.


Sun Oct 12, 2014 6:41 am
Profile
Rank 10
Rank 10
User avatar

Joined: Fri Dec 12, 2014 6:33 am
Posts: 56
I see it's possible to access functions dynamically, can the same be done with variables?
Code:
loc.test.a1 = 123;
loc.var_name = "a1";
loc.test.[loc.var_name] = 321; // just to show what I mean, it doesn't work like that


Sat Jan 10, 2015 7:34 am
Profile
Site Admin
Site Admin

Joined: Thu Feb 07, 2013 11:16 am
Posts: 1865
Yes but the syntax is somewhat different:

Code:
loc.test.a1 = 123;
loc.var_name = "a1";
*loc.test|loc.var_name = 321;

The syntax for dynamic variables is:

*prefix|var_name-postfix

So you can also do:

Code:
loc.test.a1.b = 123;
loc.var_name = "a1";
*loc.test|loc.var_name-b = 321;


You can also do it yourself like this:

Code:
loc.test.a1 = 123;
loc.var_name = "a1";

// Create string containing var name
loc.s = "loc.test.";
loc.s += loc.var_name;

*loc.s = 321;


Sat Jan 10, 2015 9:19 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 13 posts ]  Go to page Previous  1, 2

Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group.
Designed by X-Moon Productions.