Tod means Fox

Business Intelligence, Data Warehousing, SQL, Visual FoxPro.

Archive for August, 2007


Published August 18th, 2007

FoxShow 41 FoxForward (and beyond)!

I wanted to take a moment to draw your attention to an interview on Andrew MacNeill’s FoxShow regarding FoxForward 2007. It’s a few months old, but will certainly give you an idea on what to expect if you head out.

Here is the link to the audio (mp3).

If you want to know more about the conference, or would like to hear Andrew or Kevin’s voice, check it out!

Published August 17th, 2007

FoxForward is Only a Few Weeks Away

As most of you know, FoxForward begins September 7th, 2007 in Alpharetta GA. The speakers list has long been set and the schedule of talks is now online. This is looking like it is going to be a great event! There are sessions on FoxUnit (see Alan Stevens blog), Cusror Adapters (see David Stevenson’s blog), Web Connection (presented by Stein Goering), n-tier development (Michael Babcock), and custom report controls with Sedna (Bo Durban). I will be speaking on Data Warehousing — giving you an overview of what it takes to build a data warehouse (using VFP). For those of you looking to use VFP with MySQL or MapPoint, then there are sessions for you. I am particularly interested in John Koziol’s talk on Visual Analysis. Also, Brian Marquis‘ presentation is geared for Foxpro developers looking to add Web 2.0 technologies into their applications (”Fox Trails” not “VFP on Rails”!). And there’s much, much more.

FoxForward 2007 - Alpharetta, GA USA - September 7th-9th

If you can get to the Atlanta area, please make it out! It’s right here.

For more updates, check out Kevin’s blog or visit the FoxForward official website!

Published August 14th, 2007

Ezelsbruggen

Or as I like to say, my “easel’s broken”, because it helps me remember how to pronounce it. Which is funny because ezelsbruggen, in dutch (and German too, I think), translates into “donkey bridges” (according to the Internet and my wife). A donkey bridge is a memory technique for creating visual bridges between disparate words. In English, the translation is “memory aid”, or “mnemonic”.

Whether you have a rat in separate, your princiPAL is your PAL, or your committee does nothing but mutter mutter, talk talk, and eat eat, donkey bridges are quite handy. They help you remember little bits and pieces of information, like the form instantiation order in FoxPro (the lovely Lisa G.). Oftentimes donkey bridges are illogical, arbitrary, and downright silly — but they always seem to work. Who is this Lisa G. anyway?

So, here is a list of some of the mnemonics — Ezelsbruggen — that I have learned over the years. If you have any fun or interesting ones, please share!

  • LISA G.
    Load, Init, Show, Activate, GotFocus
  • Lucky Cows Drink Milk
    The order of Roman numerals (ascending): LCDM
  • Please Excuse My Dear Aunt Sally
    Parentheses, Exponents, Multiplication, Division, Addition, Subtraction.
  • My Very Educated Mother Just Served Us Nachos
    There are only eight planets now! Sad… but true.
  • Better Be Right Or Your Great Big Van Goes West
    Ohms value for the color bands of resistors (Black, brown, red, orange, yellow, green, blue, violet, gray, white).
  • Silly People Drive Fast
    Spectroscopic notation, after F, the rest is alphabetic

So here I am in a canoe in the middle of the Atlantic Ocean, drinking the salt water out of a coffee filter. Smoke from my hibachi is getting in my eyes as my veggie burgers begin to burn. Although I’m ankle deep in plums, I manage to toss Ben and Jerry overboard so they can fix the motor, which is nothing more than a dust buster turned from suck to blow.

That, my friends, was yesterday’s shopping list. Poland Springs, coffee filters, veggie burgers, plums, ice cream, and a new hand vacuum. If I don’t create an absolutely absurd story, I’m liable to forget something without a list.

Method of Loki

Another great way to remember sequences and lists is employing the Method of Loki. In its most basic form, you simply find a location you are familiar with in your head (your bedroom, office, kitchen, etc), and begin placing things inside the room. It’s a method many use for giving paperless speeches or for remembering meeting agendas. For example, in my office, I may see the head of the research department typing away at my computer, a spinning globe just off to her right, and a bowing shelf of paper documents within arm’s reach. This will remind me to discuss the new research project, segue into our International strategy, and finally end by discussing a much needed content management solution.

