Wednesday, April 29, 2009

Work Area Manager - Go Green with VFP

At my onsite gig I'm maintaining a VFP app that's been ported from FoxPro DOS to FoxPro Windows to VFP. It has a lot of old code in it, that suffice it to say, is suboptimal. Introducing new, well-written code into it is often challenging. The old code includes very little defensive coding and is full of assumptions about the environment it runs in. It's really dependant on what cursors are open, filters, indexes, record pointers and so on. The app is modal and there's a lot of "drill-down" type behavior, so things that the environment is depenendant upon may have longn ago in the call stack. After a lot of messing around with hard coding specfic states I needed to save and restore I finally decided to just create a class that would handle this stuff for me. If you remember the cSelect class from Codebook or VFE this is basically just an extended version of it that handles all open work areas. There's nothing complex about it, so I'm not going to get into the specifics of the code here. 

In the zip I've linked here, is a class named WorkAreaManager. Basically before you're going to do something that tampers with the environment, you just create an instance of it. Then you can go about your merry way messing with the open cursors, opening new cursors, whatever it is you need to do. When the instance is destroyed (either explicitly or by letting it's variable fall out of scope), any cursors that were not previously opened are closed and the record pointer, filter, index order and alias are restored for any cursors that were previously open. 

The only potential gotcha that I'm aware of is it doesn't handle temporary cursors if your code closes them, but that hasn't been an issue for me so far. 

Give it a try. 

Clean Bill of Health

I'm back home after my surgery. For the millions of readers out there who may not have been privy to the minute details of my health, let me summarize what's transpired. Back in March I had a tummy ache that persisted long enough for me to visit the ER. It turned out that I had diverticulitis and I ended up being hospitalized for 5 nights. Due to the outstanding healthcare I received from St. Vincent's Medical Center and the overwhelming support my family and I received from our friends and family the infection cleared up and I was able to avoid emergency surgery and was discharged. My hospital stay included 4 days of nothing but intravenous liquids, followed by a delicious diet of broth and jello.

Last week I returned to St. V's to have the bad section of my colon removed. The procedure I had was a Lathroscopic Sigmoid Recession for those that want to know the exact medical terminology. The end result is that my belly now looks likes this, except the bloating is down considerably. 

I'm recovering well. A few things still cause me considerable pain - including laughing, coughing and probably most importantly - pants. I think in another week or so I'll pretty much be back to normal. 

Overall, this has been a tremendously positive experience for me. The love and support I recieved from my friends and family here in Toledo was overwhelming and truly humbling. I've always felt tremendously blessed to be a Feltman and marrying into the Taylor-Hass family has really just made me even more blessed. The shawl in the picture was knitted for me by the Prayer Shawl Ministry at our church, Saint Martin de Porres and I was really blown away to receive it. We have a lot of people with much worse conditions than mine and I was really, really touched that they took the time to knit a shawl for me. An unexpected number of people took time out to visit, send cards and call with their well wishes also. I guess you never really know how much it means for someone to say they're praying for you or express their concern until you really need it. When you're sick, little things really do mean a lot.

So I'd like to take this opportunity to thank everyone for looking out for me, particularly my wife and children, my parents and in-laws, brother and sister, all of my friends on Twitter,  Aunt Marcia and Uncle Don and their wonderful daughters, Uncle Toby, my friend Scott, the Bumpus Clan, everyone at St. Martin de Porres and everyone else that had me in their thoughts and prayers. Your love and support really made this an overall positive experience for. Thank you all so much. It's really a great honor to know I am loved and cared for by so many. 

Going forward, I basically have to maintain a healthy diet. The other bright side of this is I've lost 23 lbs and since I was about at my all time heaviest when this happened, that's a real plus. I was planning on getting down to 200 lbs by August 22nd and now I only have 15 lbs to go. I'm sure there are better diet plans out there, but this one has worked great for me. With any luck I'll have a relapse after the 4th of July and I'll make it with basically no effort. :)

My energy level is still pretty low, but mentally I'm recharged and starting to get back into the swing of things. For my Fox friends in particular - who really rock and helped to keep Toni's spirits up tremendously -  I plan on paying it forward with some long overdue blog posts, some kick ass new features in VFE and rockin' sessions at SW Fox 2009. Look for the old, enthusiastic Mike of the early 90's to come out and dazzle you with some technical wizardry, self-depracating humor and of course - frantic pacing! Maybe I'll dust off the old Foundation Read sessions - those use to be real show stoppers. Hmmm, do I have enough time to regrow the mullet for SW Fox? I figure if I do really, really well, I can move up to 2nd to last in overall speaker ranking!

Again, thanks to everyone. You're all in my thoughts and prayers and you can count on me being there for you if you ever find yourself in a time of need.