I just officially completed my final version (for now) of my big project, “addressbook2pine”. I would like to thank everyone on MacScripter for all of their help and suggestions. I appreciate it more than you ever could know.
Since my addressbook2pine application utilizes many features of Xcode’s interface builder (disclosure buttons, expanding windows, progress indicators, radio matrix buttons, check boxes, push buttons, text fields, etc etc…), and since I went through a lot of hard work figuring out how to make each of these interface elements perform in the way I wanted— I figured the best contribution I could make to this site would be to give a URL to my source code so that it could be used as an example for anyone out there stuck on how to integrate applescript & interface items together.
Hi Patrick, it’s brave and admirable to post source code.
A few things you might want to look into (this is just after a first blush at your code and there may, and probably are, other things to try and optimize). First, in the download, when posting the source code, you should get rid of extraneous items in the archive (the duplicate NIB, the non-release build, the build folder at all, really). Next, in your code, your application will be significantly faster with compound if-then-else statements (once you’ve satisfied the if statement, why continue testing it?). Also, you have so much code that does the same thing. For example, all of the following routines are identical and superfluous (just use one!):
to getFirstname(f)
if f is missing value then return ""
return f
end getFirstname
to getLastname(l)
if l is missing value then return ""
return l
end getLastname
to getMiddlename(mn)
if mn is missing value then return ""
return mn
end getMiddlename
to getsuffixname(sn)
if sn is missing value then return ""
return sn
end getsuffixname
A few key subroutines for addressing the user defaults system would also go a long way to streamline and optimize your code. Finally, just trying to compile the main script didn’t work for me because you used the word “target” as a variable name and that is a reserved word within Xcode 2.1. Changing all instances of “target” to “_target” allowed the script to compile for me.
Good luck with this and I hope you understand that this was meant as constructive criticism, not just to be cruel.
Thank you for your comments and suggestions… I do indeed appreciate it, as I do want to know in what ways I can improve.
I really wish I could meet an applescript expert who lives in Southern California who would be willing to hang out and teach me some things, because there is so much I want to understand better…
Anyway, thanks also for pointing out those handlers, it was a total oversight, and mainly because I’m not yet in the stage of my life where I am writing with optimization in mind from the start… So, in that case, I had many subroutines which I think initially I was treating differently (using lists I think), but in the end it turned out for what I was doing, it was unnecessary so I just removed those things-- and then never stopped to realize that I could have just sent them all to the same handler-- but I will modify this now. Thank you Jon, and if you have any other suggestions please don’t hesitate.