These and other such techniques for remembering items, spellings, sequences, etc, have been a big help for me. In the health care industry, I’m often required to remember many acronyms, processes, and procedures that are quite foreign (I have no medical background whatsoever — unless you count years of watching ER). The same might be true for you as well.

Now if you’ll excuse me, I need to see the quill from behind the tall man who’s sitting on a beanbag chair fiddling with a rubix cube.

Published August 13th, 2007

Cast(), Str(), or Transform() — Choose wisely!

It’s been said that if you can’t do something 3 different ways in FoxPro, then it can’t be done. I’m not sure where this phrase originated, but it’s stuck with me over the years. With options though, come responsibility. Yes, you can often solve a problem using several methods, but your job as a developer is to pick the most reliable and best performing of the options available. This could mean making a choice to use the REPLACE statement instead of SQL-UPDATE, MEMLINES/MLINE over ALINES, or TRANSFORM instead of STR.

Trimmed conversion of number n

For example, run this code from a program file a few times over. They are functionally equivalent, producing a trimmed string conversion of a number n:

clear
nSec = SECONDS()
FOR n = 1 TO 100000
  lc = ALLTRIM(STR(n))
NEXT
? "Run 1 with STR(): "
?? SECONDS() - nSec
 
nSec = SECONDS()
FOR n = 1 TO 100000
  lc = TRANSFORM(n)
NEXT
? "Run 2 with TRANSFORM(): "
?? SECONDS() - nSec
 
nSec = SECONDS()
FOR n = 1 TO 100000
  lc = CAST(n as Varchar(10))
NEXT
? "Run 3 with CAST: "
?? SECONDS() - nSec

You will notice right away that using CAST is by far the fastest (on average 2.5 times faster than ALLTRIM(STR())). Transform is a little faster than ALLTRIM(STR()) as well (on average 1.3 times faster using 100000 iterations as a test). If you reduce the number of iterations, this ratio reduce until finally ALLTRIM(STR()) begins to outperform TRANSFORM().

CAST is new to VFP9, so it is likely that it hasn’t made its way into a lot of your code — but perhaps some refactoring is in order! Especially in loops with many iterations or in SQL statements.

nLength conversion of number n

In the previous example, I returned a trimmed string of a number n. Consider that you want your numeric transformation to be of a particular size. What’s faster now?:

clear
nSec = SECONDS()
FOR n = 1 TO 1000000
  lc = STR(n,10,2)
NEXT
? "Run 1 with STR(): "
?? SECONDS() - nSec
 
nSec = SECONDS()
FOR n = 1 TO 1000000
  lc  = TRANSFORM(n,"9999999.99")
NEXT
? "Run 2 with TRANSFORM(): "
?? SECONDS() - nSec
 
nSec = SECONDS()
FOR n = 1 TO 1000000
  lc = CAST(n as Character(10))
NEXT
? "Run 3 with CAST: "
?? SECONDS() - nSec

Again, CAST is faster than both STR and TRANSFORM (on average 2.7 times faster). Transform (which surprised me) still outperforms STR() (at 100,000 iterations, the ratio on average was still about 1.3). But take heed! The last example here isn’t functionally equivalent: CAST will left-align the results, while STR and TRANSFORM right-align the results. STR and TRANSFORM will round decimals to the specified amount, CAST will not.

Obviously, there are many things you can do with TRANSFORM that you cannot do with either STR or CAST. In most cases, however, CAST seems to be the way to go. Using ‘Varchar’ in CAST trims your string, using ‘Character’, does not. TRANSFORM automatically produces a TRIMed string as well, unless you specify a format code.

I like the new CAST function in VFP9. I got used to using it while writing code to interact with SQL Server. But I soon found CAST sneaking into my code in various other places — often replacing ALLT(STR()) and TRANSFORM.

Published August 9th, 2007

Marketing for FoxPro

Who said Microsoft doesn’t care?

Published August 7th, 2007

SPS VFPEncryption Update

Sweet Potato Software (SPS) has updated their free and popular vfpencryption71.fll utility. Aside from a bug fix (or two?), they have also added CRC() and CRCFile() functions to produce 16 and 32 bit CRCs for Strings and Files. A few handy record-level functions (HashRecord() and CRCRecord()) have also been added.

Other functions included in vfpencryption71.fll include: ENCRYPT(), DECRYPT(), ENCRYPTFILE(), DECRYPTFILE(), HASH(), and HASHFILE(). Thanks Craig for the update!

Visit Craig’s VFPEncryption page now to download the latest!