Here's the problem. you're using object-oriented Lotus script to create classes and objects. like a good object-oriented LotusScript developer, You're declaring all your class variables as "private" and then writing"Setter"And"Getter"Properties to allow access to them.
The truth is, most of"Setter"And"Getter"Properties that you wocould write offer direct read/write access to those variables anyway -- and writing them out is such a pain! You cocould cheat and declare the class variables as public or you cocould have a Lotus Notes form generate them for you.
Here is the code for a button that will do just this:
Private m_myvar1 as stringprivate m_myvar2 as variantprivate m_myvar3 as integerprivate m_myvar4 () as string
That will generate these:
Public property get myvar1 as stringmyvar1 = me. m_myvar1end propertypublic property set myvar1 as stringme. m_myvar1 = myvar1end propertypublic property get myvar2 as variantmyvar2 = me. m_myvar2end propertypublic property set myvar2 as variantme. m_myvar2 = myvar2end property... and so on.
To further set this up, create a Lotus Notes form in any Lotus Notes database and put two text fields in it.
These text fields shocould be labeled:
- Input: This is a multi-value Lotus Notes text field. Set the multi-value options tick boxes to use "newline" for both display and input.
- Output: This is a single value Lotus Notes text field.
Now follow these steps:
- Create a button on the form and paste the button code below into its LotusScript click event.
- Create a new Lotus Notes document from the form and paste your class variable declarations intoInputField.
- Click the button.
The"Setter"And"Getter"Properties will be created inOutputField. You can then copy and paste the lotus script below into your class definition code:
Button codedim session as new notessessiondim ws as new notesuiworkspacedim uidoc as notesuidocumentdim doc as notesdocumentdim inputvar as variantset uidoc = ws. currentdocumentset Doc = uidoc.doc umentcall Doc. computewithform (false, false) inputvar = Doc. inputif inputvar (0) = "" thenmessagebox "no input found" Exit subend if % remassumptions are that class variables will declared thus private m_myvar1 as string private m_myvar2 as variant private m_myvar3 as integer private m_myvar4 () as stringand so on. we use the split function to create a variant array (tempvar) of 4 members. these will betempvar (0) = the word "private ". tempvar (1) = the variable's nametempvar (2) = the word "as" tempvar (3) = the variable's type. you need two text fields on a form: "input" = multi-value text field. set the multi-value options tickboxes to use newline. "output" = single value text field % end partition outputstring as stringdim tempstring as stringdim tempvar as variantdim variablename as stringdim region as stringdim variabletype as stringdim NL as region $ = "" dim region as Region $ = "M _" NL $ = CHR $ (13) & CHR $ (10) 'true for every ze only. shocould change for Mac or Linux clients. forall inputline in inputvartempvar = Split (inputline, "") variablename = trim (tempvar (1) variabletype = trim (tempvar (3) If instr (variablename, "(")> 0 then 'must be an array, so need to declare the set and get as variant variablename $ = strleft (variablename $ ,"(") variabletype $ = "variant" End ifif instr (variablename $, classvariableprefix $)> 0 then setgetvariablename $ = strrightback (variablename $, classvariableprefix $) else setgetvariablename $ = variablename $ end if outputstring $ = outputstring $ & "public property get" & setgetvariablename $ & "as" & variabletype $ & NL $ outputstring $ = outputstring $ & CHR $ (9) & setgetvariablename $ & "= me. "& variablename $ & NL $ outputstring $ = outputstring $ &" end property "& NL $ outputstring $ = outputstring $ &" public property set "& setgetvariablename $ &" as "& variabletype $ & NL $ outputstring $ = outputstring $ & CHR $ (9) & "me. "& variablename $ &" = "& setgetvariablename $ & NL $ outputstring $ = outputstring $ &" end property "& NL $ end foralldoc. output = outputstringcall uidoc. reload
Do you have comments on this tip? Let us know.
This tip was submitted to the searchdomino.com tip library by member Mike Brown. please let others know how useful it is via the rating scale below. do you have a useful Lotus Notes, Domino, workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you cocould win a prize.