Hey guys,
I am an absolute newbee to Applescript, xcode and applescript studio. I am a student researcher, in meta genomics. I have lots of perl scripts that I would like to put together in a nice stand alone software when user enters some config info, and then select a file (fasta file format or xml file) and the package will do its magic instead of me running 10 different perl scripts one after the other. So I have started working on it. My first task is just to get user to enter some server info, and make sure that I can connect to the server using my UI and ssh in the back end. I have set up the UI, and wrote some code using the guide from MacScripter and examples from xcode itself.
I have two problems right now. After I enter my info the the text field i get an error “Can’t make contents of «class texF» “blastServerAddress” into type reference. (-1700)” I have no idea what it means. My script is very similar to that of “Currency converter” script. I have attached my code below please help. Also not so urgent by quite annoying thing is I can’t figure you how to control to “tab” setting for the fields, that is after i type in some filed if I hit the tab key I want to specify with is the next text field to jump to.
Using xcode version 2.4.1, intel macbook 2.0ghz
I have be banging my head and looking for answer for quite some time, please help.
Thanks
Jaysheel.
on clicked theObject
-- try
if the name of theObject is equal to "blastTest" then
set theAdr to contents of text field "blastServerAddress"
set theUser to contents of text field "blastUserName"
set thePass to contents of text field "blastPassword"
end if
display dialog theArd
if sAdr is equal to "" then
display dialog "Must enter server address"
set valid to false
else if sUser is equal to "" then
display dialog "Must enter username"
set valid to false
else if spass is equal to "" then
display dialog "Must enter password"
set valid to false
else
set valid to true
end if
if valid is true then
display dialog sAdr & " " & sUser & " " & spass
end if
-- end try
end clicked
on awake from nib theObject
(*Add your script here.*)
end awake from nib
on idle theObject
(*Add your script here.*)
end idle
on should quit after last window closed theObject
return true
end should quit after last window closed
Browser: Firefox 2.0
Operating System: Mac OS X (10.4)
Well, apparently this error involes contents, "blastServerAddress", and some odd mix of letters inside some chevrons (in this case, they mean text field); Let’s look for these in your code.
set theAdr to contents of text field "blastServerAddress"
The typical cause for such an error is either misspelling a name or using an incomplete reference; Your problem is the latter. Your application doesn’t know where to find this text field named “blastServerAddress”; odds are that this text field is located inside a window (or inside a box, which is inside another box, which is inside a tab view, etc.). Wherever this object is, you need to give the application a complete reference to it. Here’s an example:
-- make sure the window is named!
set theAdr to contents of text field "blastServerAddress" of window "main"
Note that there are other ways of making this work. Assuming your three text fields are in the same window, you could use something like this:
if the name of theObject is equal to "blastTest" then
tell window "main"
set theAdr to contents of text field "blastServerAddress"
set theUser to contents of text field "blastUserName"
set thePass to contents of text field "blastPassword"
end tell
end if
Hey Bruce,
You are right. I have window, inside which I have 2 tabs “workbench” and “config”. I am getting all the info from the “config” tab, so I added
of box “config” of window “main” (the title of the window is “main”).
but no luck now I get an error NSReceiverEvaluationScriptError: 4 (1)
I did a search on the form for above error and its seems its a referencing error. Can you tell how to access my textfield with is inside a tab, and the tab is inside the main window.
OK so after looking through some more posts I make the following changes to my code.
if the name of theObject is equal to "blastTest" then
set contents of text field "blastServerAddress" of tab view "config" of box "work" of window "main" to "theAdr"
set contents of text field "blastUserName" of tab view "config" of box "work" of window "main" to "theUser"
set contents of text field "blastPassword" of tab view "config" of box "work" of window "main" to "thePass"
end if
But I still get the error for NSReceiverEvaluationScriptError: 4 (1)
I actually figured it out with a help of you guys and another friend Matt. Here is what did in case anyone else is wondering.
My code now looks as follows
tell tab view item "conf" of tab view "border" of window "main"
set theAdr to contents of text field "srAdr"
set theUsr to contents of text field "srUser"
set thePas to contents of text field "srPass"
end tell
Also on each of the text fields under “AppleScript” section in “info” section in Interface builder make sure you have checked your script name.
Thanks for all your help guys. I am sure I will have more questions for you guys.