11.07.2011

How To: Browse a Mercurial log in Visual FoxPro

If you use Mercurial as your version control system, you know it maintains a log of all repository history. You can view the log with the hg log command or with the TortoiseHg Workbench app.

However, if you’re a Visual FoxPro developer, you might wonder if you can get at the log from VFP. It turns out this is easy to do in two simple steps.

1) From the command prompt, do hg log --style xml > log.xml to send the log output to a file named log.xml.

2) Then, in VFP, do XMLTOCURSOR( "log.xml", "csrHgLog", 512) to create a cursor you can browse and work with in VFP.

This little tip was included in the white paper from my session on VFP Version Control with Mercurial at the 2011 Southwest Fox conference in Gilbert, AZ.

4.20.2011

Updated KB2412171 no longer breaks Gmail

As noted here, the December 2010 KB2412171 update broke Outlook access to Gmail accounts. The KB2412171 patch was updated on January 11, 2011 and from my experience no longer causes this problem.

12.15.2010

Outlook Update KB2412171 Breaks Gmail Account Access

After installing the December batch of updates from Microsoft, Outlook 2007 on my Windows Vista SP2 machine could not longer access my Gmail account using POP3. The error message was “Task ‘<gmail address> – Receiving’ reported error (0x800CCC18): ‘Your e-mail server rejected your login with Secure Password Authentication (SPA). …’ ” Uninstalling KB2412171solved the problem.

Update: Windows Secrets newsletter references this issue and links to a couple of discussions. http://windowssecrets.com/2010/12/16/07-PC-patches-end-this-year-with-a-bang

KB2412171_ErrorMessage

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.

This blog is moving

This blog is moving, stayed tuned for more details.

3.20.2010

Conditional TRANSFORMs in VFP

Visual FoxPro's TRANSFORM function is a powerful tool for converting an expression into a string. The VFP Help file defines the syntax of the TRANSFORM function this way:

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))
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
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.

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

10.28.2009

Password Agent 2.6

While discussing backup tools in my session on Disaster Recovery and Business Continuity Planning at Southwest Fox 2009, I mentioned that I use a password management program call Password Agent from Moon Software. While probably less well known than some of its competitors, I've used this particular app for several years and have always found it to be reliable and easy to use. The only caveat was that it had not been updated in quite some time, but by coincidence a new version was just released yesterday. Among other changes this release is listed as compatible with Windows 7. If you're interested in a good password management tool, check out Password Agent 2.6 at www.moonsoftware.com/pwagent.asp.

Tags: , ,

6.06.2009

Southwest Fox 2009 - Don't Miss It!

Hard to believe, but it's only a little over four months until Southwest Fox 2009, which will be held October 15-18, 2009 at the beautiful Arizona Golf Resort and Conference Center in Mesa, Arizona. Start making your plans now, because conference organizers Rick Schummer, Tamar Granor, and Doug Hennig have once again put together a great selection of speakers and topics for a conference that is not to be missed. I hope to see you all there!

Tags: , ,

SWFox 2008 Session White Papers Published

My session white papers from Southwest Fox 2008, Hidden Treasures: The FoxPro Foundation Classes and Automating QuickBooks with QODBC, are now available for download from the FoxPro Developers page of my website.

Update [Sunday, 07-Jun-2009]: I posted the wrong links to these papers yesterday. The links are now correct.

Tags: , ,