i just got into applescript today for a project at work. i have two interfaces, document.nib which has my main window and mainmenu.nib which has my menu and preference pain. i only have one preference i wish to save and access, machineName. all i am doing is mounting a network volume and am mounting whatever machine name is saved. any tips?
problem has changed. i solved the other problem by checking “continuously updates value” under the bindings menu for the text field in my preferences window.
now i have a problem using that text field in my preferences window. i want to mount a volume using a machine name the person enters, however i cannot use the text field correctly.
my code:
on clicked btnConnect
if text of text field "machineName" is "" then
display dialog "I'm sorry, but there is no machine name set."
else
try
--with timeout of 5 seconds
tell application "Finder"
-- mount volume ("smb://" & machineName)
display dialog "Connected."
end tell
--end timeout
on error
beep
display dialog "Could not connect. Please ensure that your computer is turned on."
end try
end if
end clicked
on will finish launching theObject
make new default entry at end of default entry of user defaults with properties {name:"machineName", contents:"192.168.1.1"}
end will finish launching
when i run build the app and press the connect button i get the following error:
AppleScript Error
Can’t make every text of <> “machineName” into type reference. (-1700)
does it matter if the text field machineName is actually in a panel and not a window? i just realized that i have one main window and a preferences panel.
that’s a no-go, i get the same error. i even moved everything into one .nib file. is there any special attribute that should be set on the field machineName?
full source code
on mouse down theObject event connectMachine
if content of text field "machineName" of window "Preferences" is "" then
display dialog "I'm sorry, but there is no machine name set."
else
try
with timeout of 5 seconds
tell application "Finder"
mount volume ("smb://" & machineName)
display dialog "Connected."
end tell
end timeout
on error
beep
display dialog "Could not connect. Please ensure that your machine is turned on."
end try
end if
end mouse down
on will finish launching theObject
make new default entry at end of default entry of user defaults with properties {name:"machineName", contents:"x.x.x.x"}
end will finish launching
machineName text field only has one relevant attribute, title: machineName.
you sir are a genious. that’s great, but it won’t read what’s currently in the text field machineName which is what i was trying to go for. should i figure out a way to edit the default entry after someone edits the text field? if so, how?
and yes, the preferences window is not visible at launch.
ah ha! thanks for all of your help bruce. looks like i’ve finally got my small little app where i wanted it to be.
set theMachine to (get contents of text field 2 of window 2) as string
if theMachine is "" then
display dialog "I'm sorry, but there is no machine name set."
else
i know this may not follow with the scope of the subject, but when i built my project and tried it on another mac at work i got the following message:
===== Mon Feb 13 2006 ===== 07:31:17 US/Central =====
ZeroLink: could not load .o file: /Users/XXXXX/Desktop/XXXConnect/build/XXXConnect.build/Development/XXXConnect.build/Objects-normal/ppc/main.ob
ZeroLink: unknown symbol ‘_main’
i have tried setting things for deployment in Xcode, but to no avail.