I'm currently testing out file creation, and have a few questions -
Right now, I've got a text field that the user can input information, and save it to a file called "test.txt" on the users desktop.
My code is:
Code: Select all
command cmdSave
open file specialFolderPath("desktop") & "/test.txt" for write
put field "fldResult" into myText
write myText to file specialFolderPath("desktop") & "/test.txt"
close file specialFolderPath("desktop") & "/test.txt"
end cmdSave
If that folder exists, save the text file in that folder. If the folder doesn't exist, create it, then save the file in that folder.
B) How can I use a variable from within my application as the file name used when saving the file?
Lets say I've got a variable "varName" that contains the string "John" - how can I use this information to save the file as "John.txt"?
C) Is it possible to create a custom file extension? This isn't something vital to my application idea, just something I am curious about.
So instead of creating a text file in a .txt format - maybe I want to save the text as a .xyz file or something like that - have it still be a text file, but appear to have a proprietary file format, if that makes sense.