Hello,
I’m not that frequent an AppleScript scripture, so it seems every time I try something, I have to relearn!
I need to take user input to create a text file on the desktop.
set client_name to ""
set client_name to display dialog "Client Name?:" with title "Key Generator" default answer "client name"
set x to ""
repeat 48 times
set x to x & some item of "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()_-+={}?"
end repeat
set the clipboard to x
set thePath to (path to desktop as Unicode text) & string {client_name + ".txt"}
(* If there's an error, recover and continue from where the access is closed. *)
set fRef to (open for access file thePath)
try
(write) & {x}
end try
close access fRef
-- Rest of script.
(* Ditto. Here we think there may even be a problem opening the access. *)
try
set fRef to missing value
set fRef to (open for access file thePath)
-- Read/write stuff here.
end try
if (fRef is not missing value) then close access fRef -- If fRef _is_ missing value, the access wasn't opened.
-- Rest of script.
(* If there's an error, delay it just long enough to close the access. Otherwise continue. *)
set fRef to (open for access file thePath)
try
-- Read/write stuff here.
on error errMsg number errNum
close access fRef
error errMsg number errNum
end try
close access fRef
-- Rest of script.
Thanks for any advice or help you can provide!