|
|
|
|
|
|
|
|
|
|
|
|
|
|
Getting inside the code of the automated signature generator (continued)
You can see how the @commands edit the text and insert the placeholder as bold, red text with the bounding characters.
When the template is processed as part of making the signature, the Render HTML and Format the Text clicks use LotusScript to do the replacement. The key lines of code are below. I've removed a few case entries to simplify and numbered them to call them out.
01 i = Instr(text,"#%")
02 Do While i > 0
03 j = Instr(text,"%#")
04 If j < i Then
05 Msgbox "Template is not properly formatted; terminating field replacement"
06 Exit Do
07 Else
08 fieldname = Mid(text,i+2,j-(i+2))
09 Select Case Ucase(fieldname)
10 Case "HTTP": text = Mid(text,1,i-1) & doc.http(0) & Mid(text,j+2)
11 Case "HTTP_1": text = Mid(text,1,i-1) & doc.http_1(0) & Mid(text,j+2)
12 Case "USERNAME": text = Mid(text,1,i-1) & doc.username(0) & Mid(text,j+2)
13 Case "EMAIL": text = Mid(text,1,i-1) & doc.email(0) & Mid(text,j+2)
14 << several Case statements removed here >>
15 Case "STRAPLINE": text = Mid(text,1,i-1) & doc.Strapline(0) & Mid(text,j+2)
16 End Select
17 End If
18 i = Instr(text,"#%")
19 Loop:
|
At line 01, we find the beginning of the next placeholder in the template text. If there are none, i will be 0 and the loop at 2 never starts. We'll assume there is at least one placeholder.
At line 03, we find the next end placeholder, which is fair to assume matches the start. Identifiers i and j now point to the start and end placeholders. Note that there is a check that j is greater than i at line 04 and we blow out if not, because the data is bad.
Line 08 then pulls out the placeholder name, and then the case statement between lines 09 and 16 examines that name and replaces the placeholder and the placeholder characters #%..%# with the actual value to be used. We then find a new value for i from the next placeholder, and go round again.
Getting the application to render HTML directly on to the screen in Notes 6 and above is easy. If you look at the HTML template, you can see just how easy it is, as shown in Figure A.
FIGURE A
 
Getting HTML to render is easy. Roll over picture for a larger image.
The HTML template is copied to the Computed Text, which is marked as Passthru HTML. When the Render HTML button is clicked it merely closes and reopens the UIDoc. That causes the Notes client to render the HTML. The main Signature Block create form does something very similar when you hit the Render HTML button, again, assuming you use a Notes 6 or above client.
For R5, life was a bit harder. Here's the code fragment that actually does it, taken from the Render HTML button in the HTML template:
01 If sess.notesbuildversion <= "166" Then 'R5 - we have to launch a browser
02 Print "Launching your browser to display the HTML.... please wait"
03 'write the HTML as a file in the Notes data directory
04 Set uidoc = wk.CurrentDocument
05 Dim fileNum As Integer
06 fileNum% = Freefile()
07 NotesDataDir = sess.getenvironmentstring("Directory", True)
08 HTMLFile = NotesDataDir & "\MailSigTemplateHTML.htm"
09 Open HTMLFile For Output As fileNum%
10 Print #fileNum%, Uidoc.fieldgettext("HTMLTemplate")
11 Close #filenum
12 Dim db As NotesDatabase
13 Set db = sess.currentdatabase
14 Dim newdoc As New Notesdocument(db)
15 Call newdoc.ReplaceItemValue("$publicaccess","1")
16 Dim rt As New notesrichtextitem(newdoc, "RT")
17 Dim eo As notesembeddedobject
18 Set eo = rt.EmbedObject(EMBED_OBJECTLINK,"",htmlfile)
19 Call eo.activate(True) 'should fire up the browser.
20 'We dont save the document we just created.
21 Print ""
22 Else 'Notes 6 can render the HTML directly,
23 'close and reopen the form to get the RT reloaded and the passthru HTML rendered
24 Call uidoc.Save
25 Call uidoc.close
26 Call wk.editdocument(True, doc)
27 End If
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Advertisement --
Find unused Lotus Notes groups and clean up your address book
Have you ever wanted to get rid of old Lotus Notes groups that were cluttering up your address book, but you weren't sure if they were used? Find Unused Groups can help.
Find Unused Groups will check your ACL, mail, multi purpose and server groups to help you determine if they are used, and who uses them.
Learn how to easily clean up your address book. |
-- Advertisement --
Struggling with exporting Notes data to spreadsheets? No More!
Try IntelliPRINT, The world's leading Reporting, Dashboards, and Analysis solution for Notes & Domino
- Don't spend unproductive time maintaining different versions of the same spreadsheet
- Preserve data integrity and security in multi-user environments
- Create reports in minutes INSIDE Notes
- Get freedom from iterative report requests, deliver self-serve capabilities
Experience Reporting, Dashboards, and Analysis INSIDE Notes.
Try IntelliPRINT NOW! |
|
|
|
|
|
|
|
|
|
|