COM API

Page 1 of 2 (30 items) 1 2 Next >
This post has 29 Replies | 2 Followers

Posts 232
AndyTheGreek | Forum Activity | Posted: Thu, Jul 1 2010 2:30 AM

Now I have the latest update, I've been fiddling with the COM API. Thus far, using the API I can:

  • Open Logos
  • Close Logos
  • List all the resources in my Library
  • Open a resource

What I haven't got my head around is opening a resource, say a Bible, at a particular place - Book, chapter and verse. Also, can the API be used to issue commands - Update Now, Update Resources, etc?

Anyone worked these out yet?

Andy

 

Posts 569
J. Morris | Forum Activity | Replied: Thu, Jul 1 2010 5:43 AM

Apparently the COM API is intended for more advanced users of some type...  I'll admit it all seems WAY over my head. 

Question:  What is it intended for exactly?  What will it help?

Could one of you production genius' create a video to help people like me (doubt I'm the lone wolf) see how to use it?  Big Smile

Posts 1367
JimTowler | Forum Activity | Replied: Thu, Jul 1 2010 7:12 AM

Andy Bell:

What I haven't got my head around is opening a resource, say a Bible, at a particular place - Book, chapter and verse. Also, can the API be used to issue commands - Update Now, Update Resources, etc?

Anyone worked these out yet?

Andy,

Sorry for the delay. I was going to send an answer earlier, but then forgot about it when something else got my attention.

Well, I'm still learning what works well, and have been focused on other non-Logos portions of what I need to get working.

Firstly, print out the current COM API docs if you like working off paper. Also have a look at the sample that Bradley wrote up. It gives a few good hints, but I don't know if its static, or if its had updates. I've not been back to look.

There are a few ways to open something to specific locations. The simple way is to open something manually, paste the link into a word doc, and then use that as a starter for some code. This aspect does not even need the COM API. You could just make calls to the Windows Shell API.

However, using the Logos4 COM API, calls to the following for example, using VIsual Basic 2010 (.NET).

Dim uri as string
uri = "logosres:esv;ref=BibleESV.Mt5.13" ' REM ESV to "SALT and LIGHT"
'uri = "logos4:Guide;t=Passage_Guide;ref=BibleESV.Jn1.1-18" REM Passage Guide on John 1:1-18
'uri = "logosres:bdag;hw=$CE$BB$CE$BF$CC$81$CE$B3$CE$BF$CF$82" ' Opens BDAG to logos
app.ExecuteUri(uri)

Posts 1367
JimTowler | Forum Activity | Replied: Thu, Jul 1 2010 7:21 AM

(OK - pasting from Visual Studio directly to the forum messes up formatting a lot!)

The above works, and will get you started. Better is to the the Navigation calls directly. I'll post something a little later, once I find something "clean" thats not too deeply nested in the way my current code is layered.

In short, you ask the COM API for a Navigation object, set its values to where you want to go, then pass that navigation object back to one of the navigate requests. A little cleaner in some ways that the above.

Note however, that directly using the URI concept makes it very easy to do this from a scripting language. Windows Shell, Perl, Java, just about anything that can create an object and make a few calls on it.

Posts 1367
JimTowler | Forum Activity | Replied: Thu, Jul 1 2010 7:32 AM

(Making each of these a new post, as they touch on different aspects.)

Re calling any command, such as running "Update Now" or "Rebuild Bible Index" is something I'm still unsure of. It does not seem to work as a call to the ExecuteUri, but its not a URI, so that seems fair. Not sure about passing it to the command-line, with the Launcher.LaunchApplication("Some command"), as I have not tried that one.

My hope is that one of the Logos guys might speak to this please.

Posts 232
AndyTheGreek | Forum Activity | Replied: Thu, Jul 1 2010 7:39 AM

Jim

Thanks for the info - I look forward to the Navigate information - I think that's what I'm after.

I'm using Delphi 2007, which seems to work OK with Logos4 but it has idiosyncracies of its own...

In theory, at least, the COM interface should let me build an application that tracks everything I do in Logos and can 'control' Logos to some degree. It might be possible to create a decent Note taking application that links to Logos' resources but is external to Logos, thereby solving all the Notes/Backup/Cloud issues/concerns in one hit...

Posts 1367
JimTowler | Forum Activity | Replied: Thu, Jul 1 2010 7:40 AM

J. Morris:

Apparently the COM API is intended for more advanced users of some type...  I'll admit it all seems WAY over my head. 

Question:  What is it intended for exactly?  What will it help?

Could one of you production genius' create a video to help people like me (doubt I'm the lone wolf) see how to use it?

Its mostly for programmers creating some kind of tool or application that works with Logos Bible Software.

My hope is, that in time, Andy, myself or someone, will release little modules already built, that can be used by others.

