Applescript Error in Xcode

Discussion in 'Mac Programming' started by willfurnell, Mar 3, 2012.

  1. willfurnell, Mar 3, 2012
    Last edited: Mar 3, 2012

    macrumors member

    willfurnell

    Joined:
    Feb 24, 2011
    #1
    Hello there!

    I am having a slight problem with Applescript and my simple test Connect to an AFP Server application. It is very basic at the moment, but I hope to expand on it.

    Whenever I try and input text into one of my textboxes, I get this error:

    Code:
    2012-03-03 16:32:38.391 Test[7460:707] *** -[WFAppDelegate buttonConnect:]: Finder got an error: «class RApw» doesn’t understand the stringValue message. (error -1708)
    I don't have a clue how to solve this.

    This error does not appear when I remove the following line from the code below:

    Code:
    set passWordValue to passWord's stringValue()
    Code:
    --
    --  WFAppDelegate.applescript
    --  Test
    --
    --  Created by Will Furnell on 02/03/2012.
    --  Copyright (c) 2012 Will Furnell Virtual. All rights reserved.
    --
    
    script WFAppDelegate
    	property parent : class "NSObject"
    	
    	on applicationWillFinishLaunching_(aNotification)
    		-- Insert code here to initialize your application before any files are opened 
    	end applicationWillFinishLaunching_
    
        
        property serverID : missing value
        property network_share1 : missing value
        property userName : missing value
        property passWord : missing value
            
        
        on buttonConnect_(sender)
            
    
            
            tell application "Finder"
                
                
                set serverIDValue to serverID's stringValue() 
                set userNameValue to userName's stringValue() 
                set passWordValue to passWord's stringValue()
                
                try
                    set network_share1 to "afp://" & userNameValue & ":" & passWordValue & "@" & serverIDValue & "/Shared"
                    if not (exists network_share1) then
                        mount volume network_share1
                        else
                        eject network_share1
                        mount volume network_share1
                    end if
                    on error
                    display dialog "Could not conect to the server you specified. Did you enter your correct credentials? If in doubt, contact your system administrator." buttons "OK" default button "OK"
                end try
            end tell
                
            
        end buttonConnect_
        
        
    	on applicationShouldTerminate_(sender)
    		-- Insert code here to do any housekeeping before your application quits 
    		return current application's NSTerminateNow
    	end applicationShouldTerminate_
    
    end script
    Thanks in advance :)
     
  2. macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #2
    The term password is reserved, so you will either need to choose another name or enclose the variable name in pipes.
     
  3. thread starter macrumors member

    willfurnell

    Joined:
    Feb 24, 2011
    #3
    Thanks for the help, it seems to be working now.
     

Share This Page