[bt-devel] save search anlaysis - updated

Joachim Ansorg bt-devel@crosswire.org
Wed, 19 Dec 2001 16:52:00 +0100


Hi Mark!


> I figured a little discussion might help this along.  To me the way to
> limit the books on the output html page it to get a list of the books
> that were within the scope.  Then iterate through that list when
> building the page.

This sounds like the right way to go,

> Currently, the code is using the CSwordVerseKey class (starting with
> Genesis 1:1), and calling NextBook until it runs out of books.
>
> My initial thought was to get the scope (in the form of a list of
> verses) possibly from the CSwordModuleSearch class (would have to be
> modified to return the scope), then use that list to identify the books
> in question. I don't see a class which takes a list of verses and will
> iterate through the books like the CSwordVerseKey does though. Is there
> such a tool available?  One option is to go through each verse and
> compare the book to the previous, but i think that is less than desired.

You were right, the CSwordModuleSearch class did not have a function which 
returns the used scope. I added CSwordModuleSearch::scope() which returns the 
used scope as a ListKey.

ListKey is a class of Sword, it's derrived from SWKey and holds a list of 
keys. We use this class to implement our scope.
I'd suggest to get the scope of the search (see above) and then iterate 
throught the list of SWKeys (given by the scope ListKey).
Then cast each SWKey of the list to an VerseKey (valid, because were 
operating on Bibles and commentaries).
The remaining problem is to get the books which are in a range (I hope the 
VerseKey we have now has valid boundaries).

As a solution I'd suggest something in the following way (I left out some 
thins):

CSwordVerseKey bookKey;
//add here a loop which itereates though all books from Genesis to Revelation
{
	//now check if the book is in the scope
	VerseKey vk = bookKey;
	// set the scope to vk
	[...]
	if (vk == bookKey) { 
		/*
		* If the book is not in the range
		* bookkey would be different to vk
		*/

	}
}
}

This is only a quick framework, I hope you can get it working. I fnot please 
ask again.


Joachim