[MacRuby-devel] [MacRuby] #235: Problems with adding objects to scriptable applications via scripting bridge

MacRuby ruby-noreply at macosforge.org
Fri Mar 20 04:39:45 PDT 2009


#235: Problems with adding objects to scriptable applications via scripting
bridge
--------------------------------+-------------------------------------------
 Reporter:  i.script@…          |       Owner:  lsansonetti@…        
     Type:  defect              |      Status:  new                  
 Priority:  blocker             |   Milestone:  MacRuby 0.4          
Component:  MacRuby             |    Keywords:  ScriptingBridge Error
--------------------------------+-------------------------------------------
 hi,


 lately I've tried to get some exerience in scripting DEVONthink using the
 ScriptingBridge. This works overall very well. Only the "create a record
 with in" command crates headaches for me. The following code-snippet
 exemplifies the problem:


 {{{
 #!/usr/local/bin/macruby

 framework  "Cocoa"
 framework  "Foundation"
 framework  "ScriptingBridge"

 devon =  SBApplication.applicationWithBundleIdentifier("com.devon-
 technologies.thinkpro2")

 theGroup = devon.createLocation '/root/scripts/myscript', :in => '/'
 theRecord
 =devon.classForScriptingClass("record").alloc.initWithProperties({'type'=>'text','plainText'=>"Hallo
 Welt!",'name' =>"helloworld"})
 puts theRecord.description


 #  Scripting Bridge does not actually create an object in the target
 application until you add the allocated and
 #  initialized object to an appropriate element array (SBElementArray),
 such as records in my example.

 #  thats's the way it should be done, but its not working

 puts devon.databases[0].records.insertObject(theRecord, :atIndex => 11)
 #  or : puts devon.databases[0].records.addObject(theRecord)

 theRecord.createRecordWithIn resultRecord
 }}}


 While working with this code snippet I've found out that:

 1. if i use: "puts theRecord" instead of "puts theRecord.description" the
 script runs out of time

 2. the attempt to instantiate a scripting object within DEVONthink creates
 this error:

 {{{

 /Users/stereocle/Documents/devonruby.rb:24:in `insertObject:atIndex:':
 NSGenericException: Apple event returned an error.  Event = 'core'\'crel'{
 'kocl':'DTrc', 'insh':'insl'{ 'kobj':'obj '{ 'want':'DTrc', 'from':'obj '{
 'want':'DTkb', 'from':'null'(), 'form':'indx', 'seld':1 }, 'form':'indx',
 'seld':1 }, 'kpos':'befo' }, 'prdt':{ 'DTpl':'utxt'("Hallo Welt"),
 'pnam':'utxt'("helloworld"), 'DTty':'utxt'("text") } } (RuntimeError)
 Error info = {
     ErrorNumber = -10000;

 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/235>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list