Ben Langhinrichs

Photograph of Ben Langhinrichs

IBM Champion logo

E-mail address - Ben Langhinrichs

January, 2004
    01 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.

Fri 9 Jan 2004, 04:05 PM
I haven't blogged much about our Midas Rich Text LSX recently, and I thought I would describe an undocumented/semi-documented secret for all of you Midas users out there, or those just interested in Midas.  Perhaps this will even motivate me to document it properly.  Perhaps.

Since this tip relates to chunks, you might want to read Midas 101 - Chunks first if you are not comfortable with the concept.

Imagine the following nested tables (which came from today's CNN site) and that these are surrounded by lots more rich text stuff (as they are in that site):

enter symbol

MARKETS: 04:05PM ET, 01/09

Now, imagine that you want to get a handle on the blue table with the MARKETS: hotspot.  Midas is pretty flexible, so you could use FindTextChunk and find the appropriate text, or cycle through the hotspots until you found the right one.  After that, you could cycle through the various nested tables until you found one whose LastRecord property was greater than the LastRecord property of the hotspot or text chunk and whose FirstRecord property was less than the FirstRecord property of the hotspot or text chunk.  Possible, but kind of far away from the dream I espouse for Midas.  So, a few versions back, I added a better way.  

In my imagination, a developer or user would look at this problem and say "I want that table which has the word MARKETS in the upper left hand corner".  The question is, how to handle that in Midas-think.  My solution was to add a syntax close to that used in the FindTextChunk property.  Now, you can say:

Set rtchunk = rtitem.DefineChunk("Table 'MARKETS:' 1")

and the chunk will try to match the first table in which the string MARKETS: is the first string found.  Now, that may be a bit too precise, so you could also use 

Set rtchunk = rtitem.DefineChunk("Table Starts 'MARKETS' 1") 

where the first string in the table would need to start with the string, or 

Set rtchunk = rtitem.DefineChunk("Table Substring 'MARKETS' 1")

where the first string in the table would need to contain as a substring the specified string, or 

Set rtchunk = rtitem.DefineChunk("Table Ends 'TS:' 1")

where the first string in the table would need to end the string.  By the way, the search is not case sensitive, as that seemed a bit too constrained.

Now, like all chunks, you can cycle through each hit, so if you had a table such as the following:
SalespersonQuota ($)
Abelson, Bernard100000
Anderson, Art225000
Bratsworth, George55000
Cadwell, Lori175000
Carter, Billy15000
Dirk, Sidwell45000

you could use the following code to get the total of all the quotas for all the sales people whose last name started with C:

total_quota = 0
Set rtchunk = rtitem.DefineChunk("Table 1; Row Starts 'C' 1; Column 1")
While rtchunk.Exists
   total_quota = total_quota + Clng(rtchunk.Text)
There are lots more ways to use this, some less obvious than others.  See if you can guess what the logic of these other chunk definitions are and why they might be useful:

Set rtchunk = rtitem.DefineChunk("Text Substring '(216)' 1")

Set rtchunk = rtitem.DefineChunk("Hyperlink Substring '/showcase.nsf/' 1")

Set rtchunk = rtitem.DefineChunk("Hyperlink Substring '/Aladdin/' 1")

Set rtchunk = rtitem.DefineChunk("ActionHotspot Ends ' shutdown' 1")

Set rtchunk = rtitem.DefineChunk("Paragraph 'Table of Contents' 1")

Now, if you are a regular Midas user, you have learned something new.  If not, I hope you have gotten at least a taste of how simple and powerful Midas programming can be.

Copyright © 2004 Genii Software Ltd.

Fri 9 Jan 2004, 12:39 PM
Yes, I know I posted a new version just last night, but with 465 downloads so far, I feel I have a responsibility to my readers.  Anyway, there are two big changes I have made to the sessions db, one due to a great idea which Jerry Glover sent me (actually, he sent a modified db, but I then made additional changes you can read about on the sessions page), which is an embedded view to show other sessions starting at the same time as the one you are looking at.  This make it much easier to figure out what you are giving up by selecting a session.  Thanks, Jerry!.  In addition to this change, Carolyn Kraut suggested in the BP Forum that I add a calendar view, so there is a now a Calendar view, which is actually (and I am ashamed to admit this) the first Calendar style view I ever remember creating.   Some Notes expert I am!

Well, what is keeping you?  Go get your Lotusphere 2004 Sessions DB Build 3.0 right now.  Cheers!

Update: As of 4pm here in Cleveland, the sessions database has been downloaded 500 times.  Not too shabby, eh?

Copyright © 2004 Genii Software Ltd.