Ticket #235 (closed defect: invalid)
Problems with adding objects to scriptable applications via scripting bridge
| Reported by: | i.script@… | Owned by: | lsansonetti@… |
|---|---|---|---|
| Priority: | blocker | Milestone: | |
| Component: | MacRuby | Keywords: | ScriptingBridge Error |
| Cc: |
Description
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;
Change History
Note: See
TracTickets for help on using
tickets.

