Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '!!! THIS IS THE MOST ELEGANT CODE !!!' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
!!! THIS IS THE MOST ELEGANT CODE !!!
Authored by: theHub on Jun 11, '10 03:00:29PM
DanCleaver (above) posted the simple (elegant) answer, but I also liked the idea of a "Cancel" button mentioned by one of the other posters. Following the general rule of Least Harmful by Default...

display dialog "¿ Show Hidden Files ?" buttons {"Yes", "No", "Cancel"} default button 3
copy the result as list to {buttonpressed}

try
	if the buttonpressed is "Cancel" then quit
	if the buttonpressed is "No" then do shell script ¬
		"defaults write com.apple.finder AppleShowAllFiles OFF"
	if the buttonpressed is "Yes" then do shell script ¬
		"defaults write com.apple.finder AppleShowAllFiles ON"
end try
do shell script "killall Finder"
Thanx DanCleaver.

[ Reply to This | # ]
!!! OF COURSE YOU COULD COMBINE !!!
Authored by: theHub on Jun 11, '10 05:41:08PM
the second if statement of the try thus...
	if the buttonpressed is "No" then
		do shell script ¬
			"defaults write com.apple.finder AppleShowAllFiles OFF"
	else
		do shell script ¬
			"defaults write com.apple.finder AppleShowAllFiles ON"
	end if


[ Reply to This | # ]