I want to 'print' the contents of a string variable w/i an expression so i can use a variable to define the attribute that is being assigned in an expression:
$var = $obj ".attrib" $var = sin(time*$feg)
...this, of course, just assigns a new string to $var. I want to ~print the contents of $var then and there, in situ where it stands in the expression so that it is interpretated as string of characters (namely an attrib address), not a variable.
.. for anyone who gives a flyers, you can do what i want to do by building up the expression statements as large string concatenations that you can provide as a variable to the expression command's -s flag. If you need to address only one varying obj, use the -o flag for a node base.
Still, i would love to know if/how you can dump variable contents at the location of a variable which is not situated in a context that expects to have its contents read (eg as command arguments). Or, id just love to know if this is a bent path im taking ....
ReturnValue The return value of argument. Description This statement is designed to allow execution of a command which is not known until runtime. It requires at least one argument, the first, which is the command to be executed.
Flags None
Examples
string $timeOfDay = "afternoon";
switch($timeOfDay) {
case "morning":
$shape = "circle";
break;
case "afternoon":
$shape = "sphere";
break;
case "evening":
$shape = "cone";
break;
default:
$shape = "cylinder";
}
eval $shape -r 5; // create specified shape with radius 5.
// In the example above, the eval command has 3 arguments: the MEL
// variable $shape, the flag -r, and the number 5. Alternatively,
// the user can construct one string from the arguments and pass it
// to eval as one argument. Eg:
eval ($shape+"-r 5");
Related Commands evalDeferred, evalEcho, scriptJob
Id sussed eval as a possibility before posting, but it wont provide, as it is 'designed to allow execution of a _command_ which is not known until runtime' ...which is not my situation, in anycase what command would it be? perhaps the magicCommand im after:
a command, or syntactical arrangement, that will take the alphanumeric content of a variable and 'write' that into the location where such a command was called from ....so that when the script/exprsn is being interpreted it will read the instances of such 'magicCommand $variable' (or some syntax surrounding the $variable) as if i had explicitly typed the variable's content right there ...
again ..
expression syntax: node.attribute = whatever
$varying_node = sphere -r 2; // outside of expression
// in expression editor:
$varying_node_attrib = $varying_node[0] + ".ty";
magicCommand $varying_node_attrib = whatever
....i want some method of writing the contents of $varying\_node\_attrib to the very position it occupies ...so it would read/interpret as:
nurbsSphereX.ty = whatever
....so we make a valid expression statement, in this case the most recent created sphere will have the expression1 controlling it's ty.
Thats all. Nothing fancy. Someone please put me out of my misery!
Thought i better add : eval is fine to use if your using the expression command, but thats not the issue here, i know how to provide commands with variables, as i said above my solution was to build stings to hand to the expression command's -s expression string. I just want to know if you can force a variable to write its contents to where it stands (like a print, but not to the script editor). I suspect its probably functionality that is simply not needed, but i just dont know it yet.
Sure, but its a situation where variables are situated in the context of a command's argument - and expects to have its contents read (or concatenated into a string). I want to force a variable to dump its contents when it isnt necessarily being asked for (eval does pretty much fit the bill, but its expecting a command first up ...i just want to 'evaluate' a string and continue on reading along the rest of the statement [if the string didnt contain a ;, of course] ..ark!)
Im not having problems building variables into expression statements if i do it with the expression command... say if you use eval to build your expression string:
I am more and more suspecting my question just doesnt make sense in the everyday handling of variables. Even if i do find out you can do what i want, it would probably be of little use anyway. Was just curious, tis all.