[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[MacOS X] RubyAEOSA and Address Book

pere.noel

12/27/2005 12:39:00 PM

i'm trying RubyAEOSA with Address Book, it works great and much more
faster than AppleScript ;-)

actually i get 12 s to get the result with AppleSCript and only 0.868 s
with RubyAEOSA script (not finished yet)

however i have a syntax prob using Address Book.

the prob comes only when attempting to retrieve attributes related to
address.

if in RubyAEOSA i write :

set al to label of every address of every person

that's ok, i'm able to retrieve the label of the address howver, when
adding :

set as to street of every address of every person

i get an error :

[0m~/work/Ruby/rubyaeosa-0.2.3/sample> ./AddressBook2vCardXml.rb
/opt/local/lib/ruby/site_ruby/1.8/osx/aeosa/osacomponent.rb:32:in
`compile_execute': (-1753) OSACompileExecute (RuntimeError)
from
/opt/local/lib/ruby/site_ruby/1.8/osx/aeosa/osacomponent.rb:32:in
`do_script'
from
/opt/local/lib/ruby/site_ruby/1.8/osx/aeosa/osacomponent.rb:17:in
`do_osascript'
from ./AddressBook2vCardXml.rb:12:in `album_list'
from ./AddressBook2vCardXml.rb:57


same error when doing :

set {al,as,az,ac,ast,aco} to {label, street, zip, city,
state, country} of every address of every person
{c,o,d,t,f,l,n,el,ev,ul,uv,pl,pv,al,{al,as,az,ac,ast,aco}}

what surprised me here is in the fact i'm using the same approach for
email address :

set el to label of every email of every person
set ev to value of every email of every person

and that IS working...

what do you think is the good syntax for address ???

in case you have some light for me !

interested part of my AppleScript version :
-------------------------------------------
tell application "Address Book"
set theCount to count of every person
set companies to company of every person
set organizations to organization of every person
set departments to department of every person
set titles to title of every person
set firstNames to first name of every person
set lastNames to last name of every person
set {emailLabels, emailValues} to {label, value} of every email
of every person
set {urlLabels, urlValues} to {label, value} of every url of
every person
set {phoneLabels, phoneValues} to {label, value} of every phone
of every person
set {addressLabels, addressStreets, addressZips, addressCities,
addressStates, addressCountries} to {label, street, zip, city, state,
country} of every address of every person
set notes to note of every person
end tell
-------------------------------------------


interested part of my RubyAEOSA version :
-------------------------------------------
def album_list
result = OSX.do_osascript %{
tell application "Address Book"
set c to company of every person
set o to organization of every person
set d to department of every person
set t to title of every person
set f to first name of every person
set l to last name of every person
set n to note of every person
set el to label of every email of every person
set ev to value of every email of every person
set ul to label of every url of every person
set uv to value of every url of every person
set pl to label of every phone of every person
set pv to value of every phone of every person
set {al,as,az,ac,ast,aco} to {label, street, zip, city,
state, country} of every address of every person
{c,o,d,t,f,l,n,el,ev,ul,uv,pl,pv,al,{al,as,az,ac,ast,aco}}
end tell
}
co = result[0].map {|i| i.to_s}
org = result[1].map {|i| i.to_rbobj }
de = result[2].map {|i| i.to_rbobj }
ti = result[3].map {|i| i.to_rbobj }
fn = result[4].map {|i| i.to_rbobj }
ln = result[5].map {|i| i.to_rbobj }
no = result[6].map {|i| i.to_rbobj }
el = result[7].map {|i| i.to_rbobj }
ev = result[8].map {|i| i.to_rbobj }
ul = result[9].map {|i| i.to_rbobj }
uv = result[10].map {|i| i.to_rbobj }
pl = result[11].map {|i| i.to_rbobj }
pv = result[12].map {|i| i.to_rbobj }
return ln.map {|k| [ rand(10000),
[co.shift,org.shift,de.shift,ti.shift,fn.shift,k,no.shift,el.shift,ev.sh
ift,ul.shift,uv.shift,pl.shift,pv.shift]]}
end
-------------------------------------------
i don't use {al,as,az,ac,ast,aco} to this time because it's buggy ))
--
une bévue
2 Answers

pere.noel

1/1/2006 2:04:00 PM

0

Une bévue <pere.noel@laponie.com> wrote:

> however i have a syntax prob using Address Book.

sorry for the noise, i've forgotten that even if the script is written
in Ruby, in the AppleScript tell part i don't to use a reserved word as
"as" )))
--
une bévue

spamisus

2/14/2008 10:51:00 PM

0

On Feb 14, 12:54 pm, Jonathon Barbera <jonathonbarb...@ispname.net>
wrote:
> On Thu, 14 Feb 2008 12:37:10 -0700 (MST), jommycross@[127.1] (Jommy
>
>
>
> Cross) wrote:
> >On Thu, 14 Feb 2008 03:10:08 -0700, Jonathon Barbera
> ><jonathonbarb...@ispname.net> wrote in msg
> ><3q48r3t15itt9q1neos3rtlg2jre29h...@4ax.com>:
> ><snip>
>
> >>I'm not an apologist. I'm a declared SP.
>
> >Being a declared SP doesn't prevent you from being an apologist. Your
> >apologia includes explicit enthusiasm for KSW, doesn't it?
>
> >On Thu, 14 Feb 2008 03:38:27 -0700, Jonathon Barbera
> ><jonathonbarb...@ispname.net> wrote in msg
> ><jb68r3t2ul8keoe061unrim4eg29t81...@4ax.com>:
> ><snip>
> >>Yes, my choice is KSW.
>
> Keeping Scientology Working is a policy letter written to give
> instructions on how to keep standard tech standard. To use an almost
> disrespect comparison, it would be like Colonel Sanders writing a
> policy on how to keep his original recipe original. If caretakers of
> the "recipe" don't maintain its "flavor" then it isn't what the
> originator intended.
>
> Love,
> -- Jonathon
Yes, it's a very disrespectful comparison.
Colonel Sanders hasn't killed NEARLY as many people
as L. Ron Hubbard.
Now maybe if you had compared KSW to the secret recipe
for a brand of rat poison, you'd have a working analogy.