COM API

AndyTheGreek
AndyTheGreek Member Posts: 232 ✭✭
edited November 2024 in English Forum

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

 

Comments

  • J. Morris
    J. Morris Member Posts: 569 ✭✭

    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?  [:D]

  • JimTowler
    JimTowler Member Posts: 1,383 ✭✭✭

    Andy Bell said:


    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)

  • JimTowler
    JimTowler Member Posts: 1,383 ✭✭✭

    (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.

  • JimTowler
    JimTowler Member Posts: 1,383 ✭✭✭

    (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.

  • AndyTheGreek
    AndyTheGreek Member Posts: 232 ✭✭

    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...

  • JimTowler
    JimTowler Member Posts: 1,383 ✭✭✭

    J. Morris said:


    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.

  • JimTowler
    JimTowler Member Posts: 1,383 ✭✭✭

    Andy Bell said:

    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

  • JimTowler
    JimTowler Member Posts: 1,383 ✭✭✭

    Andy Bell said:

    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

  • AndyTheGreek
    AndyTheGreek Member Posts: 232 ✭✭

    JimT said:

    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 said:

    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.

  • AndyTheGreek
    AndyTheGreek Member Posts: 232 ✭✭

    Andy Bell said:

    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

  • Paul Davey
    Paul Davey Member Posts: 44 ✭✭

    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
  • JimTowler
    JimTowler Member Posts: 1,383 ✭✭✭

    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 ...

  • Rosie Perera
    Rosie Perera Member Posts: 26,194 ✭✭✭✭✭

    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.

  • Paul Davey
    Paul Davey Member Posts: 44 ✭✭

    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.

  • Rosie Perera
    Rosie Perera Member Posts: 26,194 ✭✭✭✭✭


    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.

  • MJ. Smith
    MJ. Smith MVP Posts: 55,539

    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.[:D]

    Orthodox Bishop Alfeyev: "To be a theologian means to have experience of a personal encounter with God through prayer and worship."; Orthodox proverb: "We know where the Church is, we do not know where it is not."

  • Paul Davey
    Paul Davey Member Posts: 44 ✭✭

    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

  • Paul Davey
    Paul Davey Member Posts: 44 ✭✭

    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")
  • Paul Davey
    Paul Davey Member Posts: 44 ✭✭

    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

  • Bradley Grainger (Logos)
    Bradley Grainger (Logos) Administrator, Logos Employee Posts: 12,191

    Andy Bell said:

    Also, can the API be used to issue commands - Update Now, Update Resources, etc?

    No, the API cannot be used to execute arbitrary commands supported by the command box in Logos 4.

  • Bradley Grainger (Logos)
    Bradley Grainger (Logos) Administrator, Logos Employee Posts: 12,191

    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:

    Thanks for posting this; I added the basics of launching the app with PowerShell to http://wiki.logos.com/How_to_Use_the_COM_API.

  • AndyTheGreek
    AndyTheGreek Member Posts: 232 ✭✭

    Andy Bell said:

    Also, can the API be used to issue commands - Update Now, Update Resources, etc?

    No, the API cannot be used to execute arbitrary commands supported by the command box in Logos 4.

    Bradley

    Thanks for the clarification. I guess you know what my next question will be [:)]...

    Could such functionality be added to the API?

    It would make creating a scheduler to dio updates, download resources and re-indexing really easy, allowing such time consuming tasks to be done overnight. Better still, could such functionality be part of Logos? Instead of the simple 'Update Now' command, 'Update every wednesday at 0:00' would be excellent...

    Andy

     

  • David Garrett
    David Garrett Member Posts: 4 ✭✭

    I'm assuming the C# demo was created with Visual Studio 2005 or 2008. I have Visual Studio 2010 and it needed to be converted. I was running the demo for a couple of days, but now the Logos4Lib reference is no longer allowed. When I hover of the Logos4Lib text in a .cs file it says, "The type of namespace name 'Logos4Lib' could not be found (are you missing a using directive or an assembly reference?"

    Well it is an assembly reference. The referenced Assembly, Logos4Lib (Logos Bible Software 4 Type Library), which is on my system as LogosCom.exe.

    When I try to add the COM again I get the following error: "A reference to 'Logos Bible Software 4 Type Library' could not be added.

    My question is, does this have something to do with using VS 2010? The project is set to use .NET 3.5.

    Thanks,

    -David

     

     

  • JimTowler
    JimTowler Member Posts: 1,383 ✭✭✭

    I suggest you remove the Logos Type Library from your VS Project, then re-add it.

    There might have been some changes or whatever due to updates.

    See http://wiki.logos.com/How_to_Use_the_COM_API

    I tested both a VB Express 2010 and VC# Express 2010 projects just now, and both compile, link and run just fine. I have Logos 4.1 Beta 2 installed.

    (I'm waiting and looking forward to when they add a few more things to the COM API so we can use it for things that can't be done better or as well using the URIs. It fact, for page locations, its possible to get more power from a link than the navigation controls of the API. Most strange!!!)

  • David Garrett
    David Garrett Member Posts: 4 ✭✭

    Thanks for your reply, Jim. I did remove it and tried to add it again, but to no avail. I even tried to download the demo again and It still complains. I have 4.0d installed. Is it safe to try and update to the Beta?

    -David

  • JimTowler
    JimTowler Member Posts: 1,383 ✭✭✭

    Hi David,

    I don't know what your error is then. I don't have the full VS 2010 product. (I used to have VS 2005 installed on an older PC, but never upgraded te licenses due to the high costs, and using it little. I try and get by on the Express products for most of my current needs.)

    Consider making yourself a new Windows Form project using VB or C#, or whatever. Add the Logos Type Library, then add a single Button, and make it so that is creates the base Logos Launcher object, then starts Logos4 running.

    Once you have such a project, you can compair the one that works against the one that wont link/compile and work out whats going on with the Logos type library and how they resolve. I don't know what level of Logos4, Visual Studio or programming knowledge, so don't want to make this post too complex. See how this goes, and maybe I can say more, or others might speak up too. Consider posting a screen-capture of selected bits containing the errors or messages you get. The more you can make it easy, the better someone will be able to work out whats up I guess.

    In C#, this can be little more than as follows:

    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Logos4Lib;

    namespace Logos4Tester
    {
        public partial class Form1 : Form
        {
            //int X;
            //LogosApplication app;
            LogosLauncher ll;
          
            public Form1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                ll = new LogosLauncher();
                ll.LaunchApplication();
            }
        }
    }

    Re the Beta, I have only used the Beta since the start, and don't have a release install at present (disk space). I do have L3 as a backup plan, but its rare to every look there.

    If you need Logos4 to be as close to 100% operational, with low risk, maybe Beta is not for you. Howver, with Printing now, there are enough goodies that mostly work to make it useful. Please read the warning and caution note posted to the top of the Logos4 PC Beta forum before you consider installing it.

  • JimTowler
    JimTowler Member Posts: 1,383 ✭✭✭

    I have my projects built using .NET 4.0, so I can use the latest and best.

    I think the Logos4 application is built to 3.51 SPx, so it might be important to be at least that or hgher. Not sure. Just use 4 for your code.

    EDIT: The version of .NET you use for your own code really does not matter. I just testing the above code built for 3.5, 4.0 and 2.0 and its fine!!!

     

  • David Garrett
    David Garrett Member Posts: 4 ✭✭

    OK, things are working great now. I'm not sure what happened, but I typed the command 'set update channel to beta', then immediately it said it was downloading updates. But it never installed it. I type 'update now' and it said there were no updates. I check the version of my Logos software and it is still 4.0d. I went into Visual Studio and tried to add the Logos COM reference and it did it successfully.

    As I am typing this a text bubble just popped up from Logos telling me I have updates. It is probably the Beta. I'm going to install it now.

    Thanks for your help.

    -David

  • David Garrett
    David Garrett Member Posts: 4 ✭✭

    OK, now that things are working, I see from some posts that one can pass strings to ExcuteURI that start with "logosref", "logosres", or "logos4". Are these the only base commands supported? Is there an exhaustive list of the supported commands and all the permutations somewhere? Where would one learn how to use the Logos COM API?  I've found some info on the Logos Wiki, like the demo, the Logos 4 COM API wiki, List of Resource Types, Bible Book Abbreviations, List of DataTypes, etc., but there are many other bits of data that are missing. I see I can also get some of the information from the Logos COM API, like, LogosApplication.Library.GetResourcsByResourceType().

    I modified the logos COM API demo to use resource types like, "lbx.calendar-devotional", or "text.monograph.bible", in a ComboBox, (I found the resource types on the Logos Wiki), then retrieved the resources from my library and listed them in a ListView. It just seems there are many gaps in the knowledge needed to really use the Logos COM API effectively.

    I would like to use the Logos COM API with Microsoft's OneNote API, but the Logos COM API doesn't expose much. I would like to play with and understand the Logos COM API, so that I can request additions to the Logos COM API that would be useful.

    Thanks,

    -David