Substance Painter
In this start to finish texturing project within Substance Painter we cover all the techniques you need to texture the robot character.
# 1 03-05-2003 , 06:56 PM
Registered User
Join Date: Apr 2003
Location: lahore
Posts: 26

local and global variables ??

hi,

i have declared a string variable and create scrollListBox and named to that varible
and in -c flag named procedure "abc" of a button

now in procedure "abc"
i want to query some info from that early scrollListbox that is equals to string variable in my thougt

but maya gives error that undefined variable

is it some global or local variable declaration prob.

then how to use UI controls info in procedures..

here is my case:

// declare variables

string $a = "window";
string $b = "layout";
string $c = "scrollListBox";


// some window creation commands here that i deleted ...

textScrollList -w 100 -h 100 -append "None" -selectCommand "updateChar" $c;

button -l "Refresh" -w 55 -c "refreshChar";


showWindow;

// procedures
proc refreshChar()
{

textScrollList -e -removeAll $c;
textScrollList -e -append "None" $c;
// why maya is not recognising $c here .. how to fix this plz user added image
}


thnx in advance

lala


u can do it
# 2 03-05-2003 , 08:10 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
I think it's because the $c is outside of the scope of resolution of the procedure.

Anything outside of the {} will probably not be picked up by anything inside it. try them as a global var and see what happens.

edit:
nope you need to either put the $c declaration inside the function or pass it in as a parameter:


string $c = "alan";

proc refreshChar(string $c)
{
string $car = "scrollListBox";
textScrollList -e -removeAll $c;
textScrollList -e -append "None" $c;
}

do it as a param it's probably better

This should work now

Alan


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 3 03-05-2003 , 11:08 PM
Registered User
Join Date: Apr 2003
Location: lahore
Posts: 26

nice idea about passing it as parameter

really thnx.

i'll try this...

thnx again.

gr8


u can do it
# 4 04-05-2003 , 02:37 AM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
you're welcome, let me know if that fixes it and post again if it doesnt and we'll work on another solution user added image

ALan


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 5 08-05-2003 , 06:57 AM
mark_wilkins's Avatar
Registered User
Join Date: Jan 2003
Posts: 161
Button action procedures can't have arguments. The best you can do is make the variable global:


// declare variables

string $a = "window";
string $b = "layout";
global string $c = "scrollListBox";


// some window creation commands here that i deleted ...

textScrollList -w 100 -h 100 -append "None" -selectCommand "updateChar" $c;

button -l "Refresh" -w 55 -c "refreshChar";


showWindow;

// procedures
proc refreshChar()
{
global string $c;

textScrollList -e -removeAll $c;
textScrollList -e -append "None" $c;

}


Mark R. Wilkins
author of MEL Scripting for Maya Animators
www.melscripting.com
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads