Wiki Home

VFP Last Copy Idiom

Namespace: WIN_COM_API

VFP's last copy idiom

VFP possesses the following cool idiom: If a .PRG contains two or more class definitions with the same name, or two or more functions with the same name, VFP compiles only the last one. This means if you are changing a class or function, you can copy and paste it to the bottom of the file, and make your changes to the copy.

In other words, the following program prints Shocked.

  ? "Sharp"

  ? "Shocked"

This is a great way to preserve Framework code while, at the same time, maintaining your own modifications.

I'd call the behavior happenstance, Steve...and I'd sure like an official Fox Team blessing before I relied in it. That being said, it is very cool. --- John Koziol
It's been thus since the FoxBase days, John-- Steven Black

I sure hope I never come across this - I am sure it will cost me some time before I figure out that the first function I find isn't the one that is executing. and no, I am not going to double check to make sure that the function I am looking at is the last one. Grrr... ?CFK

This technique is used by Doug Hennig's error handling routine to fix the RI cascading delete trigger bug. Check out and read the white paper on error handling.
Category Learning VFP
( Topic last updated: 2010.12.12 03:08:18 AM )