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


Click here to return to the 'Whoops, OnOff becoming inOff!' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Whoops, OnOff becoming inOff!
Authored by: ageless on Feb 10, '05 05:09:12AM

The variable name changes from OnOff on line 1 to inOff on line 2, because of the macoshints software, e.g. geeklog -- or so it would appear! For some reason it leaves the first line alone, but on the second line it changes OnOff to inOff -- try it for yourself, just preview your post but don't submit it. -- it works 'unprotected' and also when wrapped in \[code\]\[/code\] tags -- heh, just found another way to break the software, try previewing \[code\]\[/code\] with less backslashes to protect the brackets -- when I did it looked like this:

Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 7447497 bytes) in /home/virtual/site40/fst/var/www/html/lib-common.php on line 2746

Here is a corrected version of the above, using stateOfShowAllFiles instead of OnOff, thus making it macoshints compatible! What an upgrade! Oh, and I made a number of other changes as well, enjoy!

To be fair to geeklog this might be an older version of the software and of course it may be a known bug that is being/will be fixed -- anyone want to to track that down?

The code below works perfectly on my G4 running 10.3.7.

(*
Toggle AppleShowAllFiles
http://www.macosxhints.com/article.php?story=20030409015020645
*)
set shellScriptToDo to ""
set firstRun to ""
try
	set stateOfShowAllFiles to do shell script "defaults read com.apple.finder AppleShowAllFiles"
on error
	display dialog "Looks like the variable 'AppleShowAllFiles' doesn't have a value yet, so you are probably running this AppleScript for the first time.*

Are you sure you want to set AppleShowAllFiles to ON?

_________________________________________________

* If this is not the first run, consider this message an error!" buttons {"Cancel", "OK"} default button 2
	set buttonPressed to the result
	if buttonPressed is "Cancel" then
		set firstRun to "CANCEL"
	else
		set shellScriptToDo to "defaults write com.apple.finder AppleShowAllFiles ON"
	end if
end try
if firstRun is not equal to "CANCEL" then
	if shellScriptToDo = "" then
		if stateOfShowAllFiles = "ON" then
			set shellScriptToDo to "defaults write com.apple.finder AppleShowAllFiles OFF"
		else
			set shellScriptToDo to "defaults write com.apple.finder AppleShowAllFiles ON"
		end if
	end if
	try
		tell application "Finder" to quit
	on error
		error "Unable to quit Finder. You may want to force quitting it (cmd-option-esc) to have the change take effect."
	end try
	try
		do shell script shellScriptToDo
	on error
		error "Shell script '" & shellScriptToDo & "' failed!"
	end try
	delay 0.25
	try
		tell application "Finder" to activate
	on error
		delay 0.1
		tell application "Finder" to activate
	end try
end if


[ Reply to This | # ]