Ben Langhinrichs

Photograph of Ben Langhinrichs

E-mail address - Ben Langhinrichs







Recent posts

Wed 18 Sep 2019

Perils of PDF 5: Data Confusion



Mon 16 Sep 2019

About that email in Notes



Mon 9 Sep 2019

Perils of PDF 4: Missing and obscured data


November, 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

Carrying Concealed (case file)

Thu 2 Dec 2004, 10:55 AM



by Ben Langhinrichs
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.

What has been said:


240.1. Stan Rogers
(12/02/2004 09:51 AM)

Now, this is gettin' good!


240.2. Duffbert
(12/02/2004 10:07 AM)

Can't wait to catch more of Crystal... :-)


240.3. bykrmyk
(12/02/2004 11:30 AM)

Yeah...Crystal. Now there's a dame. Just like her name, she's hard as rock and cold as ice. Sure she can read a sales brochure to a customer, slick as glass. But when it comes to the down and dirty of fixing a hide-when, she's as lost as a preacher in a biker bar.


240.4. Ben Langhinrichs
(12/02/2004 11:48 AM)

LOL. Thanks for your input, Biker Mike. It sounds like you know Crystal from... well, let's just say from way back.


240.5. Richard Schwartz
(12/02/2004 03:56 PM)

We're not worthy! We're not worthy! :-)

-rich


240.6. jonvon
(12/03/2004 05:59 AM)

Anakin Skywalker, Tom, Dick, Harry, dark helmets and heavy breathing all in one sentence!

i bow down in your general direction. :-D