<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" />
<title>Re: [sword-devel] Sword API Questions / Proposal >> flatapi.cpp / flatapi.h</title>
</head>
<body dir="ltr">
Appreciate the prompt reply!
<p> </p><pre>On Tue, 3 Jun 2008 17:13:46 +1000, "Ben Morgan" <benpmorgan@gmail.com> said:
</pre><blockquote type="cite" class="QuoteMessage">
<div>Hi,</div>
<div> </div>
<div>Some answers below...<br /><br /></div>
<div class="gmail_quote">On Tue, Jun 3, 2008 at 4:45 PM, Simon J Mackenzie <<a target="_blank" href="mailto:smackoz@fastmail.fm">smackoz@fastmail.fm</a>> wrote:<br />
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;" class="gmail_quote">
<div dir="ltr">
<p style="margin-bottom: 0.5cm;">I have been attempting to familiarise myself with flatapi.cpp/h for a small in house project but have come up with a few questions about the Sword API, particularly flatapi.cpp/h.</p>
<p style="margin-bottom: 0.5cm;">1) The function listkey_getVerselistIterator in flatapi currently accepts two parameters but I fail to see the difference / dissimilarity between the two parameters "char * list" and "char * key"? Could someone please point me in the right direction? Thank you. </p>
</div></blockquote>
<div>The list is the actual text you want parsed. The key is some form of context. Thus a list of "6:1-12" and a key of "John 3:16" will give John 6:1-12. </div>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;" class="gmail_quote"> </blockquote></div></blockquote><div class="gmail_quote"><div dir="ltr">
<p style="margin-bottom: 0.5cm;"><span></span>Thank you this all makes sense now.<br /></p></div></div><blockquote type="cite" class="QuoteMessage"><div class="gmail_quote"><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;" class="gmail_quote"><div dir="ltr"><p style="margin-bottom: 0.5cm;"><br />2) Is there any reason why the function listkey_getVerselistIterator in flatapi.h does not accept a boolean flag for normalising a bible reference such as "John 6:1,12-16"?<br />
The current call to listkey_getVerselistIterator produces a "verses" array containing [John 6:1, John 6:12] and not [John 6:1, John 6:12, John 6:13, John 6:14, John 6:15, John 6:16] as would be expected.</p></div>
</blockquote>
<div>Currently the flatapi does not allow proper parsing of biblical references. Even with your proposed change, it will not allow you to get at what you want.</div>
<div>The listkey that is returned in the contains keys.<br /></div></div></blockquote>Using the mod I proposed provides me enough to work with. An array of single verse entries I can use to extract some biblical text. <br /><blockquote type="cite" class="QuoteMessage"><div class="gmail_quote"><div><br /></div>
<div>Each key is either a single verse (such as John 6:1)</div>
<div>or a contiguous range of verses (such as John 6:12-16)</div>
<div> </div>
<div>Thus under python you can do: </div>
<div>>>> lk=vk.ParseVerseList("John 6:1,12-16", "", True)<br />>>> lk.getElement(0).getRangeText()<br />'John 6:1'<br />>>> lk.getElement(1).getRangeText()<br />'John 6:12-John 6:16'</div>
<div> </div>
<div>However, the flatapi implementation uses getText, not getRangeText, so it doesn't return the ranges. Updating it to do this should result in it working. Note that the boolean flag you are wanting added controls whether the ranges appear, or just the first verse in each range.</div>
<div> </div>
<div>However, I don't believe the flatapi bindings are used at all, and are not likely to be updated. They implement a very small portion of the bindings. I'm not sure exactly what you are trying to do, but trying to do it using one of the three methods below is likely to work much better:</div>
<div>a) Python with the swig bindings - this is the approach BPBible uses.</div>
<div>b) using c++ - like almost all Sword clients do</div>
<div>c) using java, with either JSword (like BibleDesktop) or the corba bindings (as the web interface does (I believe))<br /></div></div></blockquote>d) using the flatapi bindings with D programming language, see www.digitalmars.com.<br /><br />For my joint managed congregarions here in Thailand I print the Lectionary Readings for each Sunday. This is currently done manually and is time comsuming and inefficient use of my time. In my spare time I've began writing a small program in D to extract a set of Lectionary readings (already working) for a given range of Sundays (tabulated text file of Lectionary readings)
and format the extracted Lectionary readings (working on this now) for import into OOo Writer for final layout and printing with a
minimum of user intervention. This has also been an opportunity for me to evaluate the D programming language for future projects (I used to be a programmer in my former life) which has been an enoyable experience.<br /><br />As I was looking over the flatapi code I started thinking ahead and was wondering what the status of this code was. Your comment confirmed that flatapi.cpp/h is far from complete but it is sufficeint for the needs of my current small project. What the future holds remains to be seen.<br /><br />
Regards<br />Simon<br />
</body>
</html>