Page 1 of 3
[SC] Variable name contain <var>
Posted: 16 May 2014 08:50
by binocular222
This is my general idea but does not works:
Code: Select all
$Count = 100;
while($Count <= 104){
perm $c$Index;
$c$Index = gettoken(get("MenuCaption", $c$Index, 1), 2, "<tab>");
Incr $Index;
}
echo $c100
How to quickly declare a lot of variables (i.e: $c100, $c101,...,$c1077)?
Re: [SC] Variable name contain <var>
Posted: 16 May 2014 11:02
by bdeshi
creates permavars $c100,$c101... with values of 100,101...
Code: Select all
$count = 100;
while($count <= 104) {
$var = '$c'.$count;
//text "variable created: $var";
//$value = gettoken(get("MenuCaption", $count, 1), 2, "<tab>");
$value = $count; //dummy values
load("perm $var = $value;",, s);
$count++;
}
Re: [SC] Variable name contain <var>
Posted: 16 May 2014 11:17
by binocular222
Genius! You should have joined this community sooner.
But XY take a significant time to process such as large demand.
Code: Select all
$count = 100;
while($count <= 250) {
$var = '$c'.$count;
$value = gettoken(get("MenuCaption", $count, 1), 2, "<tab>");
load("perm $var = $value;",, s);
$count++;
}
echo $c105
@Don: anything unusual with perm?
Re: [SC] Variable name contain <var>
Posted: 16 May 2014 12:24
by bdeshi
Thanks! I guess I should've discovered XYplorer sooner
BTW, don't know what you're doing, but you probably want to use this instead:
Code: Select all
$value = quote(gettoken(get("MenuCaption", $count, 1), 2, "<tab>"));
Re: [SC] Variable name contain <var>
Posted: 16 May 2014 13:23
by admin
OK, that was a very inspiring thread.
1) I discovered the bug that made it so slow.
2) I added a
deference operator that will make this stuff much faster.
BTW, you should quote that value:
Code: Select all
OLD: load("perm $var = $value;",, s);
NEW: load("perm $var = ""$value"";",, s);
But this is now obsolete anyway. This script should look like this in the next version:
Code: Select all
$count = 100;
while($count <= 250) {
$var = '$c'.$count;
$value = gettoken(get("MenuCaption", $count, 1), 2, "<tab>");
perm *$var = $value;
$count++;
}
echo $c105;
Re: [SC] Variable name contain <var>
Posted: 16 May 2014 15:09
by binocular222
Thanks Don, now I can build a custom menu of frequently-used-XYnative command such as
Code: Select all
"_Initialize"
if(isset($c101) == 0) {
$count = 100;
while($count <= 1077) {
$Command = '$c'.$count;
$KBshortcut = gettoken(get("MenuCaption", $count, 1), 2, "<tab>");
perm *$Command = $KBshortcut;
$count++;
}
};
"Minitree $c489|:minitree" #489
"Toggle Fav Folder $c566|:favs" #566
"Branch view $c311|:flatview" #311
"$HiddenFile|:showhidden" #493; status "Hidden files: " . get("#493", "Show", "Hide") . " | System files: " . get("#494", "Show", "Hide")
"$SystemFile|:showsystem" #494; status "Hidden files: " . get("#493", "Show", "Hide") . " | System files: " . get("#494", "Show", "Hide")
Re: [SC] Variable name contain <var>
Posted: 16 May 2014 16:20
by bdeshi
XY can construct

dynamic variables

now!!!!
Don, you are a genie with unlimited wishes!

Re: [SC] Variable name contain <var>
Posted: 16 May 2014 16:26
by admin
The line is missing:
Don't see a bug after adding the line.
Re: [SC] Variable name contain <var>
Posted: 16 May 2014 16:44
by binocular222
Yeah, sorry, I found my mistake.
But why not expand the dereference operator to normal variable, not just global/perm?
Re: [SC] Variable name contain <var>
Posted: 16 May 2014 16:49
by FluxTorpedoe
SammaySarkar wrote:XY can construct

dynamic variables

now!!!!
Don, you are a genie with unlimited wishes!

Yeahhh! This one is terrific!
And yet another old wish auto-granted… Fertile week indeed!

Re: [SC] Variable name contain <var>
Posted: 16 May 2014 16:51
by bdeshi
@binocular222, Works with normal variables too!
Re: [SC] Variable name contain <var>
Posted: 16 May 2014 16:51
by admin
Where is this cemetry of old Flux wishes? Seems to be a gold mine...

Re: [SC] Variable name contain <var>
Posted: 16 May 2014 16:52
by admin
binocular222 wrote:Yeah, sorry, I found my mistake.
But why not expand the dereference operator to normal variable, not just global/perm?
I did. Check out the change log...
Re: [SC] Variable name contain <var>
Posted: 16 May 2014 17:05
by FluxTorpedoe
admin wrote:Where is this cemetry of old Flux wishes? Seems to be a gold mine...

Well, there's lots more where that came from…

This week's were voiced via forum or PM, but I've a nice bunch waiting for you… undisclosed — to spare me a shameful

status!

Re: [SC] Variable name contain <var>
Posted: 16 May 2014 17:08
by admin
Keep them if you can. I enjoy getting ideas myself much more than being fed with the ideas of others.
