Choose application dialog opening when not needed in my Applescript

Discussion in 'Mac Programming' started by hary536, Nov 13, 2013.

  1. hary536, Nov 13, 2013
    Last edited by a moderator: Nov 14, 2013

    hary536 macrumors newbie

    Joined:
    Mar 30, 2012
    #1
    Hi,
    I have an applescript that seemed to work okay till OS 10.8.4. Now with OS 10.8.5 and 10.9, I am having below issue.
    What I do is,I have a subroutine where I check if the app is installed on the system or not and if it is not installed, I return back. If it is installed, I do other actions, like launching the app, etc. (Code copied below).

    However, what is happening now is, whenever I run the script and if the app is not installed, it does return from the subroutine but then before exiting from the script, it opens up the choose application dialog. It also opens up when I compile or save the file. The application is Timbuktu Pro.

    Below is the simplified code from my larger script. This simplified code has same problem.

    Does anyone have any suggestions for solution?
    Thanks a lot!
    *********************Code Below*********************
    Code:
    global tb2Exists
    set netopiaprefexists to true
    
    try
    	tell application "Finder" to get application file id "com.netopia.timbuktu.pro"
    	set tb2Exists to true
    on error
    	set tb2Exists to false
    end try
    settimbuktu()
    display dialog "Returned from timbuktu"
    
    on settimbuktu()
    	if tb2Exists is false then
    		--bringtofront()
    		display dialog ¬
    			"Seems Timbuktu Pro is not installed on this computer.
    Install Timbuktu Pro and then re-run this script to configure timbuktu preferences." with title "AutoConfigure: Timbuktu Pro not Installed" buttons {"Continue"} default button 1 with icon 2
    		return
    	end if
    try
    			if netopiaprefexists is false then
    				tell application "Timbuktu Pro.app"
    					ignoring application responses
    						activate
    						delay 3
    						quit
    					end ignoring
    				end tell
    				
    			end if
    		end try
     
  2. Mark FX, Nov 15, 2013
    Last edited: Nov 15, 2013

    Mark FX macrumors regular

    Mark FX

    Joined:
    Nov 18, 2011
    Location:
    West Sussex, UK
    #2
    I tested the code snippet below on OSX 10.9 and I'm not getting the open application dialog box you're describing.

    Code:
    global tb2Exists
    
    try
    	tell application "Finder" to get application file id "com.netopia.timbuktu.pro"
    	set tb2Exists to true
    on error
    	set tb2Exists to false
    end try
    settimbuktu()
    
    on settimbuktu()
    	if tb2Exists is equal to false then
    		display dialog "Timbuktu Pro is not installed"
    		return
    	else
    		display dialog "Timbuktu Pro is installed"
    		return
    	end if
    end settimbuktu
    
    You've not posted all of the code in the settimbuktu() method in your post, as we cant see the "end settimbuktu" statement.

    Are you sure the problem occurs in the posted segment of code, or somewhere else in the scripts code.

    Regards Mark
     
  3. Mark FX macrumors regular

    Mark FX

    Joined:
    Nov 18, 2011
    Location:
    West Sussex, UK
    #3
    After further testing I can only get the application open dialog box to appear if I try to send messages to an application that is not installed on my system.

    For example the code below displays the open application dialog box because I dont have the "Timbuktu Pro" application installed, but does so only once, then returns true on subsequent runs.

    Code:
    tell application "Timbuktu Pro" to set tb2Exists to true
    
    Which leads me to conclude that you are trying call an application that does not exist on your system, or you have typed the name of the app incorrectly.

    So I would check the spelling in your code.

    Regards Mark
     

Share This Page