LotusScript to C API Programming Guide

rtLib Domino Rich Text Management template
Home
Show details for ContentContent
Purchase
Ready-to-use samples
Show details for Online resourcesOnline resources
Forum
Links
Happy readers

Anonymous

login


 

Hosted by Prominic.NET, Inc.
Main topic: Problems with memory management and NSFItemAppend

Problems with memory management and NSFItemAppend (by Normunds Kalnberzins, 11/22/2004 02:54:18 AM)

>>As far as I understand I now must use a memory buffer, write to it, and then set the item using NSFItemAppend with the content in the buffer.

Question 1: Is this a correct assumption?

*yes, in this way you should be able to write item of size up to 64K

>>I allocate a buffer that is as big as the number of characters is the text that I want to write.

Question 2: Is this correct? Should I perhaps allocate a buffer that is twice the size, since LotusScript uses 2 bytes per character?

In my code, I read my text file line by line and writes to the memory buffer using ODSWriteMemory. My buffer pointer is increased for each iteration.

** you'd rather allocate all 64K, then simply indicate the correct length of your text as LMBCS string. Well, provided that LS code also use LMBCS, that from forme experience I doubt.

>>Question 3: What type should be used as 2nd parameter here? ODS_BYTE or TYPE_TEXT?

**0, you could use this flags to indicate for example ITEM_SUMMARY, but if you want to write 64K this cannot be summary.

>>Question 4: Should the buffer-pointer be increased with the size of the LotusScript string just written, or perhaps with twice that size?

**depends how you set it up. You must be able to know the size of your text -- usually that something returned by OSTranslate or NLS_translate that you use to convert Unicode to LMBCS. But as i said i'm not 100% sure that the source code also uses LMBCS. it's going to be 2 times the size in chars provided you can write unicode straight from your LS string. You could try that.

>>When I use the NSFItemAppend API, what should the 4th parameter be? ODS_BYTE or TYPE_TEXT?

**TYPE_TEXT this time:-)

As for writting items bigger than 64K, I think you really append several items of the same name. Does it let to do that? Should be no problem.

Sure, this part you are in IS a bit undocumented; no wonder you feel it's a bit scary;-)

Your code looks more or less right:

1) as I just mentioned it could be better to have lenb(strLine); provided you can use Unicode in source code instead of LMBCS that is normally used for all the strings stored within Notes.

2) pCurr should increase automatically when you use ODSWriteMemory,

3) and you keep track of the length and use the real length instead of lngBuffSize. Or you subtract the end buffer pointer from original buffer pointer, but that comes to the same thing, as it's you who tells it how much to write each time.

Good luck

Normunds