Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 25-02-2004, 12:42 AM   #1
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Question passing a variable to a proc

I'm trying to pass a variable from one proc to another, but can't figure out the syntax. I can't seem to find the place in the docs where this would be described. Can anyone help?

Something like this.

global proc testPrint()
{
string $sendA = "Success";
string $sendB = "Failure";

printMe($sendA,$sendB);

}
global proc printMe(string $A, string $B)
{
print $A
print $B
}
Dann is offline   Reply With Quote
Old 25-02-2004, 12:37 PM   #2
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Try this

proc alanTest(string $a, string $b)
{
print ("a: "+$a+"\n");
print("b: "+$b+"\n");
}
alanTest("alan", "woods");
You have to make sure that you pass a string and that when you print it that you concatenate it properly so that it is evaluated and not printed as a literal.

Alan
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 25-02-2004, 04:35 PM   #3
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Alan,

Thanks for all the help. I'm not actually trying to print something, I was jus using that as an example. What I'm trying to do is not pass a string from opne proc to another, but pass a viriable. I'm not sure why I can't do it, as my test looks just like your to my eyes. What's the diff?
Dann is offline   Reply With Quote
Old 25-02-2004, 04:53 PM   #4
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

you can do this with any variable (A string is a TYPE of variable). so

proc intTest(int $a, int $b)
{
int $c = $a + $b;
print ("value of c is: " + $c + "\n");
}

intTest(4,5);

That should work.
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 25-02-2004, 05:06 PM   #5
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default

right, but why can't I do this...

proc intTest(int $a, int $b)
{
int $c = $a + $b;
print ("value of c is: " + $c + "\n");
}

int $c = 4;
int $d = 5;
intTest($c,$d);

That should work as well, but it doesn't. I get the message varible $a is not defined.
Dann is offline   Reply With Quote
Old 25-02-2004, 05:35 PM   #6
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

it does work, you need to make sure that the function is properly defined before you use it. So highlight the functino and then hit the small enter key on your keyboard and it should appear in the top half of the window. Then execute the other half of the script and it should work fine. I copied and pasted it straight in and it worked
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 25-02-2004, 07:01 PM   #7
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default

OK, this is pissing me off!! That DOES work, but my script still doesn't. It turns out, my script doesn't understand my variable, says it's not defined, but it sure as hell is! Can someone take a look at my script and tell me why $overscanStart thinks itself to be undefined!?!

Many thanks in advance for the kind soul who solves this for me.
-dann
Attached Files
File Type: mel filmoffset.mel (3.3 KB, 12 views)
Dann is offline   Reply With Quote
Old 26-02-2004, 11:35 AM   #8
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

right the problem is that you are not evaluating that variable to it's value. Basically the way I have fixed it is to build up a string of the command (as that is what -c is expecting)

so you have

string $com = "resetCamera("+$cameraStartOverscan+")";

then in the button put -c $com and that should work fine.

Bloody mel it's so stupid sometimes!!
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 26-02-2004, 05:53 PM   #9
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default

That is very stupid. I never would have figured that out.

Thanks for all the help Alan.
Dann is offline   Reply With Quote
Old 26-02-2004, 06:35 PM   #10
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

anytime, there's probably a better way of doing it, but that will work. What you could do is build a string of the whole button command in a similar way to what I showed you and then do that. It's the same things really though..


Alan
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.