[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Creating Files



        Reply to:   RE>[MacPerl] Creating Files...

Hi,
You probably want to use one of the MacPerl extensions, MacPerl'Choose which
put up a file selector.  Here's an example,
$myfile = &MacPerl'Choose(&GUSI'AF_FILE, 0, "Save to this file" , "",
&GUSI'CHOOSE_NEW + &GUSI'CHOOSE_DEFAULT,   "mydefaultname");
if ($myfile=="") {exit}      
open(WHATEVER,myfile);
while ($line = <WHATEVER>)
{
...
}

open being the key part here and choose to let the user select a new file and
exit (or do something else) if they pressed cancel.

hope this helps!
Tanya Quinn
--------------------------------------
Date: 4/3/96 6:17 PM
To: Tanya Quinn
From: Brian R. Barbash
Hello:
        I'm very new to programming in Mac Perl (or just plain old Perl for
that matter), so please bear with me.  I need to be able to create a file
and place data in it from a variable.  For example:

print ("Enter the filename to save into:\n");
$filename = <STDIN>;
chop ($filename);
die ("Error: cannot open file $filename for writing.") unless open
(Outputfile, ">$filename");
print Outputfile ("$data_to_go_into_file\n");
close (Outputfile);

Since the file does not actually exist yet, the die command is executed.
How do I create the file to write the information into?  Thanks in advance
for any help.

-Brian

---------------------------------
Brian R. Barbash
brb125@psu.edu
---------------------------------