Prompt user for a file and read it
set fileContents to read (choose file)
Yes, just that.
Tips & Tricks & Code & Recipes & Examples
When coding your ApplesScript Studio application, sometimes it's useful to disable all the window's controls. By "controls" I mean every clickable piece, like buttons, popups, sliders and matrices.
You may want to disable them to avoid user clicks for a short time period, when some processing is occurring or when the application is not yet ready to handle these clicks. It's just a single line:
set enabled of every control of window 1 to false
To restore all the controls, just change the last word to true. I know you knew it :)
Remember: always consider the every magic keyword when you need to apply something to a group of elements.
reverse of "ABCDEF"
-- Error
characters of "ABCDEF"
-- Returns: {"A", "B", "C", "D", "E", "F"}
reverse of characters of "ABCDEF"
-- Returns: {"F", "E", "D", "C", "B", "A"}
reverse of characters of "ABCDEF" as text
tell application "Finder"
get name of folders of folder ("/Library/Desktop Pictures/" as POSIX file)
-- Returns: {"Abstract", "Black & White", "Nature", "Plants", "Solid Colors"}
end tell
tell application "Finder"
get name of folders of folder "Library:Desktop Pictures" of startup disk
-- Returns: {"Abstract", "Black & White", "Nature", "Plants", "Solid Colors"}