PDA

View Full Version : Global /Local Proc. Clearification


th3m3nt4l
02-27-2012, 11:54 AM
right now I have created a script file.. call it script.mel for now.

right now it looks closely too:


myGui;

global proc myGui(){
makes the gui;
}

proc buttnChck(){
checks the state of elements in the gui and enables/disables certain portions of the gui
}

proc Names(){
Contains Arrays of Names and suf/prefixes to be used throgh out the script.
}
proc Positions(){
contains a matrix with default x, y ,z positions and a loop to get the positions of certain elements
}
....


The Problem I'm experiencing is that; out side of the GUI proc, if I don't declare the procedure's as global... the script breaks with the error of "cannot find procedure /Name/". Right now its ButtnChck.. but if I change it to global the next non-global proc causes the error. Any one have an idea as to the solution, besides making everything global- I'd like to avoid that for now.

In a second question: Is it possible to declare a matrix of lets say 0,0 and have its size updated- let say have 3 arrays representing x,y,z cordinates?

zeroeffect
02-27-2012, 12:46 PM
In this case you need to declare your local procs before they are called, so before the global proc. Maya does not allow you to forward reference locally scoped procedures.

http://download.autodesk.com/global/docs/maya2012/en_us/index.html?url=files/Procedures_Defining_procedures.htm,topicNumber=d28e667493

th3m3nt4l
02-27-2012, 01:02 PM
Zero- I did that as well.

Moved the Gui proc to the the last procedure declared, and every thing else it refrences to be above it:
Looks like:

myGui;

proc Names(){
}

proc Positions(){
}

proc buttnChck(){
}

global proc myGui(){
}



Still get the error of cannot find procedure ButtnChck (gets called when a texfieldButtonGrp's command is pressed).

Wood moving the call to the gui (currently at the begining of the file) to the end of the file change things?

NaughtyNathan
02-27-2012, 05:21 PM
GUI controls or callbacks cannot reference local procs. Anything on a button -command, or a slider -dragCommand or a textField -updateOnKeyPress, or tabLayout -changeTabCmd, or -dropControl, etc, etc, etc, must be a global proc.
local procs can only be called directly from the single script file they exist in, not from UI and not from any kind of deferred evaluation.

CGTalk Moderation
02-27-2012, 05:21 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.