View Full Version : Mel - textScrollList
goosh 01-06-2003, 10:37 PM I'm writting a little script where I put some objects name into a textScrollList. This is all good, but the problem is that when I close the GUI and run the script again, obviously, the list comes back blank. ('cause it's re-initialazing the variables)
I was trying to get a way that I could keep the objects names that I have on the textScrollList.
(I was thinking of having a string node, which I would call then the GUI opens up, but I don't think there is such a thing)
Any ideas?
Thanks
Goosh
|
|
jschleifer
01-06-2003, 11:33 PM
Heya goosh,
you could store them in a global variable..
global string $list[0];
then when you bring the text scroll list up, do something like:
for ($item in $list)
{
textScrollList -e -add $item myTextScrollList;
}
that'd work..
cheers!
-jason
goosh
01-06-2003, 11:40 PM
Mmnn... Oookeeeeyyyy
I try not to use global variables, I don't like them.... 'We hatesss them.... no no, nice hobbits.... but they took it from usss'...
but I guess in this case I have to... since what I wanted to do was kind of the same, but with a node...
Thanks Jason, I'll try it and post the script soon...
Goosh
jschleifer
01-06-2003, 11:53 PM
ah, there is a script node that may be able to help ya out..
you could also just make a string attribute on a node..
$node = `group -empty`;
addAttr -ln "list" -dt string $node;
then set the attr:
setAttr -type "string" ($node + ".list") "bob sally jessey harry";
then to get it:
string $result = `getAttr ($node + ".list")`;
string $list[0];
tokenize ($result, $list);
then add it to the textScrollList
for ($item in $list)
{
textScrollList -e -add $item myTextScrollList;
}
??
-jason
goosh
01-06-2003, 11:56 PM
AJA!!
That's more what I was looking for... :bounce:
it's just perfect...
Thanks
Goosh
goosh
01-07-2003, 12:58 AM
Ok.. why doesn't this work then?
(this is why I hate global variables :( )
global string $cars[3] = {"n NSX", " Porsche", "n Acura"};
proc theCarTest()
{
string $car;
for ($car in $cars)
print("I have a" + $car + ".\n");
};
:annoyed:
G
jschleifer
01-07-2003, 03:10 AM
ah, it's because you're not declaring $cars as a global string array inside the procedure..
before the for loop, use the following line:
global string $cars[];
this will declare $cars as a global string array so it can be used. If you want to clear $cars so it has nothing in it, use the clear command:
clear $cars;
but you won't want to do this in the proc 'cuz you need the info in there..
global string $cars[3] = {"n NSX", " Porsche", "n Acura"};
proc theCarTest()
{
string $car;
global string $cars[];
for ($car in $cars)
print("I have a" + $car + ".\n");
};
:)
Originally posted by goosh
Ok.. why doesn't this work then?
(this is why I hate global variables :( )
global string $cars[3] = {"n NSX", " Porsche", "n Acura"};
proc theCarTest()
{
string $car;
for ($car in $cars)
print("I have a" + $car + ".\n");
};
:annoyed:
G
CGTalk Moderation
01-14-2006, 03:00 AM
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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.