Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm using the following snippet of code:
sub SAVE { @types = (["Text files", [qw/.txt .doc/]], ["All files", '*' ]); my $file = $mw->getSaveFile( -initialfile => $save_file, -defaultextension => '.txt', -filetypes => \@types); &exit; }
Any idea why this isn't working on windows.
I don't receive an error message, but I can't locate the file after saving it either.

???

Replies are listed 'Best First'.
Re: getSaveFile problems in Tk
by physi (Friar) on Feb 11, 2003 at 21:37 UTC
    Ok, once again, I just read the perldoc Tk::getOpenFile ;-)
    the getSaveFile only opens a fileselect dialog for you. It will not even save a file, it just returns the filename and it's full path....

    So you have to do this:

    sub save { @types = (["Text files", [qw/.txt .doc/]], ["All files", '*' ]); my $file = $mw->getSaveFile( -initialfile => $save_file, -defaultextension => '.txt', -filetypes => \@types); open OUTFILE, ">$file"; print OUTFILE "whatever you want to save in that file"; close OUTFILE; &exit; }

    Please try to name your sub's in lower letters. UPPER letters normaly used for Filehandles ..

    
    
    -----------------------------------
    --the good, the bad and the physi--
    -----------------------------------
    
Re: getSaveFile problems in Tk
by physi (Friar) on Feb 11, 2003 at 19:25 UTC
    Your sub got an exit; at the end. So there will be no return to the main process. Do you want this ?

    -----------------------------------
    --the good, the bad and the physi--
    -----------------------------------
    
      I want it to exit after saving the file