One good idea I got from someone earlier today, is something to start a download just after 2 am, when his internet traffic is not charged for (until 7 am).

I'm also playing with getting my ESV bible in Logos4 to track along by verse, as some MP3s of the ESV play in WIndows Media Player (it works a bit so far).

All kinds of useful things might be possible. And if the COM API gets additional functions in due course, who can say what someone might think of.

Don't be surprised to see some commercial (or free) products at some time, that uses the COM API to work with Logos Bible Software, to do something interesting or useful. Maybe some kind of teaching software, or Bible Study course, where it "automatically" opens things to the right place as you work thru the course-work. I'm only guessing, but I look forward to what people might do with it once it becomes known what it can do.

Posts 1367
JimTowler | Forum Activity | Replied: Thu, Jul 1 2010 8:59 AM

Andy Bell:
In theory, at least, the COM interface should let me build an application that tracks everything I do in Logos and can 'control' Logos to some degree. It might be possible to create a decent Note taking application that links to Logos' resources but is external to Logos, thereby solving all the Notes/Backup/Cloud issues/concerns in one hit...

Andy,

If Delphi allows you to receive the Events, you get them firing and telling you whats going on as you open or close panels, and navigate around within them.

Here is a trace of me opening ESV, then jumping to Rev, then scrolling down a few paragraphs. Note the API warns you need to detect and decide if anything has changed, or is something you care about. You will see lots of repeats. This is just from a program I'm using to test and try stuff. Its not very useful for much yet. It does however "watch" the Windows Message Pump, so gets events if the Clipboard changes, so it easy to copy a verse in Logos4, and have it automatically pulled from the Clipboard. For now, it just puts everything in a very large queue, and displays debug messages. But its on the way to some of the things a Notes package would need. My current thinking is to NOT write the whole thing, but call the automation object model of Word to do those parts.

Unless we have commercial secrets, I'm happy to continue sharing ideas.

0211.Logos4 trace.txt

Posts 1367
JimTowler | Forum Activity | Replied: Thu, Jul 1 2010 9:20 AM

Andy Bell:
Thanks for the info - I look forward to the Navigate information - I think that's what I'm after.

Again, in VB, and only a portion of a whole "something" that might be useful.

Call this with "Gold" and it will open something with "Gold" as a Headword. Just as if you double-click "gold" in some text somewhere. In my case, it opens to an entry in the "Baker encyclopedia of the Bible".

In short, get a nav object, fill it in, use it ==> jumps to location.

The calls are all Subs, not Functions. So you get no direct feedback. Its impossible to know if something worked, except if it DOES WORK, you get events fired for the new panel if there is an open or movement. I've not messed with this part yet, but I think I can "ask" a panel where it is, and in what resource. Also, asking what panels there are, and which is the current one.

For the example here, I got:

app.Event: PanelOpened [panel.Title: Baker Encyclopedia of the Bible] [panel.Kind: Resource] [panel.LinkSet: None]

Sample code for nav to a headword in whatever resource Logos4 feels like (it uses your resource priorities)

Public Sub NavigateByHeadword(ByVal inHeadword As String)

        app = launcher.Application
        Dim nav = app.CreateNavigationRequest()
        'nav.ResourceId = "LLS:COED11"                   REM Commented out
        nav.HeadwordLanguage = "en"                       REM English
        nav.Headword = inHeadword
        app.Navigate(nav)
End Sub

Posts 232
AndyTheGreek | Forum Activity | Replied: Thu, Jul 1 2010 10:25 AM

JimT:
If Delphi allows you to receive the Events, you get them firing and telling you whats going on as you open or close panels, and navigate around within them.

Delphi has a mechanism for receiving the events, but I haven't had a chance to try it yet - the 'Help Text' on the subject is vague and there's not much on Google about it... I could use C# (I've compiled the COM API sample app in C#) as it handles COM without hassles, but I have a huge set of Delphi GUI components that I'm loathe to sacrifice at this stage.

JimT:
Unless we have commercial secrets, I'm happy to continue sharing ideas.

Me too. One thing I am certain of is that whatever I produce wil not be commercial - if I think it's good enough for others to use I will make it available as freeware. I've been down the shareware route before with other applications and it's way too much hassle.

Anyway, I so far have 24 hours of Logos COM API experience and am pleased that I can get simple things to work. If I can crack the event handling then I may well take it further. Another option is to write a DLL in C# that Delphi can poll for the events...

I'm away now until Monday, so there wont be further progress until next week at the earliest.

Posts 232
AndyTheGreek | Forum Activity | Replied: Thu, Jul 1 2010 11:57 AM

Andy Bell:
I'm away now until Monday, so there wont be further progress until next week at the earliest.

I had one final fiddle with the API before shutting down for my long weekend and I now have my Delphi application receiving the Logos events! It remeains to be seen how far me and Jim can take this, but it's been relatively plain sailing so far. I'm really happy that Logos has chosen to make this API available - hopefully they'll be able to expand it and make it more and more useful.

