ktpr
05-28-2003, 11:14 PM
I need/want to make dynamic variables. Essentially what I want is a really fast lookup table. Might as well use the program stack, right?
The eval statement has global scope. If I put the scope "{}" characters in the eval statement my dynamic variable code and its use has to be included.
The eval statement won't take a string longer than 76 characters. The code that deals with the dynamic variables is longer than 76 characters.
You can't delete normal variables.
But what about useing optionVar, which writes to the users preferences? Using something like that sounds really bad but I'll erase every variable when I'm done and I'll make a backup before I do anything. Is this acceptable? Is there a better way?
===
little example ... technically you should back up your user prefs although I delete the variable anyway...
===
string $varname = "zzz_myvar" + 9;
optionVar -sv $varname "any string I want here";
string $foo[] = `optionVar -list`;
print ("if you look at the end of this list zzz_myvar9 should be there...");
print ("\n...\n");
int $i = size( $foo ) - 5;
for (; $i < size ($foo); $i++){
print ("\n" + $foo[$i]);
}
print ("\n\ndeleting optionVar variable...\n");
optionVar -rm $varname;
string $foo[] = `optionVar -list`;
int $i = size( $foo ) - 5;
for (; $i < size ($foo); $i++){
print ("\n" + $foo[$i]);
}
print( "\n\n see?\n" );
===
The eval statement has global scope. If I put the scope "{}" characters in the eval statement my dynamic variable code and its use has to be included.
The eval statement won't take a string longer than 76 characters. The code that deals with the dynamic variables is longer than 76 characters.
You can't delete normal variables.
But what about useing optionVar, which writes to the users preferences? Using something like that sounds really bad but I'll erase every variable when I'm done and I'll make a backup before I do anything. Is this acceptable? Is there a better way?
===
little example ... technically you should back up your user prefs although I delete the variable anyway...
===
string $varname = "zzz_myvar" + 9;
optionVar -sv $varname "any string I want here";
string $foo[] = `optionVar -list`;
print ("if you look at the end of this list zzz_myvar9 should be there...");
print ("\n...\n");
int $i = size( $foo ) - 5;
for (; $i < size ($foo); $i++){
print ("\n" + $foo[$i]);
}
print ("\n\ndeleting optionVar variable...\n");
optionVar -rm $varname;
string $foo[] = `optionVar -list`;
int $i = size( $foo ) - 5;
for (; $i < size ($foo); $i++){
print ("\n" + $foo[$i]);
}
print( "\n\n see?\n" );
===
