Ben Langhinrichs

Photograph of Ben Langhinrichs

E-mail address - Ben Langhinrichs

January, 2011
02 03 04 05 06 07 08
09 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31

Search the weblog

Genii Weblog

Civility in critiquing the ideas of others is no vice. Rudeness in defending your own ideas is no virtue.

Wed 26 Jan 2011, 11:37 AM
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 ")
   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.

Why not give the Midas Rich Text LSX a try, and see what you can do when rich text manipulation truly is easy?  Request a free evaluation license, and try out the many samples today.

Copyright 2011 Genii Software Ltd.