Genii Weblog


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


Thu 2 Dec 2004, 10:55 AM
Mike MidasCarrying Concealed
by Mike Midas, Ace Developer

It was the end of a long day, the kind of day that made me rummage through my desk for a hair of the dog, even though I hadn't touched a drop the night before.  This e-mail was the last thing I needed, the last thing that is but a glass of whiskey and a dame to spill it on.

"I have lots of documents, thousands and thousands, that were created with a form with a hide-when formula on the Body field.  We changed the hide-when formula, but now we can't see any of the old fields."  The message was longer, but I wasn't holding my breath like some doll swooning over  Anakin Skywalker when every Tom, Dick and Harry knew he was destined for a life of dark helmets and heavy breathing.  I knew what was coming.


Sure as shinola, the letter went on to say, "Now the new documents we create work fine, but the thousands of old rich text fields don't show up at all.  This is really urgent, as my boss is gonna kill me if I can't figure out how to fix this before all hell breaks loose!"  Cry me a river and send me downstream to a beach with a boardwalk, babes and booze.  Where was that damn bottle?

People are strange.  They spend every last dollar trying to find a safe way to stash their valuables, then want to moan and complain like a cheap date sharing a single box of popcorn at the movies with Pee Wee Herman when they can't find the stash later.  

It made me wince, but I had to read to the end in case there was some diabolical twist snuck into the e-mail like a hand grenade in a box of Cracker Jacks.  Sure enough, it was there.  "What my boss doesn't know yet is we use these rich text fields combined with some others and rendered to a new document.  So even if I knew how, I couldn't just change all the hide when formulas on those documents, because there are some different hide-whens and hide-flags  on the rendered form that need to stay."  I looked at my watch, but unfortunately I had enough time.  Why is there always time when clients are involved, and never when you have thirty seconds left on a sixty second peep show?  

I started simple, 'cause this guy didn't sound up to the hard stuff.  The beach umbrella was up, but the sun wasn't shining, if you catch my drift.  This bit of code would set the hide-when formula everywhere, slicker than spit and a helluva lot less messy:

While Not (doc Is Nothing)
   Set rtitem = New GeniiRTItem
   Call rtitem.ConnectBackend(doc.Handle, "Body")
   If rtitem.IsConnected Then 
      rtitem.Everything.HideFormula = new_formula
      rtitem.Save
   End If
   Set doc = collection.GetNextDocument(doc)
Wend 

But that wasn't good enough.  I had to deal with those rendered documents.  Why don't they stick to rendering the leftover chickens at KFC?  There could be all sorts of random hide-when formulas, and I didn't want to cycle through every paragraph.   It would take too long, and I needed the time to nip down to the corner market and purchase some hooch before Crystal got back and put the nix on it.

Sometimes a man has to do what a man has to do, damn the torpedoes and full steam ahead.  I remembered a sample database I wrote a couple of slow Sundays ago when the cable was out and the only show on was an old repeat of a Dallas episode with Bobby Ewing showering and recovering nicely from being road kill.   It took less time than it takes a pigeon to target a tourist in Times Square to find what I needed, and it was easier than I thought, as I had forgotten that the ReplaceText method would change hide-when formulas:  

While Not (doc Is Nothing)
   Set rtitem = New GeniiRTItem
   Call rtitem.ConnectBackend(doc.Handle, "Body")
   If rtitem.IsConnected Then 
      Call rtitem.Everything.ReplaceText(old_formula, new_formula, "HideWhen")
      rtitem.Save
   End If
   Set doc = collection.GetNextDocument(doc)
Wend 

Why walk through the park when you can send the terrier on ahead to do its business without you?  I sent it off, knowing my chances of getting thanked were lower than a limbo champion with arthritis.  But no matter, because I had time to get to the Cash & Carry, and the day was finally looking up.

Copyright © 2004 Genii Software Ltd.