PDA

View Full Version : Applescript Error in Xcode




willfurnell
Mar 3, 2012, 11:12 AM
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:

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:

set passWordValue to passWord's stringValue()

--
-- 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 :)



Red Menace
Mar 3, 2012, 12:16 PM
The term password is reserved, so you will either need to choose another name or enclose the variable name in pipes.

willfurnell
Mar 3, 2012, 02:25 PM
The term password is reserved, so you will either need to choose another name or enclose the variable name in pipes.

Thanks for the help, it seems to be working now.