I cant make this AppleScript to work!!

Discussion in 'Mac Apps and Mac App Store' started by MacMaster1000, Sep 28, 2014.

  1. MacMaster1000, Sep 28, 2014
    Last edited by a moderator: Sep 28, 2014

    MacMaster1000 macrumors newbie

    MacMaster1000

    Joined:
    Jul 24, 2014
    Location:
    Private!
    #1
    Code:
    try
    	set suCALLapp to the result of the application
            set APPn to the result of the application
    if suCALLapp is "1" then
    	display dialog "You need  to activate Superuser. Activate?" buttons {"OK"} default button 1
    	tell APPn
    		do shell script "cd /Applications/Superuser/Needed;mkfile 1b confirmFILE.conf"
    		activate
    	end tell
    
    on error the error_message number the error_number
    
    	if suCALLapp is "0" then
    	display dialog "Will you like to activate Superuser?" buttons {"Yes", "No"} default button 2
    	if the button returned of the result is "" then
    		do shell script "cd /Applications/Superuser/Needed;mkfile 1b confirmFILE.conf"
    	else
    		-- action for 2nd button goes here
    	end if
    end try
    The code above in Apple Script form is not working.
    The code is supposed to do the following (for people that don't know):
    Code:
    "try set suCALLapp to the result of the application 
    set APPn to the result of the application" is trying to get result that is called from app
    "if suCALLapp is "1" then
    	display dialog "You need  to activate Superuser. Activate?" buttons {"OK"} default button 1
    	tell APPn
    		do shell script "cd /Applications/Superuser/Needed;mkfile 1b confirmFILE.conf"
    		activate
    	end tell" checks for result by app & if true prompts for activate
    "on error the error_message number the error_number
    
    	if suCALLapp is "0" then
    	display dialog "Will you like to activate Superuser?" buttons {"Yes", "No"} default button 2
    	if the button returned of the result is "" then
    		do shell script "cd /Applications/Superuser/Needed;mkfile 1b confirmFILE.conf"
    	else
    		-- action for 2nd button goes here
    	end if
    end try" 
    
    is called when result is false (broken part :( ).
    Help!!!

    Garret Stand

    download ↓
     

    Attached Files:

  2. Intell macrumors P6

    Intell

    Joined:
    Jan 24, 2010
    Location:
    Inside
    #2
    You're missing a few end if lines. Try this:

    Code:
    try
    	set suCALLapp to the result of the application
    	set APPn to the result of the application
    	if suCALLapp is "1" then
    		display dialog "You need  to activate Superuser. Activate?" buttons {"OK"} default button 1
    		tell APPn
    			do shell script "cd /Applications/Superuser/Needed;mkfile 1b confirmFILE.conf"
    			activate
    		end tell
    	end if
    	
    on error the error_message number the error_number
    	
    	if suCALLapp is "0" then
    		display dialog "Will you like to activate Superuser?" buttons {"Yes", "No"} default button 2
    		if the button returned of the result is "" then
    			do shell script "cd /Applications/Superuser/Needed;mkfile 1b confirmFILE.conf"
    		else
    			-- action for 2nd button goes here
    		end if
    	end if
    end try
     
  3. Partron22 macrumors 68000

    Partron22

    Joined:
    Apr 13, 2011
    Location:
    Yes
    #3
    You'll get much more informative error messages if you comment out those try ...on error ... end try structures until everything is pretty much working as planned.
     

Share This Page