COM API: Need HELP using LogosDataType.ScanForReferences(text) please

Page 1 of 1 (6 items)
This post has 5 Replies | 1 Follower

Posts 1367
JimTowler | Forum Activity | Posted: Fri, Aug 27 2010 3:12 AM | Locked

I'm have been exploring the newest additions to the COM API. I have the CopyBibleVerse ones working. Sadly, plain-text, rather than RTF etc, but at least it works. Thanks.

However, I have no idea how to make the two new ones below work.

  1. LogosDataType.ParseReference(text)
  2. LogosDataType.ScanForReferences(text)

I'm happy to work out the details of the return types. But  I would value an example of what is expected in the text string for (1) and (2) above.

Please, if Bradley could give a hint of what the input strings for (1) and (2) looks like ...

(Either here, or maybe in the COM API docs themselves. Thanks.)

Posts 7142
LogosEmployee
Bradley Grainger (Faithlife) | Forum Activity | Replied: Fri, Aug 27 2010 10:59 AM | Locked

ParseReference(Text : String) : LogosDataTypeReference

Parses the text into a data type reference.

This method performs a "strict" parse and interprets the entirety of "Text" as a single data type reference. It tries pretty hard to understand the text it's given as a reference of the current data type. It's basically the method we use to accept input from text boxes in the application.

dt = app.DataTypes.GetDataType("Bible")
dt.ParseReference("Gn1.1") -> Bible.Ge1.1 
dt.ParseReference("First Thessalonians 1:1-3") -> Bible.1Th1.1-3
dt.ParseReference("John 3:16, 17") -> null
dt.ParseReference("Read Gen 1:1") -> null


ScanForReferences(Text : String) : LogosParsedDataTypeReferenceCollection
Scans the text for references (for this data type) and returns a collection of all that were found (or null if this data type does not support scanning).

This method takes arbitrary English text and finds all the references it can for the specified data type. It's basically the method we use to find references in a Word document for the smart tag. It tries a little less hard to force text to be interpreted with the current data type and errs on the side of caution in interpreting text that might be ambiguous.

dt = app.DataTypes.GetDataType("Bible")
dt.ScanForReferences("Gn 1:1") -> [ Bible.Ge1.1 ]
dt.ScanForReferences("John 3:16, 17") -> [ Bible.Jn3.16, Bible.Jn3.17 ]
dt.ScanForReferences("Read Gen 1:1") -> [ Bible.Ge1.1 ]
dt.ScanForReferences("My favourite verses are Gen 1:1, John 3:16, 17 and First Thessalonians 1:1-3") -> [ Bible.Ge1.1, Bible.Jn3.16, Bible.Jn3.17, Bible.1Th1.1-3 ]
dt.ScanForReferences("This text has no verses.") -> [ ] 

Posts 1367
JimTowler | Forum Activity | Replied: Fri, Aug 27 2010 3:02 PM | Locked

Thanks Bradley.

I should be able to get those to work just fine now. Without your post above, I was going to have to just try stuff, but the possible scope of "text" is rather wide ... Smile

There should be little now to stop any able programmer adding a "Smart Tags" kind of thing to any application or utility that supports any kind of addon or macro concepts. Many Thanks for making Logos4 even better!

Posts 232
AndyTheGreek | Forum Activity | Replied: Sun, Aug 29 2010 3:28 PM | Locked

I'll second Jim's thanks! The new CopyBibleVerses is excellent - it turns the API from being a 'novelty feature' into something really useful. I've already started writing an external note-taking application that uses this feature. Excellent.

One improvement would be to be able to specify which bible it works with - having to change the 'Favorite Bible' within Logos is a nuisance as it effectively makes bringing in comparisons of different translations a manual process... It would also be great to be able to specify the format to use without having to change it in Logos...

And the ability to pass text to Logos and get the Bible references back is going to be really useful as well.

These features really make the API useful in a practical way - so thank you!!

Posts 442
Tim Engwer | Forum Activity | Replied: Sat, Jun 4 2011 1:30 PM | Locked
ScanForReferences(Text : String) : LogosParsedDataTypeReferenceCollection
Scans the text for references (for this data type) and returns a collection of all that were found (or null if this data type does not support scanning).

 

This method takes arbitrary English text and finds all the references it can for the specified data type. It's basically the method we use to find references in a Word document for the smart tag. It tries a little less hard to force text to be interpreted with the current data type and errs on the side of caution in interpreting text that might be ambiguous.

dt = app.DataTypes.GetDataType("Bible")
dt.ScanForReferences("Gn 1:1") -> [ Bible.Ge1.1 ]
dt.ScanForReferences("John 3:16, 17") -> [ Bible.Jn3.16, Bible.Jn3.17 ]
dt.ScanForReferences("Read Gen 1:1") -> [ Bible.Ge1.1 ]
dt.ScanForReferences("My favourite verses are Gen 1:1, John 3:16, 17 and First Thessalonians 1:1-3") -> [ Bible.Ge1.1, Bible.Jn3.16, Bible.Jn3.17, Bible.1Th1.1-3 ]
dt.ScanForReferences("This text has no verses.") -> [ ] 

From this example could you please tell me how to get the output into a variable that I can see in a messagebox?  for instance I tried

$Text = $dt.ScanForReferences("Read Gen 1:1")

msgbox(0,"",$Text)  

The $text variable was empty so I must need to add a few more lines -- what would they be?

Thanks for the help!!

Posts 3578
steve clark | Forum Activity | Replied: Sat, Jun 4 2011 3:08 PM | Locked

Hi Tim,

Tim Engwer:
$Text = $dt.ScanForReferences("Read Gen 1:1")

ScanForReferences returns LogosDataTypeParsedReferenceCollection

So you will need to get that collection. Then you will need to determine if there is anything in that collection. Then you can get the reference info for that collection member which contains strings for your reference. The example below returns  "Ge 1:1" which is placed in var s1. If the reference is a range, then you will need to use the other Reference.Details. parts.

        Dim dtf As Logos4Lib.LogosDataTypeParsedReferenceCollection
        Dim s1 As String

        dtf = L4App.DataTypes.GetDataType("bible").ScanForReferences("Read Gen 1:1")
        If dtf.Count >= 1 Then
            Dim r1 As Logos4Lib.LogosDataTypeParsedReference

            r1 = dtf.Item(0)
            s1 = r1.Reference.Details.book & " " & r1.Reference.Details.chapter & ":" & r1.Reference.Details.verse
        End If

Hope this helps

 

QLinks, Bibl2, LLR, Macros
Dell Insp 17-5748, i5, 1.7 GHz, 8G RAM, win 8.1

Page 1 of 1 (6 items) | RSS
Copyright 1992-2015 Faithlife / Logos Bible Software.