Thanks, Jim, for the code examples and other tips you've posted. Next week I will revisit what I've done and explore more fully what this gives us...

Andy

Posts 41
Paul Davey | Forum Activity | Replied: Thu, Jul 1 2010 12:07 PM

It might be a bit off-topic but it took me a while to get this working so I figured I would post it.

I was able to get the Logos COM API working from Windows Powershell using the following:

 

$lg = New-Object -com "LogosBibleSoftware.Launcher.1"
$lg.LaunchApplication()
$lga = $lg.Application
$nr = $lga.CreateNavigationRequest()
$nr.ResourceId = "LLS:COED11"
$lga.Navigate($nr)
$lgap = $lga.GetActivePanel()
$lgap.Details
Posts 1367
JimTowler | Forum Activity | Replied: Thu, Jul 1 2010 12:57 PM

Paul Davey:
It might be a bit off-topic but it took me a while to get this working ... 

Hi Paul,

No - not off-topic in my view. Its right where it needs to be for what Andy was asking.

I'm not done much with any scripting for a while now. I used to do a lot with SVR4 Unix, and some Perl and some wscript on NT etc at one time.

Mostly, I currently mess around with VB or sometimes C#.

Your above code is a great starter for anyone wanting to script something, and using the .GetActivePanel, does not depend on the Events to get any new status.

So: VB, C#, Delphi and Windows Power Shell already ...

Posts 18075
Rosie Perera | Forum Activity | Replied: Thu, Jul 1 2010 2:09 PM

Glad to know there are now three of you guys doing COM API stuff. I was a programmer at one time in my life (worked for Microsoft for 11 years) and could probably figure this out and work on it too, but alas I've lost the interest and haven't got the time. And I don't have a development environment to work in anymore.

Posts 41
Paul Davey | Forum Activity | Replied: Thu, Jul 1 2010 7:32 PM

Hi Rosie

The thing about Powershell is that you don't need a development environment - it's just that, a shell.  It's a free download from Microsoft.  You don't compile anything, just issue commands and see if it works or not.

Posts 18075
Rosie Perera | Forum Activity | Replied: Thu, Jul 1 2010 7:44 PM

Paul Davey:

The thing about Powershell is that you don't need a development environment - it's just that, a shell.  It's a free download from Microsoft.  You don't compile anything, just issue commands and see if it works or not.

Thanks, Paul. I'm still too busy right now to give it a try.

Posts 23681
Forum MVP
MJ. Smith | Forum Activity | Replied: Thu, Jul 1 2010 10:05 PM

Paul Davey:
The thing about Powershell is that you don't need a development environment - it's just that, a shell.  It's a free download from Microsoft. 

Paul, if I don't get the lectionaries out it's all your fault - a new toy no one could resist.Big Smile

Orthodox Bishop Hilarion Alfeyev: "To be a theologian means to have experience of a personal encounter with God through prayer and worship."

Posts 41
Paul Davey | Forum Activity | Replied: Fri, Jul 2 2010 9:37 AM

Ok I got some navigation action happening:

 

$lg = New-Object -com "LogosBibleSoftware.Launcher.1"
$lg.LaunchApplication()
$lga = $lg.Application

$nr = $lga.CreateNavigationRequest()
$nr.ResourceId = "totc09kius"
$ref = $lga.DataTypes.LoadReference("Bible.1Ki8.62-66")
$nr.reference = $ref

$lga.Navigate($nr)

This navigates to the "1 Kings 8:62–66" entry of 1 and 2 Kings: An Introduction and Commentary, Tyndale Old Testament Commentaries logosres:totc09kius;ref=Bible.1Ki8.62-66

Posts 41
Paul Davey | Forum Activity | Replied: Fri, Jul 2 2010 9:41 AM

Just to add, the following line also works (i.e. the Bible reference has some flexibility, but must start with "Bible."

$lga.DataTypes.LoadReference("Bible.1 Kings 8:62-66")
Posts 41
Paul Davey | Forum Activity | Replied: Fri, Jul 2 2010 10:00 AM

Now to open a resource using friendlier language, just like searching your library.

$bstmatcol = $lga.Library.GetResourcesMatchingQuery("bible speaks today matthew")

$nr2 = $lga.CreateNavigationRequest()
$nr2.ResourceId = $bstmatcol.Item(0).ResourceID
$ref2 = $lga.DataTypes.LoadReference("Bible.Matt5:3")
$nr2.reference = $ref2

$lga.Navigate($nr2)

This chooses the first item matching my query, and opens it up at Matt 5:3

Page 1 of 2 (30 items) 1 2 Next > | RSS
Copyright 1992-2015 Faithlife / Logos Bible Software.