Home Technical Talk

MEL: two strings, one line value?

polycounter lvl 11
Offline / Send Message
Toast polycounter lvl 11
Just a question on syntax for all the MEL experts here, how do you do this properly (first line is correct, i have to declare two strings to be the same value on second line)
if (`checkBox -q -v randScale` == 0) 
	$getScaleMin, $getScaleMax = 1;

Obviously second line currently fails, just don't know how to do it properly.

Replies

  • Ben Apuna
    I don't know mel but a wild stab at it would go like this:
    if (`checkBox -q -v randScale` == 0) {
        $getScaleMin = 1;
        $getScaleMax = 1;
    }
    

    EDIT:

    On second thought though if these variables are strings wouldn't the values need to be enclosed in quotes? like this:
    if (`checkBox -q -v randScale` == 0) {
        $getScaleMin = "1";
        $getScaleMax = "1";
    }
    

    Though in this case I'd guess you actually want these variables to be ints instead of strings so you'd have something like this:
    int $getScaleMin;
    int $getScaleMax;
    
     if (`checkBox -q -v randScale` == 0) {
         $getScaleMin = 1;
         $getScaleMax = 1;
     }
    

    lol, I should probably learn mel one of these days.
  • Toast
    Offline / Send Message
    Toast polycounter lvl 11
    Edit: nevermind. Thanks very much for your help that last code worked

    I had to declare blank strings before the if statement for it to work!

    Solved. :)

    I agree, I didn't understand how much you could do with MEL and improve tools before starting to learn it.
  • Ben Apuna
    Oh it worked! cool.

    Yeah,
    $getScaleMin,
    

    doesn't really work because it doesn't know what you want to do with the $getScaleMin, since you aren't declaring a new variable like this:
    int $getScaleMin;
    
    or assigning a value to it like:
    $getScaleMin = 1;
    
    or doing both at the same time (which is probably possible) like this:
    int $getScaleMin = 1;
    
    Anyway I'm glad I could help :)
  • haiddasalami
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Just as a general heads up. Its always better to set your value type in mel cause you actually have to tell MEL what you're going to return if your doing functions. Also helps the reader and you know what that value is :)
Sign In or Register to comment.