PermaLinkShow 'n Tell Thursday #1
Written By : Scott Good

Technorati tags: ,

Hopefully, by now you know about Rocky Oliver's new initiative for all of us (YES, you, too) to give a little back, or out, or somewhere, to the general Notes community every Thursday. It's a collaboration tool; let's share.

Great idea, Rock. It was, as we are fond of saying around here, a Blinding Flash of the Obvious. Glad you had the sense to think of it. Wish I had.

So, without further ado, and in the spirit of Rocky's initiative, I'll show you mine if you'll show me yours (figuratively speaking, of course):

I love the formula language. I really do. It's fast, it's powerful, and (shhh, don't tell anybody) it's something a lot of newer developers, those who came at this from a Computer Science or, perish the thought, Visual Basic background, often have a hard time getting their heads around.

And yet, the things you can do with @Formulas are often a little like magic. Or at least, they can seem that way.

The mystery of the disappearing list elements

Let's imagine you have two fields, Company and State. Both are multiple-value fields. Both have several values:

CompanyState
AbercrombieOH
BoeingWA
Cummins EngineIN
DaimlerChryslerMI
EvenfloOH
GoogleCA
Home DepotGA

Ok, so let's say you need to find all the companies in the list located in particular state. Ohio, let's say. How would you do it? Go ahead. I'll wait. How would you write the code to extract only the names of the companies from Ohio?

If you could use LotusScript, which would be cheating, you could write a simple looping construct more or less like this:

Dim w As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = w.CurrentDocument
Set doc = uidoc.Document
Dim x As Integer
Dim companyList As Variant
x = 0
y = 0
Forall coName In doc.Company
   If doc.State(i) = "OH" Then
      Redim Preserve companyList(y)
      companyList(y) = doc.Company(x)
      y = y + 1
   End If
End Forall

That oughta do it, but that's a lot of work for what little you actually get out of it, and way too much typing. So what about not cheating and using the formula language? Well, you could do pretty much the same thing using the new ND6 looping constructs:

@For(n := 1; n <= @Elements(Company); n := n + 1;
   @if(States[n] = "OH";
      CoList := @Trim(CoList : Company[n]);
      ""
   )
);

That's certainly better, and a lot less verbose, but I'd rather keep it simpler still. That's still too much typing for my tired old fingers.

Formula language to the rescue: It turns out, all you really need to do everything we're trying to do here is this:

@Trim(@Left(Company + "~" + States; "~OH");

Really. Try it for yourself if you don't believe me.

What's going on here is elegantly simple. Company + "~" + States creates a list of concatenated values; Abercrombie~OH, Boing~WA, Cummins Engine~IN, and so on. @Left(...; "~OH") gets you everything that's to left of the string "~OH." That gives you a null for any list item that doesn't end with "~OH" and the name of the company for any that does. In other words, in my example above, you get this:

"Abercrombie" : "" : "" : "Evenflo" : "" : ""

@Trim( ) simply removes the null values and leaves you with "Abercrombie" and "Evenflo," the Ohio companies. You've gotta love the formula language.

Comments :v

1. Chad Schelfhout02/15/2006 11:25:15 PM
Homepage: http://www.chadsmiley.com


Very cool, I always did the @Explode with the third parameter of @False to get ride of empties but the @Trim is even more slick.




2. Peter von Stöckel02/16/2006 07:03:23 AM
Homepage: http://www.bananahome.com/


You've got to love those @Formula constructions! In cases like these, there's just no beating them!




3. Donovan Quesenberry02/16/2006 03:21:06 PM


Greetings,
Very KIS. This is what I was hoping S&TThurs would be. Simple ideas, simple code, extremely usable.
I appreciate it.
Stay Well
dq




Enter Comments^


Email addresses provided are not made available on this site.





You can use UUB Code in your posts.

[b]bold[/b]  [i]italic[/i]  [u]underline[/u]  [s]strikethrough[/s]

URL's will be automatically converted to Links


:-) :cry: :-\ :huh: ;-) :cool: :grin: :emb: :laugh: :-p :lips: :-( :rolleyes: :-o :-D :angry: :-x
bold italic underline Strikethrough





Remember me    

Disclaimer & Copyright
Monthly Archive
Contact me...
Racing sponsors and such...

Thank you sponsors!

GABlogLogo.jpg

GOODAero

GOODAero specializes in building aerodynamic products for racing cars. Our first product, the GOODAero Raptor wing is available at a surprisingly reasonable price (under a grand) for a full carbon, full-sized, racing wing. Check it out.


Infinite Fiberworks Co, a great source for high-quality Porsche fiberglass parts

Infinite Fiberworks Co.

If you are looking for fiberglass for Porsches, IFC is the place to go. I have used parts from most of the major suppliers and IFC's are easily the highest quality and the most reasonably-priced. Contact Mike at Infinite Fiberworks for more information.

Located in Racine, OH (so far Southeast they're almost in West Virginia), IFC's goal is to be The Best. Give 'em a try.


Bent or ugly wheels? Call Wheel Medic!

Wheel Medic & The Round House

Whether you need to repair, repaint, refinish or just replace your wheels, the guys at Wheel Medic/Round House can get you back on the road in no time!

Wheel Medic, Inc is a family-owned company which specializes in the repair and restoration of aluminum wheels.

The Round House was founded to service Wheel Medic's clients looking for more than just repair work...from custom wheel colors to high-end wheel applications and body kits, the Round House is there to serve the discriminating automotive enthusiast.


Used Porsche parts, great prices!

A Part Above

Looking for used parts for 944s, 924s, 968s or other late-model water-cooled Porsches? Contact John at A Part Above.

Located in Strongsville, OH (20 miles south of Cleveland) their goal is to provide top quality parts and services. I can tell you, John is great to work with and the prices? Very hard to beat.


SMRT Motorsports wants you!

SMRT (that's short for Skid Mark Racing Team), a very-

loosely organized band of fun-loving friends who enjoy auto racing (heck, cars in general), and the occasional adult beverage, wants you to be a part of our team.

Go here to find cool T-shirts, sweatshirts, caps and mugs with the SMRT team logo.

The BlogRoll
Lotus Domino ND6 RSS News Feed RSS Comments Feed Geo URL RSS Validator Blog Admin Lotus Geek Open Notes Picture Database OpenNTF BlogSphere
Calendar
February 2012
Su
Mo
Tu
We
Th
Fr
Sa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
By Category
What I do for a living


I am the President of Teamwork Solutions a long-time Lotus, now IBM, Premier Partner.

With offices in Columbus and Cincinnati, Ohio, we specialize in custom application development for IBM Lotus Notes, Domino, and related technologies. Our software product, ProcessIt! (see below), is quite possibly the world's best, most powerful and easiest-to-use workflow tool for Notes and the web.

Our clients are some of the world's largest corporations along with others that aren't so big.

We do excellent work, quickly, and often on a fixed-fee basis. We'd love to talk to you about your next project.




I am a Contributing Author to Lotus Advisor Magazine, with more than 40 articles under my belt.

I've written how-to series (serieses?) on LotusScript, JavaScript, Cascading Style Sheets (CSS), and now, AJAX (Asynchronous JavaScript and XML), as well as a bit on miscellaneous web development topics.


TheView.jpg

I also write for The View as of the July/August issue where I showed how to take an ugly Notes applications and make it beautiful with just a few minutes' (careful) work.



I am the chief architect and one of two primary developers for what many consider the best all-around workflow tool for Notes/Domino, anywhere, regardless of price.

It's called ProcessIt!, and you can read all about it at www.notesworkflow.com but the bottom line is this: ProcessIt! is fast and easy to learn, extremely powerful, and can be used by mortals. Even--dare I say it?--common users.

You can spend a lot more on a workflow tool but you won't be able to do a lot more for all the extra money.

Don't believe me? Download and try it for free for 60 days.



GTSLogoSm.gif
Copyright Porsche and NASA...not me!

I race a Porsche 944 S2 in National Auto Sport Assocation events and am the 2008 National Champion in NASA's GTS2 class.

Blame this event, a few years ago, for starting that particular money drain all over again.

In support of my habit, I am the NASA Great Lakes Region's GTS (German Touring Series) Director.

I'm also a Nationally-Certified Instructor for the Porsche Club of America and am in charge of classroom sessions for the Mid-Ohio region when we are doing high performance driving events.

In a prior racing life, I was the Midwestern Regional Formula Atlantic Champion and, in 1991, the Ohio Vally Region of SCCA's Regional Driver of the Year (but that, alas, went away when my credit cards let go of the rope!).




I'm writing a book...or at least trying to.

It's murder mystery in which, not too surprisingly, the main character runs a small software company and races cars for fun. Oh yeah, and lives near where I do.

Just where do they come up with these crazy ideas?

Facebook