Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Yeroc8

macrumors newbie
Original poster
Mar 4, 2015
1
0
When I run my code, the list pops up and I make a selection, but nothing happens.

My code:
Code:
set showOrHide to choose from list {"Show system files", "Hide system files"} with prompt "Please make your selection" without multiple selections allowed and empty selection allowed
	return the result as string
	if showOrHide is false then
		error number -128
	else if showOrHide contains "Show system files" then
		set userChose to "Show system files" as text
	else if showOrHide contains "Hide system files" then
		set userChose to "Hide system files" as text
	end if
	if userChose is "Show system files" then
		do shell script "defaults write com.apple.finder AppleShowAllFiles YES"
	else if userChose is "Hide system files" then
		do shell script "defaults write com.apple.finder AppleShowAllFiles NO"
	end if
 

HexMonkey

Administrator emeritus
Feb 5, 2004
2,240
504
New Zealand
You need to remove the "return" statement on the second line. Calls to return in that context will immediately end the script (with the return value as the result).
 

Bruno09

macrumors 68020
Aug 24, 2013
2,202
153
Far from here
Hi,

what is your goal ? Show/Hide hidden files ?

Code:
set retour to (return & return)
set theTexte to ("Hidden files" & retour)

display dialog theTexte buttons {"Reveal", "Hide", "Cancel"} default button 3 with icon 2

set resultat to button returned of the result

if (resultat = "Reveal") then
	do shell script "defaults write com.apple.finder AppleShowAllFiles 1
killall Finder"
	
else if (resultat = "Hide") then
	do shell script "defaults write com.apple.finder AppleShowAllFiles 0
killall Finder"
	
else
	quit
end if
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.