i am using the open panel to get the string of a folder.
this is my current script:
-- Choose Site Folder
on set_choose_folder()
-- set the_site_folder to (choose folder) as string
set can choose directories of open panel to true
set can choose files of open panel to false
display open panel attached to window "main"
end set_choose_folder
on panel ended theObject with result withResult
-- what do i put?
end panel ended
-- End
what do i put in there to get the identical result as in simply this:
-- Choose Site Folder
on set_choose_folder()
-- set the_site_folder to (choose folder) as string
set can choose directories of open panel to true
set can choose files of open panel to false
display open panel attached to window "main"
end set_choose_folder
on panel ended theObject with result withResult
if withResult is 1 then
set the_site_folder to (path name of open panel) as POSIX file as alias
end if
end panel ended
-- End
Note: You can find the code in the Open Panel project in /Developer/Examples/AppleScript Studio/
i tried your suggestions but it ain’t working. the result needs to be a string and it needs to be a folder.
i changed the alias to string. alias does not work at all - but the string makes it work yet wrongly. more on that later.
i use this folder set for this script:
on create_credits_file()
set credits_contents to "<!-- Credits -->"
set credits_file to credits_contents & (ASCII character 10)
set credits_file to credits_file as string
set new_file_path to the_site_folder & "credits.txt"
set file_ref to (open for access file new_file_path with write permission)
set eof file_ref to 0
write credits_file to file_ref as «class utf8»
close access file_ref
end create_credits_file
originally with the simply (choose folder) action, it has set the the_site_folder as a string and has placed the file into that folder with the name credits.txt.
now on the other hand, it creates the file in the same location as the folder is. it also names the file incorrectly. it gives it the name of the selected folder + credits.txt … wrong
it needs to return the same result as if i would use this script:
do i maybe need to use the path names thing as described in the open panel project? but that would give me a list of files, not just the folder as a string would it?
I remember, you had this behavior before,
I guess it’s not the call of the handler which opens the panel,
the cause must be the clicked or whatever handler