Fourteen years and over 1.5 million client licenses after releasing the Midas Rich Text LSX, I still run into plenty of people who haven't heard of it or have no idea what it can do. But the most surprising thing to me is that even those who know what it can do don't always understand how easy it can be.
Take the following script, used to generate those neat little Additional Resources pages in the Sessions database:
id = "C"+Cstr(col+1+(row*MAX_COL))
Set rtLayer = rtchunk.FindNamedChunk(True, "Layer", id, "Exact")
Set rtLayer = rtitem.DefineChunk("Inside "+rtLayer.Definition)
If page > 1 Then
hide_formula = |P!="|+Cstr(page)+|"|
Call rtLayer.AppendParagraph("", "", hide_formula)
Elseif dc1.Count + dc2.Count > MAX_COL*MAX_ROW Then
hide_formula = |P!=""|
rtLayer.HideFormula = hide_formula
End If
Call rtLayer.AppendResource("Image", bookdoc.BookCover(0), |ImageWidth='|+Cstr(bookdoc.CoverWidth(0))+|' ImageHeight='|+Cstr(bookdoc.CoverHeight(0))+|' BorderEffects=DROP_SHADOW|)
Call rtLayer.AppendTable(1,1,|TableMarginLeft='0' TableWidth='2' CellBorder='NNNN' HideFormula='|+hide_formula+|' |,2.0)
Set rtCell = rtLayer.DefineSubChunk("Table "+Cstr(rtLayer.GetCount("Table"))+"; Row 1; Inside Column 1")
Call rtCell.AppendLink(bookdoc.BookTitle(0), repid, viewid, bookdoc.UniversalID)
If bookdoc.IsFree(0) = "Yes" Then
Call rtCell.AppendText(Chr(0)+bookdoc.BookType(0)+" (FREE)", "Plain #686868 ")
Else
Call rtCell.AppendText(Chr(0)+bookdoc.BookType(0), "Plain #686868 ")
End If
col = col + 1
This script finds specific layers, even if nested, sets hide-when formulas, adds a table, appends text with a specific color and style. In general, each task takes one line. For example, let's examine one of the most complicated lines:
Call rtLayer.AppendResource("Image", bookdoc.BookCover(0), |ImageWidth='|+Cstr(bookdoc.CoverWidth(0))+|' ImageHeight='|+Cstr(bookdoc.CoverHeight(0))+|' BorderEffects=DROP_SHADOW|)
The rtLayer variable points at a specific layer inside the rich text. We are appending an "Image" resource, and the image resource name is specified as the second parameter. The third parameter is string containing several optional properties. I used three:
ImageWidth - the width
ImageHeight - the height
BorderEffects - the style or type of border for the image, in this case, adding a Drop Shadow effect.
Of course, it is possible to do such a thing with DXL, but the amount of code it takes is much, much longer, and DXL doesn't operate on the rich text in place, but demands that you export the rich text, manipulate it, then import it.
Copyright © 2011 Genii Software Ltd.
Tags: Lotus Notes