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

dikyman

macrumors newbie
Original poster
May 2, 2011
1
0
my program is:

display dialog "VIRUS DETECTED" buttons {"Slow os x to handle virus", "Crash CPU"} default button 2
if the button returned of the result is "Slow os x to handle virus" then
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}
diplay dialog "Error, Please force quit" buttons {"Ok"}

else
sleep
end if

as you can see its for a fake virus. just for fun be I get the error "Expected end of line but found identifier." and it points to the highlighted above word: dialog. how can I fix this?
 
I haven't tried your script, but my guess is that the word immediately preceding the highlighted word is misspelled: "diplay" should read "display." Good luck.
 
It's been a long, long time since I did anything in Apple Script. Possibly the last time was when I pulled a similar trick on my old boss. That was back in OS 7 or something… I made the script look like his main work folder and when he double clicked on it, it threw a dialog that said something like, 'Are you sure you wish to erase the entire hard drive XXXX'? And the best part was it only had an 'OK' button!!! Oh I was such a funny fellow back then…

Anyway, aside from the typo, surely you can create some kind of loop rather than repeat the same line 50 times? Basic rule of programming is don't repeat yourself. So, yeah… don't repeat yourself.
 
If you want the dialog to loop endlessly to force a force quit just add a repeat. And I take it you want the system to sleep otherwise.

Code:
display dialog "VIRUS DETECTED" buttons {"Slow os x to handle virus", "Crash CPU"} default button 2
if the button returned of the result is "Slow os x to handle virus" then
	repeat
		display dialog "Error, Please force quit" buttons {"Ok"}
	end repeat
else
	tell application "Finder" to sleep
end if
 
I haven't tried your script, but my guess is that the word immediately preceding the highlighted word is misspelled: "diplay" should read "display." Good luck.

This is absolutely the problem. Fix that on all of those repeated lines, and it will work just as expected. The post above mine does show you an easier way to achieve the result, however.

jW
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.