Page 1 of 1

Defaults When Writing Files

Posted: Wed Oct 12, 2016 5:08 pm
by smith8867
I have this piece of code:

Code: Select all

ask file "Please choose where you want to save the file..."
   if the result is not "Cancel" then
      put it into fileLocation
   end if
   put outputData into url("file:" &fileLocation)
Is there a way I can change the defaults that are shown here:
Image

Thanks!

Re: Defaults When Writing Files

Posted: Wed Oct 12, 2016 5:43 pm
by AndyP
Try this from the dictionary as an example.
ask file "Please choose where you want to save the file..." with filter "JPEG file,*.jpg"

Re: Defaults When Writing Files

Posted: Fri Oct 14, 2016 10:01 am
by MaxV
Please note, that the follwing codes have different results (note the ";"):

Code: Select all

ask file "Export picture as:" with filter "Image file, *.jpg; *.gif"

Code: Select all

ask file "Export picture as:" with filter "Jpeg image, *.jpg, Gif image,*.gif"

Re: Defaults When Writing Files

Posted: Fri Oct 14, 2016 12:45 pm
by Klaus
Hi Mr. Smith,

the question is do your users know what kind of file your app will output?
I mean do they know what filetype/suffix to use?

If not then this is "moot", since you will write the file in the neccessary format and with the correct suffix.
Know what I mean? Does not make sense if the user selects e.g "JPEG" but your app will just write a TXT file.


Best

Klaus

Re: Defaults When Writing Files

Posted: Mon Oct 17, 2016 12:24 am
by smith8867
The program will always output a text file, at least that is the idea.

Re: Defaults When Writing Files

Posted: Mon Oct 17, 2016 1:26 pm
by Klaus
smith8867 wrote:The program will always output a text file, at least that is the idea.
In that case it does not make sense at all to let the user select a filetype, right?
Just ask for a filename and then output your TXT file, you can even omit the suffix, if you like!