tbaypaul
11-03-2006, 02:49 AM
I'm having some difficulties with filehandeling....seems to be a plague of it going around...
I want to use fileBrower.mel script in SAVE mode (1) to allow the user to navigate to a directory and name a file for my procedure to write to...But I just can't capture the $filename from the fileBrowser proc.
I don't understand how to use the call back to fopen and write to the file my output..I can only get the hard coded $filename to work and not the fileBrowser....I've tried many ways....I just pasted it here for example....and to show that I had a callback procedure going...I get really close but the name is always a null string to the fopen, which fails....
proc pk_jointOutput(float $startFrame, float $endFrame, int $outputWS)
{
string $filename = ( `internalVar -userWorkspaceDir` + "exampleJO1.txt" );
//fileBrowser("fileCallback", "Save", "", 1);
int $fileHnd = `fopen $filename w`;
if($fileHnd == 0 )
{
error ("Unable to open output file " + $filename + " for writing");
return;
}
.....calculations and fprints here.....
fclose $fileHnd;
}
pk_jointOutput(1, 3, 0);
I want to use fileBrower.mel script in SAVE mode (1) to allow the user to navigate to a directory and name a file for my procedure to write to...But I just can't capture the $filename from the fileBrowser proc.
I don't understand how to use the call back to fopen and write to the file my output..I can only get the hard coded $filename to work and not the fileBrowser....I've tried many ways....I just pasted it here for example....and to show that I had a callback procedure going...I get really close but the name is always a null string to the fopen, which fails....
proc pk_jointOutput(float $startFrame, float $endFrame, int $outputWS)
{
string $filename = ( `internalVar -userWorkspaceDir` + "exampleJO1.txt" );
//fileBrowser("fileCallback", "Save", "", 1);
int $fileHnd = `fopen $filename w`;
if($fileHnd == 0 )
{
error ("Unable to open output file " + $filename + " for writing");
return;
}
.....calculations and fprints here.....
fclose $fileHnd;
}
pk_jointOutput(1, 3, 0);
