by Frank Perez
December 14, 2008
Just the other day I got burned by what I consider a rookie mistake. I was working with a Visual FoxPro application (compiled as a multi-threaded DLL) that records application events to a Visual FoxPro table. To limit the size of the log table, the application re-used records after 500,000 events by updating the oldest record instead of adding new records.
As a general rule I know that I should always use a SELECT command before performing any command or function that processes a work area. For example, in the following sample code the SCATTER command is used to copy data from the current record to an array. Because this command processes the current work area only, I should always select the desired work area first.
* create a cursor with a single record
CREATE CURSOR "CURSOR01" (character1 C(10))
INSERT INTO "CURSOR01" (character1) VALUES("VALUE01")
* create another cursor with a single record
CREATE CURSOR "CURSOR02" (character1 C(10))
INSERT INTO "CURSOR02" (character1) VALUES("VALUE02")
* before calling the SCATTER command, select the work area
SELECT("CURSOR01")
SCATTER NAME loValues
* this should display "VALUE01"
WAIT WINDOW loValues.character1
The exception to this rule is any command that has an IN clause or alias parameter. For example, in the following sample code the REPLACE command can safely be used without selecting the desired work area first.
* create a cursor with a single record
CREATE CURSOR "CURSOR01" (character1 C(10))
INSERT INTO "CURSOR01" (character1) VALUES("VALUE01")
* create another cursor with a single record
CREATE CURSOR "CURSOR02" (character1 C(10))
INSERT INTO "CURSOR02" (character1) VALUES("VALUE02")
* this should display "CURSOR02"
WAIT WINDOW ALIAS()
* change the value in CURSOR01 cursor
REPLACE character1 WITH "NEWVALUE" IN "CURSOR01"
* this should display "NEWVALUE"
WAIT WINDOW CURSOR01.character1
In this particular situation, I was using a LOCATE command without specifically selecting the work area first. In an application compiled into an EXE, executing the LOCATE command when the current work area is blank would cause an Open File Dialog similar to the one below to appear.

However, in an application compiled into a DLL, the LOCATE command appears to be ignored if the current work area is blank. An error does not get thrown and the program simply executes the next line of code. :(
Fortunately, I was able to track down and fix the problem quickly. I'm sure that this is one of those mistakes that we all make at one time or another. I'm just hoping that by blogging about it, I will be less likely to make it again {g}.
1bd804f4-aed7-40f3-9ea6-d5636af47441|0|.0
Keywords:
Filed Under: VFP
by Frank Perez
December 1, 2008
This week I begin my 18 week training program for the Martian Marathon April 5th, 2009. The Martian Marathon is a two day event that begins with a 5K (3.1 miles) and 10K (6.2 miles) on Saturday. The Full Marathon (26.2 miles) and Half Marathon (13.1 miles) take place on Sunday.
For this race I will be using Hal Higdon's Novice Training Program. This program consists of four training runs per week, averaging 15 to 25 miles each week. I don't have any strong reasons why I chose this program over others. I can only say that it worked with my schedule and that it filled the need to have specific goals every week.
Based on my recent Half Marathon results, my goal is to complete this race in 4:45 (hh:mm). That's an average of 10:50 (mm:ss) per mile. Although, since this is my first Full Marathon, just crossing the finish line will be in itself a personal victory.
Links:
Martian Marathon
http://www.martianmarathon.com/
Hal Higdon's Marathon
Training Guide
http://www.halhigdon.com/marathon/Mar00index.htm
1ba4e25a-7725-4c47-9023-365229af90a1|0|.0
Keywords:
Filed Under: RUN