I had the feeling when I saw your post last night, that the response that you received did not quite give you the answer you wanted, however, I did not have the time to respond to your question, as the answer is not just a short simple thing.
The problem is related to the handling variables, objects, and attributes. You have a variable, which and you want to run it through the "for" loop and print out the actual value that the variable contains.
It's been a while since I have read up on all this, so my terminology may not be exact, but with MEL, when you are storing data, within code that is "run-time", you need to use
attributes. It sounds like a pain, but after you learn about it and become familiar with it, you would want it no other way. I have written programs in four other programming languages, and by far, MEL is easier to use and work with than any of them.
Let's create an attribute to go along with an object . . . just like when you look in the expression editor at a selected sphere, you will see:
pSphere.translateX, pSphere.translateY, pSphere.translateZ
pSphere.rotateX, pSphere.rotateY, pSphere.rotateZ
What gives? . . Well this is how they store data with the object. As an attribute.
You can add these attributes - (goto --> modify > add attribute) - to various objects you have created in MAYA, like a sphere, a cube, a locator . . . or, you can just create a node, and add attrubutes to it.
string $iterate;
string $s;
createNode "transform" -n "thisNode"; // create a node
for ($i=1; $i<=6; $i++) {
// $s = "torpedo1", "torpedo2", etc
$s = "torpedo" + $i;
// add an attribute for each torpedo
// and set its default value to $i
addAttr -longName $s -dv $i "thisNode";
// $iterate = "thisNode.torpedo" + torpedo # as a string
$iterate = "thisNode.torpedo" + $i;
// print the value in the attribute "torpedo#"
print `getAttr $iterate`;
print "\n";
}
You can use:
int $num = `getAttr thisNode.torpedo1`;
and
setAttr thisNode.torpedo1 3;
to get and set attributes.
However . . .
I am still not yet that familiar with just adding attributes to nodes, you can add them by type . . . but why make it difficult?
There is always geometry in your scene and you normally have the geometry in the scene effected by the data, so why not just go to "modify > add attribute", then you can select the type, integer, float, etc, and even specify the range that the attribute can cover. Then all you have to do is use setAttr if you want to change its value, and getAttr if you want to retrieve it.
// get the value stored
int $num = `getAttr sphere.torpedo1`;
// set the attribute
setAttr sphere.torpedo1 3;
By the way, I ran this code in MAYA, in the script editor . . . you can do the same step by step to see it in action.
Ok, I'm getting bored, and didn't mean to write a book, but you can find examples of this and all the technical crap too in the Maya help library . . . . This sample code contains most of what you asked about though, if you study it and the Maya help manuel, you should be able to formulate your code to do whatever it is you are attempting to accomplish.
"The Sage as an Astronomer: If you still see the stars as something above you, you lack the eye of knowledge." Friedrich Nietzsche