Hi Bill,
1. welcome to the forum!
2.
OK, I did get a "can't create that directory (17)" error message back when attempting to create my folder:
Code: Select all
global gMyFilePath1
on mouseUp
set the defaultFolder to specialFolderPath("resources")
...
In a standalone this folder is inside of the MacOS APP packed and a "normal" user does not have WRITE permissions here,
that's why you get hte above mentioned error!
if you need to store any app data on a Mac use either:
-> specialfolderpath("documents")
or maybe:
-> specialfolderpath("preferences")
Check the dictionary for more (and platform specific) specialfolderpath names.
Code: Select all
...
set the defaultFolder to specialFolderPath("resources")
put defaultFolder & "/" & "Files to Verify" into gMyFilePath1
create folder gMyFilePath1
...
Avoid setting the defaultfolder if you can have an bulletproof absolute pathname
AND ALWAYS do some errorchecking!
Yes, it's tedious, but neccessary!
Code: Select all
...
put specialFolderPath("resources") & "/Files to Verify" into gMyFilePath1
if there is not a folder gMyFilePath1 then
create folder gMyFilePath1
end if
...
Get used to put parens when concatenating object and file names to avoid surpises from the engine!
Code: Select all
...
open file (gMyFilePath1 & "/"& (item i of gTextFileNamesList)&".txt") for write
write gSelectedPortion to file (gMyFilePath1 & "/"& (item i of gTextFileNamesList)&".txt")
close file (gMyFilePath1 & "/"& (item i of gTextFileNamesList)&".txt")
...
Or save some typing by putting the filepath into a variable first
Code: Select all
...
put gMyFilePath1 & "/"& (item i of gTextFileNamesList)&".txt" into tTargetFile
open file tTargetFile for write
write gSelectedPortion to file tTargetFile
close file tTargetFile
...
If you deal with smallish (maybe max 20 MB) data, you can use the shorter URL syntax if you like
Code: Select all
...
put gSelectedPortion into URL("FILE:" & gMyFilePath1 & "/"& (item i of gTextFileNamesList)&".txt")
## Supposed the content of gSelectedPortion is TEXT, if it is binary stuff, use BINFILE
...
Best
Klaus