Greg is right, but concerning VerseKey objects. The problem with instancing a 
VerseKey is that it defaults to the KJV v11n system. The module may use 
another. So, then you need to setVersification appropriately on the newly 
instantiated VerseKey to access all the verses correctly for the module. The 
alternative is either to:

Simply call: SWModule::createKey()
Which will give you back an SWKey appropriate for the module.

Or simply send strings to SWModule::setKey(...)

All keys can be reduced to a string representation and each module type will 
ask its own key representation to deal with the string accordingly.

In C++, this is allowed in the engine by providing a const char * c-tor on the 
base of all keys, the SWKey object. Then SWModule::setKey(const SWKey &) will 
accept strings by constructing a temporary for you.

module.setKey("jas.1.18")

So, in essense, your C# code to create an SWKey with a string, and then set the 
module with this key does the same thing, though in multiple steps.

So, to summarize. Gregs warning about constructing a VerseKey manually is 
important. You're not doing this in your example so there's not danger of using 
the wrong versification system. I'm not sure if you need to even construct a 
key at all; i.e., I don't know if C# will imply the temporary SWKey and simply 
allow the module.setKey("jas.1.18"), as C++ provides for.

Hope this is more help than confusion.

Troy
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Greg Hellings <greg.helli...@gmail.com> wrote:

On Sat, Aug 11, 2012 at 9:38 PM, Daniel Hughes <tramps...@gmail.com> wrote:
> I managed to get it working with the following code:
>
> using(SWMgr mgr = new SWMgr())
> using(SWModule module = mgr.getModule("ESV"))
> using(SWKey key = new SWKey("jas 1:18"))

In SWORD you should _never_ instantiate an instance of SWKey. You
should use the module's methods for fetching its particular instance
of the SWKey and set the value using the appropriate methods (or
assignment overload in C++).

Because each module might have a different versification scheme, the
default when you instantiate one is to follow the KJV's versification
but that can lead to improper results when assigned to a module that
does not use KJV.

> {
> module.setKey(key);
> Console.WriteLine (module.RenderText());
> }
>
> I wouldn't go as far as to say that I have working c# bindings, I only have
> a very small subset working. I was planning on publishing what I have on
> bitbucket under GPL3.
>
> I must confess that as a C# developer I have no understanding of how to use
> make or how to integrate what I have with the rest of your repository and
> build system.

If you publish what you have, I can work with you to integrate it into
the engine's swig bindings. I have been the "pumpkin holder" for them
for a while now as well as for the CMake system that is the main way
to build them at present.

--Greg

>
> On Sun, Aug 12, 2012 at 4:22 AM, Peter von Kaehne <ref...@gmx.net> wrote:
>>
>> On Sat, 2012-08-11 at 20:25 +1200, Daniel Hughes wrote:
>>
>> > I'm trying to use sword from c#. I have used swig to generate a
>> > wrapper for just enough of sword to open a module and render some
>> > text.
>>
>> If you have working C# bindings, could you update the existing ones?
>> There is a not totally infrequent question on this mailing list for
>> those.
>>
>> That aside, I second the other response. No need to go into the details
>> of module construction, if you use SWMgr.
>>
>> Peter
>>
>>
>>
>>
>>_____________________________________________

>> sword-devel mailing list: sword-devel@crosswire.org
>> http://www.crosswire.org/mailman/listinfo/sword-devel
>> Instructions to unsubscribe/change your settings at above page
>
>
>
>_____________________________________________

> sword-devel mailing list: sword-devel@crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page

_____________________________________________

sword-devel mailing list: sword-devel@crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

_______________________________________________
sword-devel mailing list: sword-devel@crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

Reply via email to