PDA

View Full Version : function returning string inside a command?


PereBalsach
11-08-2006, 12:23 PM
Hi guys!

I have a little question for all of you.
Here we go.

I have a fileBrowserDialog in my melscript and one of the commands of the fileBrowserDialog is -fileCommand that is returning a string.

My question is :
How can I get this string? becouse with -fc ($var = pb_browseForFolderCallback) doesn't work....

I really want to get the "pb_browseForFolderCallback" string
Any idea? :sad:

Thanks in advice!!


The pice of code :


fileBrowserDialog
-fileType "image"
-mode 4
-fileCommand $tmp = pb_browseForFolderCallback
-actionName "Save"`;

grantimus
11-08-2006, 06:31 PM
You're probably going to have to rethink your approach a bit. The fileBrowserDialog command was designed to work more like this:


//fileCommand calls a procedure and submits two variables to that procedure
//the first variable is the $filepath, and the second is the $fileType
global proc pb_browseForFolderCallback( string $filename, string $fileType ){
//whatever you want to do with the $filename or $fileType strings goes here
}

fileBrowserDialog
-fileType "image"
-mode 4
-actionName "Save"
-fileCommand "pb_browseForFolderCallback";


The way it works is fileCommand calls a procedure, that's all it does. Don't try using it to call any other commands, it won't work. It is in the procedure that fileCommand calls that you'll want to do whatever it is you plan on doing.

PereBalsach
11-08-2006, 07:05 PM
Thanks man for your reply.

The only think that I was trying to do is to get the path that fileBrowserDialog is returning.

I'm a bit confused right now....I want to write the path on a textFieldButtonGrp
The button on the textFieldButtonGrp is calling the pb_browseForFolderCallback funcion, but I don't know how to get this string....

Any idea?
Thanks in advice!

grantimus
11-08-2006, 08:04 PM
Try this:


string $window = `window`;
columnLayout;
textFieldButtonGrp -label "Path:" -text "" -buttonLabel "Browse" -bc "launchFileBrowserDialog" exampleTextFieldButtonGrp;
showWindow $window;

global proc pb_browseForFolderCallback( string $filename, string $fileType ){
textFieldButtonGrp -edit -text $filename exampleTextFieldButtonGrp;
}

global proc launchFileBrowserDialog(){
fileBrowserDialog
-fileType "image"
-mode 4
-actionName "Save"
-fileCommand "pb_browseForFolderCallback";
}

PereBalsach
11-08-2006, 08:36 PM
Thank you very much for your help man!
Now I have a better idea how it works :thumbsup:

I appreciate it :)

grantimus
11-08-2006, 08:45 PM
No problem.

CGTalk Moderation
11-08-2006, 08:45 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.