A string within a string

Im working on a GUI rig for a character where the animators will constantly be using different computers. So to keep everything clean in setting up all the images to be available on the desktop. Im using:

string $localUser = `getenv userName` ;

to get the username. But now I want to plug it into another string:

string $img = `image -i "C:/Users/"+$localUser+"/Desktop/Monster_1.6/MonsterBG.jpg"`;

however this does not work. How can you embed the output of the first string into the second?

thanks in advance.

Figured it out! By removing string and just declaring the variable like this:

string $firstString = `codePartA.B`;
$variable = ("codePartA"+$firstString+"codePartB")

and it works great!

1st: leave mel :stuck_out_tongue:
2nd: wrap it up in parentheses :slight_smile:

I’ve slowly started working in python. Still haven’t gotten the hang of it. But I do know I’m running out of tools with mel. What process did you go through to learn python LoneWolf?

or function call style:

string $img = image( “-i”, “C:/Users/”+$localUser+"/Desktop/Monster_1.6/MonsterBG.jpg");

In programming, function call syntax is simpler than command call

Could you go a little more in-depth on that lemmon? How it works, why?

Thanks.

It’s rule.

the `` operator is special syntax like the command-line.

ex)
$ret = commandName -opt value;

when value is string expression, need ()

$ret = commandName -opt ($a + $b + "xxx");

command-line style syntax is strange.
Cannot nest `` operator.
There is not necessarily the space at the end of arguments.

All mel commands can call using function style syntax.

$ret = commandName( “opt”, $a + $b + “xxx” );

it’s simple.