[sword-devel] Getting started on sword coding

Troy A. Griffitts scribe at crosswire.org
Mon Sep 3 17:52:20 MST 2007


Awesome Lyndon!  Ha! What a silly mistake (local redeclaration of 
variable).  Yeah, I originally used an SWModule *, but changed it 
because the syntax is cleaner for stuff like the for loop:

for ((*bible) = TOP; !bible->Error(); (*bible)++)
for (bible = TOP; !bible->Error(); bible++)

But you have a very good point about error checking.  Thanks for the 
patch!  Applied.

	-Troy.



Lyndon Drake wrote:
> On Sun, 2007-09-02 at 21:41 +0100, Lyndon Drake wrote:
>> On Sun, 2007-09-02 at 13:12 -0700, Troy A. Griffitts wrote:
>>> So, all this to say, it doesn't work yet.  It is a fairly small, 
>>> self-contained client of the engine.  It might be a good place for you 
>>> to jump in and see how a typical client might utilize the engine, 
>>> including build system, etc.  I thought the code was done last night, 
>>> but looking at the output this morning, it doesn't work.
>> Sounds great - I'll have a look at it tomorrow evening after work and
>> see how I get on.
> 
> OK, I've made a start - it now builds and runs on my machine.  Attached
> is a trivial patch to print an error message if the KJV module isn't
> installed (guess what I forgot to do initially :-), and to make the
> Strongs-based lessons work as well as the KJV phrases.
> 
> BTW, is there a more canonical form for checking the return values of
> SWMgr.getModule() - my C++ is a bit rusty but might it not be cleaner to
> use a pointer variable rather than a reference?
> 
> Cheers,
> Lyndon
> 
> 
> ------------------------------------------------------------------------
> 
> Index: flash.cpp
> ===================================================================
> --- flash.cpp	(revision 96)
> +++ flash.cpp	(working copy)
> @@ -201,7 +201,7 @@
>  		}
>  		// if we would rather have short strongs
>  		else {
> -			SWBuf answers = w.def;
> +			answers = w.def;
>  			strip.processText(answers);	// remove html tags
>  			answers.replaceBytes("\n\r", ' ');	// remove newlines
>  		}
> @@ -241,13 +241,20 @@
>   */
>  vector<Word> processWords(const char *range, bool addAll = true) {
>  	SWMgr manager;
> -	SWModule &bible = *manager.getModule("KJV");
>  	map<SWBuf, Word> wordList;
> +	SWModule *tmpBible;
>  
>  	SWConfig hutf8("hwords.conf");
>  	SWConfig hdefs("hdefs.conf");
>  	SWConfig gutf8("gwords.conf");
>  	SWConfig gdefs("gdefs.conf");
> +	
> +	tmpBible = manager.getModule("KJV");
> +	if (tmpBible == NULL) {
> +		cerr << "Unable to locate KJV module" << endl;
> +		exit(1);
> +	}
> +	SWModule &bible = *tmpBible;
>  
>  	VerseKey parser;
>  	ListKey r = parser.ParseVerseList(range, 0, true);
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page




More information about the sword-devel mailing list