Batching
01-25-2011, 03:51 PM
Hello,
I am working on a script to be able to import certain scenes based on a list of names in a .txt file.
I am trying to have the script make a button for each line in the .txt file.
I got some of the code to read out the .txt file from http://www.scriptswell.net/
And got the script to make buttons with the labels of the words in the .txt file.
Now i want to add a command when the button is pushed. But because my buttons are created in a loop I don't know how to call them in my procedure. I want to know which of the buttons is pressed.
I find it hard to explain, but hope it is clear and you guys can help me with having the procedure importFile() import a file with the same name as the corresponding line in my .txt file and thus the name of the button.
Thank you very much!
Boyo
string $filePath = "D:/sceneList.txt";
string $window = `window -title "Long Name"
-iconName "Short Name"
-widthHeight 200 55`;
columnLayout -adjustableColumn true;
$fileId = `fopen $filePath "r"` ;
string $nextLine = `fgetline $fileId` ;
while (size($nextLine) > 0) {
string $cleanLine = strip($nextLine) ;
button -label $cleanLine -c "importFile()" ;
print ($cleanLine+"\n") ;
$nextLine = `fgetline $fileId` ;
}
setParent ..;
showWindow $window;
global proc importFile()
{
//here I want to have a command that will import the file with the name of the line in the .txt file.
}
I am working on a script to be able to import certain scenes based on a list of names in a .txt file.
I am trying to have the script make a button for each line in the .txt file.
I got some of the code to read out the .txt file from http://www.scriptswell.net/
And got the script to make buttons with the labels of the words in the .txt file.
Now i want to add a command when the button is pushed. But because my buttons are created in a loop I don't know how to call them in my procedure. I want to know which of the buttons is pressed.
I find it hard to explain, but hope it is clear and you guys can help me with having the procedure importFile() import a file with the same name as the corresponding line in my .txt file and thus the name of the button.
Thank you very much!
Boyo
string $filePath = "D:/sceneList.txt";
string $window = `window -title "Long Name"
-iconName "Short Name"
-widthHeight 200 55`;
columnLayout -adjustableColumn true;
$fileId = `fopen $filePath "r"` ;
string $nextLine = `fgetline $fileId` ;
while (size($nextLine) > 0) {
string $cleanLine = strip($nextLine) ;
button -label $cleanLine -c "importFile()" ;
print ($cleanLine+"\n") ;
$nextLine = `fgetline $fileId` ;
}
setParent ..;
showWindow $window;
global proc importFile()
{
//here I want to have a command that will import the file with the name of the line in the .txt file.
}
