Re: [SC] Variable name contain <var>
Posted: 18 Jul 2014 23:40
Hi,
I build up a set of "growing" variables dynamically in a loop at runtime using the dereference operator (because I use the variable names also as keys to .ini file values), something like that:note: the vars got initialized to "" in an upstream loop
Now I wonder, why this works but this doesn't I don't get it - especially because each var is eval'ed at the end of it's corresponding write access loop (last statement in 1st code block).
Is it just syntactic incompleteness or a basic logical misunderstanding on my side?
Cheers,
Filehero
PS:
I build up a set of "growing" variables dynamically in a loop at runtime using the dereference operator (because I use the variable names also as keys to .ini file values), something like that:
Code: Select all
$ALL_KEYS = "distance|duration|average_pace|total_height|trackpoints";
foreach ($key, $ALL_KEYS) {
$var = "$".$key;
// collect raw data per section
$value = getkey($key, $label, $tfo_file);
if ($value != "t.b.d.") {
*$var = eval($var) . "$value|";
}
}
*$var = trim(eval($var), "|");
Now I wonder, why this works
Code: Select all
msg("$var: " . eval($var), "1");Code: Select all
msg("$var: " . *$var, "1");Is it just syntactic incompleteness or a basic logical misunderstanding on my side?
Cheers,
Filehero
PS: