Hi,<br><br>For a start, using help isn't all that useful. Output for help of Versekey is contained in attached help.txt. Using dir will usually be just as much use. If I want to know how something works, I look at the c++ source code (which is quite an opaque mess, I think :) If you have doxygen generated, look at that. That may help a bit. A few of the methods are renamed, I think. ie
SWModule.search becomes SWModule.doSearch<br><br>Also, I do not know that there is any way to check whether a module contains a certain book (though it probably doesn't if you go through a whole chapter and it is empty)
<br><br>To get all book names and chapter counts in old and new testaments:<br>__________________<br>#!/usr/bin/python2.5<br>import Sword<br>vk=Sword.VerseKey()<br><br>def GetBooks():<br> for i in range(2):<br> for j in range(
vk.bookCount(i+1)):<br> print vk.bookName(i+1, j+1),<br> print "has %d chapters" % vk.chapterCount(i+1, j+1)<br><br>def GetChapters(i, j):<br> bookname=vk.bookName(i, j)<br> for k in range(
vk.chapterCount(i, j)):<br> print "%s %d has %d verses" % (bookname, k+1, \<br> vk.verseCount(i,j,k+1))<br><br>print GetBooks()<br>print GetChapters(1, 3) #old testament, 3rd book = Leviticus<br>
print GetChapters(2, 3) #new testament, 3rd book = Luke<br>__________________<br><br clear="all">An updated version of your script with my comments added on certain points:<br>__________________<br>#!/usr/bin/python2.5<br>
import Sword<br>import sys<br>#mgr=Sword.SWMgr()<br>#mgr.getModule('KJV')<br>vk=Sword.VerseKey()<br>error=0<br>cnt=1<br>while 1:<br> print "cnt=%d" % cnt<br> # use the following instead of a count as when the counter gets to Matthew,
<br> # it automatically increments the testament and sets vk.Book() to 1<br> # ie <br> # >>> vk=Sword.VerseKey()<br> # >>> vk.Book(1)<br> # '\x00'<br> # >>> vk.Testament()<br>
# '\x01'<br> # >>> vk.Book(40)<br> # '\x01'<br> # >>> vk.Book()<br> # '\x01'<br> # >>> vk.Testament()<br> # '\x02'<br> # So we do this below:<br>
test=vk.Book(ord(vk.Book())+1) #use ord to change char -> int<br> <span style="background-color: rgb(255, 255, 255);"> cnt+=1</span><br style="background-color: rgb(255, 255, 255);"><span style="background-color: rgb(255, 255, 255);">
error=</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">ord(vk.Error()) #with error, do error=ord(vk.Error()), this will output a number instead of a char<br> if(error):</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
break<br></span><span style="background-color: rgb(255, 255, 255);"> name=vk.getBookName()</span><br style="background-color: rgb(255, 255, 255);"><span style="background-color: rgb(255, 255, 255);"> abr=vk.getBookAbbrev
()</span><br># count=vk.bookCount()<br> print "%s -> %s " %(abr,name)<br> print "error=",error<br> print vk.Index()<br> #print vk.UpperBound().Index() #This is only for keys with bounds set
<br> #print vk.LowerBound().Index() #ditto<br>__________________<br><br>If you would like any other help, just ask.<br><br>God Bless,<br>Ben<br>-------------------------------------------------------------------------------------------
<br>He has made everything beautiful in its time. Also, he has put eternity into mans heart, yet so that he cannot find out what God has done from the beginning to the end.<br>Ecclesiastes 3:11 (ESV)
<br><br><div><span class="gmail_quote">On 1/30/07, <b class="gmail_sendername">Pierre Amadio</b> <<a href="mailto:pierre.amadio@libertysurf.fr">pierre.amadio@libertysurf.fr</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi there.<br><br>On Sun, Jan 28, 2007 at 07:18:31PM +1100, Ben Morgan wrote:<br>><br>> If you have any specific questions on how to do something, just email me.<br><br>I m copying the list as well as the answer may be interesting to have on
<br>the archive of the list.<br><br>I do not understand how to get a list of book that one can use in a<br>given module.<br><br>Using the following code, i have a sort of list of existing bible book:<br><br>__________________
<br>#!/usr/bin/python2.5<br>import Sword<br>import sys<br>#mgr=Sword.SWMgr()<br>#mgr.getModule('KJV')<br>vk=Sword.VerseKey()<br>error=0<br>cnt=0<br>while 1:<br> print "cnt=%d" % cnt<br> test=vk.Book
(cnt)<br> cnt+=1<br> error=vk.Error()<br> name=vk.getBookName()<br> abr=vk.getBookAbbrev()<br># count=vk.bookCount()<br> print "%s -> %s " %(abr,name)<br> print "error=",error<br>
print vk.Index()<br> print vk.UpperBound().Index()<br> print vk.LowerBound().Index()<br>__________________<br><br>However, as my verse key does not know wich module i m interested in, i<br>cannot be sure all the book will be available for a given module (i
<br>think tere are some translation that are not complete).<br><br>Plus, I do not see any new testament book (except for revelation).<br><br>I cannot understand how to detect i reach the end of the books.<br><br>Bear in mind that, as my python version does not seem to implement
<br>help(), i guess what is available in the modules and object i have<br>with dir().<br><br>Before trying to understand every things related to text rendering, i<br>would be happy knowing how to:<br><br>-get a list of books in a module
<br>-get a list of chapter in a book<br>-get a list of verses in a chapter<br><br>I hope the 3 mechanism are similar :)<br><br>Best regards<br><br><br>_______________________________________________<br>sword-devel mailing list:
<a href="mailto:sword-devel@crosswire.org">sword-devel@crosswire.org</a><br><a href="http://www.crosswire.org/mailman/listinfo/sword-devel">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br>Instructions to unsubscribe/change your settings at above page
<br></blockquote></div><br>