This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


Oct 25, 2015, 11:02 AM
6 Posts

Lotusscript Obect finding properies with code ?

  • Category: Application Development
  • Platform: Windows
  • Release: 9.0.1
  • Role: Administrator,Developer
  • Tags: Class obect properties methods
  • Replies: 7

I am trying to save my self time and effort and have create a user class with about 100 properties. I now want to create a Load function and populate all the properties. The properties match the field names on a document. So in pseudo code what I would like to do is :

  • For each property in MyObject
    • fieldname = property.name
    • var = doc.fieldname(0)
  • Next Each

I have hunted around everywhere and cannot find any code that is workable in Lotusscript does anyone have any suggestion or do I have to recode all the names again  in the load function as an array ? Horrible for maintenance.

Oct 26, 2015, 1:34 AM
43 Posts
In theory you could use Execute

I think I read in an Advanced Lotuscript presentation somewhere that you can use lazy loading where you put the definition of your class inside an Execute command so that the class will be loaded only when the Execute command is called. So in theory you could craft your object definition string based on whatever fieldname exist in a document. However there is a 64k size limitation for a string so I don't think that this is workable for very large class.

Oct 26, 2015, 8:22 AM
107 Posts
Delegation?
Have you considered using a delegation design pattern? I.e., your class would encapsulate a NotesDocument object instead of trying to replace the NotesDocument class. To access properties your class would then have a generic getter/setter pair.

E.g.


Class MyClass

       Private pDoc As NotesDocument


       Public Sub New(rDoc As NotesDocument)

               Set pDoc = rDoc

       End Sub


       Public Function GetProperty(rPropName As String) As Variant

               GetProperty = pDoc.GetItemValue(rPropName)

       End Function


       Public Sub SetProperty(rPropName As String, rValue As Variant)

               Call pDoc.ReplaceItemValue(rPropName, rValue)

       End Sub


       'Add whatever operations and/or properties you need


End Class

Oct 26, 2015, 8:55 AM
6 Posts
Thanks for help

Yes the 64K would be and issue Tinus , your right.

Jochen I am really trying to avoid writing a get and set for every property. I just want to create a Load function that will load all properties in one fell swoop. So if I cant get access to the property name then I think I will have to go a different route. Thanks for the suggestions

Oct 26, 2015, 11:31 AM
202 Posts
I think the 64k limit for a string only applies to string fields
not to strings within Lotusscript.
Oct 26, 2015, 2:31 PM
107 Posts
depends
LotusScript String literals are limited to 32k bytes (16,267 chars).
LotusScript Strings in variants are limited to 64k bytes.
Oct 27, 2015, 1:43 AM
202 Posts
Yep, but some can be 2G
Item Maximum
Number of strings Limited by available memory.
Total string storage Limited by available memory.
Length of a string literal 16,267 characters (32,000 bytes).
Length of a string value 2G bytes

Total string literal storage in a module 2G bytes

Note  Even though strings in LotusScript 4 can be longer than 64K, there are still restrictions with the length of the string you can read or write using the GET and PUT statements. The only combination of filetypes that will work with long strings is with a binary file and a variable-length string. Fixed-length strings, strings in variants, and random files will not work with strings greater than 64K in length because they have a two-byte header which contains the length of the string. Two bytes cannot represent more than 64K.
Oct 26, 2015, 2:44 PM
107 Posts
For the records
My approach requires only a single getter/setter pair, which take the property name as a parameter.
Anyway, I'm not sure I understand what exactly you are intending to do.

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal