4.29.2010
This blog has moved
This blog is now located at http://rickborup.blogspot.com/.
You will be automatically redirected in 30 seconds, or you may click here.
For feed subscribers, please update your feed subscriptions to
http://rickborup.blogspot.com/feeds/posts/default.
3.20.2010
Conditional TRANSFORMs in VFP
TRANSFORM(eExpression, [cFormatCodes])
eExpression is the value, or an expression that returns the value, to be TRANSFORM'ed. The optional format codes enable additional control over the resulting string. The available format codes are enumerated and explained in the TRANSFORM() Function topic in the VFP Help file.
The @R format code is a little different that the others. It tells VFP to read a format mask and use it to format the resulting string. This is useful for formatting character or numeric data that may require a specific format, such as currency values, social security and FEIN numbers, and telephone numbers. The following example shows how to use TRANSFORM with @R and a format mask to format a U.S. phone number with area code in the conventional manner.
TRANSFORM( "2175551212", "@R (999) 999-9999") && Result is "(217) 555-1212"
(Note that the space after @R is required to achieve the expected result.)
Phone numbers, however, are a good example of where you might want to use a different format mask in different situations. Assume a table with phone numbers stored in a character field. Depending on the data and how it was entered, the table might contain U.S. phone numbers with area codes, U.S. phone numbers without area codes, and international phone numbers. Assume the phone number column is wide enough to accommodate any of the anticipated possibilities.
CREATE TABLE myTable ( cPhoneNbr C(20))A format mask of "@R (999) 999-9999" works for the first value but returns garbled results for the other two. For the U.S. phone number without an area code, a format mask showing a blank area code would be more appropriate, while for the international number it may be best to use no format mask at all and just display the number the way it was entered.
INSERT INTO myTable ( cPhoneNbr) VALUES ( "2175551212") && U.S. phone nbr w/ area code
INSERT INTO myTable ( cPhoneNbr) VALUES ( "5551212") && U.S. phone nbr w/out area code
INSERT INTO myTable ( cPhoneNbr) VALUES ( "+46 704123456") && International phone nbr
Assume the length of the unformatted phone number can be used to determine what type of phone number it is. Then in a method or procedure code a conditional statement like IF or CASE can be used to determine which format mask to apply.
lcPhoneNbr = ALLTRIM( myTable.cPhoneNbr)
DO CASE
CASE LEN( lcPhoneNbr) = 10
lcResult = TRANSFORM( lcPhoneNbr, "@R (999) 999-9999")
CASE LEN( lcPhoneNbr) = 7
lcResult = TRANSFORM( lcPhoneNbr, "@R ( ) 999-9999")
OTHERWISE
lcResult = lcPhoneNbr
ENDCASE
The problem with this is that it won't work in a report field, where a single expression is needed.
Fortunately, VFP enables conditional formatting within a single TRANSFORM by using a function for [cFormatCodes]. Leaving out the "myTable." prefix for brevity, the following can be used as a report field expression to get the desired result:
TRANSFORM( cPhoneNbr, ;
ICASE( LEN( ALLTRIM( cPhoneNbr)) = 10, "@R (999) 999-9999", ;
LEN( ALLTRIM( cPhoneNbr)) = 7, "@R ( ) 999-9999", ;
""))
If that seems a little long to stuff into an expression field, and it could get worse if there are more alternatives, the conditional code can be factored out to a UDF or to a method on some object and called from within the report field expression:
TRANSFORM( myTable.cPhoneNbr, GetPhoneNbrMask( myTable.cPhoneNbr))
The ability to use a function in place of a static format code enables us to extend the power of VFP by performing conditional formatting within a single TRANSFORM function.
Tags: Visual FoxPro, VFP
10.28.2009
Password Agent 2.6
Tags: Password Agent, Moon Software, Southwest Fox
6.06.2009
Southwest Fox 2009 - Don't Miss It!
Tags: Southwest Fox, SWFox, FoxPro
SWFox 2008 Session White Papers Published
Update [Sunday, 07-Jun-2009]: I posted the wrong links to these papers yesterday. The links are now correct.
Tags: Southwest Fox, SWFox, FoxPro
4.28.2009
Restore Open Tabs in Internet Explorer 8
Tags: Internet Explorer 8, IE8
4.13.2009
VFP Task Pane Tip

2.20.2009
SWFox 2007 session white papers published
Unless the year gets away from me again, look for the papers from my Southwest Fox 2008 sessions to be published sometime in late April.
12.03.2008
Southwest Fox Session Evals
Today I finally found time to carefully read the evals from my sessions at Southwest Fox. Thanks to all of you who attended one of my sessions and took the time to comment. To those who had good things to say, thanks for the kind words. To those who suggested ways in which I can improve, I genuinely appreciate your suggestions.
A Speakers' Dilemma
One thing I always wrestle with is how much content to try to fit into the allotted time. Like most speakers, I try to provide maximum content and hence maximum value in all my presentations. Sometimes, however, that comes at the expense of not leaving enough time for questions. Several people commented that this was a problem with both my sessions at Southwest Fox this year, and I want to let you know that I hear you.
I generally ask that questions be held until the end of the session. The reason for this is to ensure there's enough time to cover all the material. You might be surprised at how easily taking the time to answer just a handful of questions during a session can derail a carefully timed presentation. However, I realize that if I ask for questions to be deferred until the end, I'm also making an implicit agreement with the audience to leave enough time for those questions.
So, here's my main take-away from this year's evals: I need to be sure to leave time for Q & A even if it means trimming the session content a bit. As I think about it, that's a better formula for maximizing the value of a session anyway, because all of us (speakers included) learn from each other's questions. Besides, the white paper provides a place to put relevant content that doesn't fit in the verbal presentation.
A Question
I think leaving around five minutes for Q & A at the end of a 75-minute session feels about right. Any less is almost certainly not enough, while significantly more means that much less session content. But that's just my opinion. What do you think?
An Apology
To the person who came up to me at the end of my Friday afternoon session on the FoxPro Foundation Classes: I apologize for putting you off and rushing out of the room. I had come down with some kind of 24-hour bug Thursday evening (and no, not from too much partying - really!). I was feeling pretty rocky all day Friday, and to be honest I wasn't sure I was going to make it through the entire Friday afternoon session. I came pretty close to losing it immediately after I finished speaking, and had to rush out of the room for a couple of minutes. When I got back, you had already left. If you are that person, I hope you will understand, and if you still have a question please e-mail me and I'll be happy to try to answer it.
Tags: Southwest Fox, SWFox, conferences, presentations
11.18.2008
ZoneAlarm Pro for free
Tags: ZoneAlarm
9.03.2008
7.09.2008
MS Patch 951748 and Zone Alarm Issue
Side note: I posted this on Twitter late last night when I first ran into it and found the answer. After using Twitter for a couple of months, that seems to be where I turn first to post this kind of thing because it's easy to get the word out quickly. I'm still blogging, but some stuff now goes on Twitter first.
5.16.2008
PowerDesk Pro 7
PowerDesk has long been my favorite desktop file manager and replacement for Windows Explorer. But version 6, which was released in 2005 and last updated in 2006, has been feeling a little long in the tooth recently. Although clicking on its EasyUpdate link (on the Help menu) still says "You have the latest software version. No update is necessary.", I discovered today that the PowerDesk home page is now featuring PowerDesk Pro 7.
I haven't received any e-mail announcement of the new version yet, and I can't find any indication of upgrade pricing for licensed users of version 6 on their website, so this might be brand new. In any case, it's good to know this fine product is getting another update.
Tags: PowerDesk
Minimalist error message

"Just keep on movin', folks. Nothing to see here. Really, this is all you need to know. Anything else would only confuse you."
This is a real error dialog from a real app. Not a beta release, either. And no, I didn't capture the screenshot before the dialog was fully rendered - this is the whole thing. (I did add the caption, though.)
So we're not only left to wonder what the error was, but also what application had the error in the first place. Huh.
4.30.2008
Beyond Compare v3 beta
There's a lot of information about the new version on Scooter Software website. Check out what's coming in the screenshot gallery and the list of new features. Or if you want to you can actually download the beta and explore it for yourself.
Tags: Beyond Compare, Scooter Software
4.10.2008
Tweeting
Tags: Twitter
3.09.2008
Cool tool from Frank Perez
Of all the tools in my developer's toolkit, the one I use most often (besides Visual FoxPro, of course) is probably Beyond Compare from Scooter Software. Besides its ability to compare and synchronize the contents of two different directories, Beyond Compare has a file comparison utility that lets you view two files side-by-side with their differences highlighted. This capability is extremely useful for analyzing the differences between two versions of text-based files such as Visual FoxPro PRG files.
While there are Beyond Compare plug-ins to facilitate comparisons between other, non-text based file types such as binary (hex) and image files, until now there was nothing designed to work specifically with non-text based Visual FoxPro files such as DBF, CDX, SCX, VCX, and so on.
Frank's new VFP file viewer rule and VFP2TEXT tool fill this void and enable you to use Beyond Compare's file comparison feature with Visual FoxPro's non-text based file types. Get the full story and the download link straight from the source on Frank's blog post. Nice job, Frank, and thanks for the "cool tool".
Tags: Visual Foxpro, VFP, Beyond Compare, Frank Perez, Paul Mrozowski
InstallShield Sold Again
The deal was announced on Feb. 14, 2008, almost a month ago. I'm a little surprised that, with one exception, this hasn't generated any chatter among the developers I know or on the blogs I read regularly. The only public mention of this that I'm aware of was Stefan Krüger's post on his InstallSite Blog the day after the official annoucement was made public.
Here are the official announcements from Macrovision and from TCB.
Tags: InstallShield, Macrovision
2.27.2008
New goodies from Sysinternals
Tags: Greg's Cool Thing of the Day, Sysinternals