PermaLinkBigBill's Big 7, number 709:34:31 AM
Written By : Scott Good

@Formulas from The Bear

This is the last of my seven-piece tribute to Bill Ernest and no tribute to him would be complete without some serious @Formula jockeying.

I learned about @Formulas at the feet of the Master. By slogging my way through the unbelievably complex @Formula code underlying Bill's Quality at Work masterpiece I eventually learned an amazing amount about how to use this strange and interesting language (and wore out a Lotus Notes Reference Manual in the process).

But, no matter how good I got, he was better. We used to joke that Bill's Indian name was He Who Walks On Water With LotusScript, but it was really with @Formulas that he was the most unbelievable.

Therefore, it's fitting to end this series with a quick lesson in the power of the formula language.

Back to the basics

To do anything useful with @Formulas, you need to really, truly, understand several basic functions:

@Left (and @LeftBack)
@Right (and @Rightback)
@Word
@Replace
@ReplaceSubstring
@Subset
@Explode
@Implode

Learn these inside and out and you're most of the way to @Formula nirvana.

No, these may not be the ones you use all the time. And, yes, you need to know the others; @Prompt, @DbLookup, @DbColumn, and the hundred others that are the bread and butter of @Formulas. Of course you need to know them, but they're not as interesting. At the end of the day there's only so much you can do with them. But my list...that's where you start unleashing the power of the language.

One of the most interesting things about @Formulas is that almost all of them work their magic not just on single values but on lists. That's "arrays" for those of you raised on other, possibly inferior, languages. This is a good thing because in Notes you have a lot of lists.

Compared to Notes, most other databases don't take much of a liking to lists. Tell most DBAs you have mutiple values in your fields and they start rolling their eyes because, well, their tools don't like that a whole lot. Notes, on the other hand, loves 'em. We get lists all over the place: from @DbLookups and @DbColumns, from field values, from dialog box choices, from view selections, from...well, you get the idea. Lists are all over the place in Notes, which is part of the power of the tool.

Since @Formulas leverage the power of lists, they are an integral part of doing things in Notes. Yes, there's LotusScript and JavaScript and even Java for the real masochists in the crowd but, whatever it is you're trying to do, if you can do it with @Formulas you can be almost certain it will execute faster than it will in one of those other languages. As Rocky Oliver likes to say, it's closer to the metal.

So, get to it already

OK, enough of the sales pitch. Let's see some code.

Better yet: Here's a challenge: You have a single string containing the history of several different transactions:

"11/11/2004 Joe G. Davis changed the status from New to Submitted. 11/12/2004 Larry Bird changed the status from Submitted to Approved. 12/12/2004 Walter Jones, Jr. changed the status from Approved to Confirmed."

It's your job to extract some meaningful data from it. Into multiple-value fields called Dates, Names, StatusFrom and StatusTo you need to put lists of the corresponding data from each entry. In other words, the Dates field should contain the values...

11/11/2004
11/12/2004
12/12/2004

The Name field should contain the names of the people named in each entry (in the proper sequence, of course), and the StatusFrom and StatusTo fields should end up with lists of the beginning and ending stati. Are you with me?

OK, so how would you do it?

No, seriously. How would YOU do it? That's really the question here. I can show you how I would do it but how much will you learn from that? One of the most important things I learned from 12 years of working with Bill Ernest is there is no shortcut. If you're going to make your living doing the things we do, you have to just plain-old learn them.

There's room for creativity and improvisation and excellent user-interfaces are always highly appreciated but, I can't say this any simpler, you have to learn how to use the tool.

I'm going to show you the answer (at least my opinion of it) in a second but I recommend you try to solve it yourself first. Do your best. Work it out, THEN come back and see how yours compares to mine. If it's better, or it's close, post it here (include a defense if you like). If not, well, that's OK as long as you learn something from the process.

For that reason, in the great tradition of The Bear (our nickname for Bill), I'll show you the answer without explanation. If you don't understand it, take half an hour to tear it apart and figure out exactly how and why it works. That will be a great start toward you becoming a power @Formula coder, too.

Here's my solution:

L1 := "11/11/2001 Joe G. Davis changed the status from New to Submitted. 11/12/2001 Larry Bird changed the status from Submitted to Approved. 12/12/2001 Walter Jones, Jr. changed the status from Approved to Confirmed.";
REM;
Nums := @Explode("0~1~2~3~4~5~6~7~8~9"; "~");
From := " changed the status from " : " to " : (Nums + " ") : (". " + Nums);
To := "~" : "~" : (Nums + "~") : ("&" + Nums);
L2 := @Explode(@ReplaceSubstring(@LeftBack(L1; "."); From; To); "&");
REM;
FIELD Dates := @Word(L2; "~"; 1);
FIELD Names := @Word(L2; "~"; 2);
FIELD FromState := @Word(L2; "~"; 3);
FIELD ToState := @Word(L2; "~"; 4);
""

Good luck. Let me know how you came out. Oh, and Bill? Thanks for everything.

Comments :v

1. Richard Shergold05/10/2005 06:54:28 AM


Scott, I think that's brilliant. Thanks, I've enjoyed all 7 in the series.




2. Erskine Harris05/10/2005 08:18:31 AM


Scott,

This has been a great series of Blog entries, that I have read everyday. I think Bill would be proud of you passing on the knowledge and making people think about how to figure things out as opposed to just giving it to them.

Thanks,
E




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