Ben Langhinrichs

Photograph of Ben Langhinrichs

IBM Champion logo

E-mail address - Ben Langhinrichs







Recent posts

Mon 10 Jun 2019

Delving deeper into your data - Part 1



Fri 7 Jun 2019

Delving deeper into your data - Intro



Tue 4 Jun 2019

Twenty-two years of Midas


June, 2019
SMTWTFS
      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

Search the weblog





























Genii Weblog

@Transform and @Midas

Tue 14 Dec 2004, 10:56 PM



by Ben Langhinrichs
Rocky Oliver has a really cool article over on his LotusGeek site called Formula Big Top Preview: The Elusive @Transform.  In it, he describes the powerful @Transform function, added to formula language for Notes/Domino 6.x.  I'd suggest you go to his site to read all about it, but I'll excerpt one little bit:<blockquote>@Transform works against a list, and executes a formula against each individual element of the list, returning the modified list as the return value. The syntax of @Transform looks like this:
@Transform(list; name of variable; formula to run)


The list parameter is the list you want to work against.
The name of variable is a string that represents a single value in your list in the formula to run.
The formula to run is the single line of formula code you want to run against each element in your list.</blockquote>So, at the risk of being obsessive, how could you possibly use this with @Midas Formulas, which works on rich text fields?

It turns out, there are several ways.  I'm just going to show a simple example today, but tomorrow I'll show a much more powerful example, having to do with HTML generation and related to our on-line demo @Midas A La Carte (which you should try if you haven't, as it is entertaining if nothing else).

Getting Counts for Rich Text Targets
Let's say I want to find out the count of a number of different objects in a rich text field.  Let's say, for example, I want to find the number of tables, sections and URL hotspots.  My code could be: 

object_list := "Table":"Section":"URLLink";
counts := @Transform(object_list; "Obj"; Obj+"="+@Text(@DbCommand("Midas":"NoCache"; "GetCount"; ""@DocumentUniqueID"Body"; Obj)));
@Prompt([OK]; "Results"@Implode(counts; ", "));

This returns the result Table=1, File=0, URLLink=3 for this blog posting so far (with the fieldname changed to match this field).

Of course, we could make this a list selected by the user from a checkbox field, and the formula would not have to change at all.  Pretty cool.  But as I said, I have a more powerful example in mind which I need to write up and test tomorrow.  Now, back to Rocky's site to set up a trackback so he knows somebody is reading his articles <grin>.

Copyright © 2004 Genii Software Ltd.

What has been said:

No documents found