# Procedure In A Script File With The Same Name

**URL:** https://forum.highend3d.com/t/procedure-in-a-script-file-with-the-same-name/2687
**Category:** Maya
**Tags:** mel
**Created:** [November 16, 2006, 10:39am UTC](https://forum.highend3d.com/t/procedure-in-a-script-file-with-the-same-name/2687 "2006-11-16T10:39:28Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![oodini](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@oodini](https://forum.highend3d.com/u/oodini)
#### Post date: [November 16, 2006, 10:39am UTC](https://forum.highend3d.com/t/procedure-in-a-script-file-with-the-same-name/2687/1 "2006-11-16T10:39:28Z")

</div>

Hello,

If I put a procedure foo() in a script named foo.mel, what will be evaluated when I'll call foo ?

The script from its beginning, or the procedure ?

Thanks.

---

<div class="post-metadata">

### Author: ![ewerybody](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/e/bcef8e/32.png) [@ewerybody](https://forum.highend3d.com/u/ewerybody)
#### Post date: [November 16, 2006, 10:52am UTC](https://forum.highend3d.com/t/procedure-in-a-script-file-with-the-same-name/2687/2 "2006-11-16T10:52:57Z")

</div>

the name of the file is irrelevant (unless you have it in your maya\7.0\scripts folder. (then I guess the main proc in only prepared for load if the file is called like the proc (i don't really know)))

To source the complete mel-file you have to run:  
CODE  
source "foo.mel";  
CODE  
foo;  
just runs a proc or command thats called "foo";

---

<div class="post-metadata">

### Author: ![oodini](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@oodini](https://forum.highend3d.com/u/oodini)
#### Post date: [November 16, 2006, 11:05am UTC](https://forum.highend3d.com/t/procedure-in-a-script-file-with-the-same-name/2687/3 "2006-11-16T11:05:35Z")

</div>

QUOTE(ewerybody @ 11/16/06, 11:52 AM) [snapback]252571[/snapback]  
the name of the file is irrelevant (unless you have it in your maya\7.0\scripts folder. (then I guess the main proc in only prepared for load if the file is called like the proc (i don't really know)))  
Actually, it is in this script folder. 🙂

I am studying a script from Maya : scripts\others\relationshipEditor.mel  
It is about 10000 lines long.

At the very beginning, there is this piece of code :  
CODE  
if (!`selectionConnection -exists setList`)  
&nbsp;&nbsp;&nbsp;&nbsp;selectionConnection&nbsp;&nbsp;&nbsp;&nbsp;-setList setList;

if (!`scriptedPanelType -exists relationshipPanel`)   
{  
&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;Define the callbacks for the relationship panel.  
&nbsp;&nbsp;&nbsp;&nbsp;scriptedPanelType  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(...)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// some callbacks reference  
}

All the remaning code is in procedures, and among them, there is one with the same name than the script's one.

I wonder what I should trace in first : the code at the beginning, or the procedure which has the same name than the script.

---

<div class="post-metadata">

### Author: ![daniel-faust](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@daniel-faust](https://forum.highend3d.com/u/daniel-faust)
#### Post date: [November 16, 2006, 12:41pm UTC](https://forum.highend3d.com/t/procedure-in-a-script-file-with-the-same-name/2687/4 "2006-11-16T12:41:17Z")

</div>

when a procedure has the same name as the file, then maya will source the file automatically as soon as you use the procedure. It does not matter where in the file the procedure is located. Since the entire file gets loaded, every other procedure inside that file will then be available for maya to later use. If there is code in the file which is not in a procedure, then it will be executed as soon as the file gets sourced, which is just before the procedure which caused the file to become sourced gets executed.

---

<div class="post-metadata">

### Author: ![oodini](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@oodini](https://forum.highend3d.com/u/oodini)
#### Post date: [November 16, 2006, 12:57pm UTC](https://forum.highend3d.com/t/procedure-in-a-script-file-with-the-same-name/2687/5 "2006-11-16T12:57:15Z")

</div>

OK. It is now clear : initial piece of code in first, and next relationshipEditor().

Thanks a lot !

---

<div class="post-metadata">

### Author: ![daniel-faust](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@daniel-faust](https://forum.highend3d.com/u/daniel-faust)
#### Post date: [November 16, 2006, 1:20pm UTC](https://forum.highend3d.com/t/procedure-in-a-script-file-with-the-same-name/2687/6 "2006-11-16T13:20:31Z")

</div>

right, you can also put print statements in that file and restart maya, once you have figured out what happens, then you can remove them again.

Or, you can make a copy of that file, then place that copy in your Documents And Settings/user/maya.../scripts folder and modify the file. when maya starts it will use that file instead of the original one, when you delete it, it will use the original again.

---

<div class="post-metadata">

### Author: ![oodini](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@oodini](https://forum.highend3d.com/u/oodini)
#### Post date: [November 16, 2006, 1:43pm UTC](https://forum.highend3d.com/t/procedure-in-a-script-file-with-the-same-name/2687/7 "2006-11-16T13:43:36Z")

</div>

Thanks. I didn't think about the second possibility.
