6

The LA Fox Developer Newsletter
March 1999
Reapplying Default Values to
Recycled Records
Microsoft Knowledge Base Article Qi 68521
In Visual FoxPro, the DELETE command does not delete a
record physically; rather, it only marks the record for deletion.
Using the RECALL command unmarks the deleted record. In
order to physically delete a record from a table in Visual
FoxPro, use the PACK command. Using PACK requires the
table to be opened exclusively. In a multi-user environment, it
may be difficult to obtain exclusive use of the file for packing. To
work around this problem, you can recycle deleted records by
using the technique illustrated below.

This article assumes you have an existing database and certain
fields have default values in the table.

The following code snippet does the following:
Looks for a deleted record.
Retrieves the default values from the table in the database.
Re-uses the first deleted record found.
If no deleted records are found, a new record is appended

LOCAL IcDeleted, dExpr, ncount, a_field(1)
IcDeleted = set(”DELETED”)
SET DELETED OFF
Looks for deleted record in the table
LOCATE FOR DELETED()
IF FOUNDO
*
bring it back to life and blank its fields
RECALL
*
blank out the contain of the deleted record
BLANK
*
Retrieve all default values from the base table.
FOR nCount = I to AFIELDS(a_field)
dExpr = BGetProp(CursorGetProp(”SourceName”)+;
“.“ + a_field[nCount, 1], “Field”,;
“DefaultValue”)
*
if there is a default value, use it
IF not Empty(dExpr)
REPLACE (a_field(nCount, 1]) WITH;
EVAL(dExpr)
ENDIF
ENDFOR
ELSE
APPEND BLANK
ENDIF

SET DELETED &lcDeleted

In order to retrieve default values from the database, the data-
base needs to be open at all times. If the database is not open,
an error occurs.

NOTE:
Unused space in memo files will not be recycled. To
recover unused space in memo files, you must issue a PACK
MEMO command (which requires that the table be opened
EXCLUSIVEly).

[Ed. Note: MS Knowledge Base articles may be reprinted
freely. If you have a favorite or interesting one, forward it along
to me at brlee@mesllc.com.]
Out and About (Con’t from page 3)
membership year when everyone that hasn’t paid their member-
ship fees will stop receiving the newletter. So if you get a call
from one of your fellow members, inquiring about the newsletter,
tell them that all they need to do is to pay their dues and
everything will be alright. <g> You can remind them that
Standard membership is $48 and Premium membership is
$120. Standard membership gets you everything it did in the
past. Premium membership allows you to get the newsletter in
advance (electronically), a ZIP file of all the past newsletter
articles in .DOC format (almost 5 year’s worth. ..as long as I’ve
been the editor). This month also marks the inception of
(Con’t, page 7)

“We get letters” Dept...
POWERHELP FoxPro Edition
Now Shipping!
Hello. My name is Glenn Mason, and I’d like to share a unique
opportunity for you to try a new, exciting product for Visual
FoxPro and FPW 2.x. POWERHELP is an automated Help
writer for FoxPro that creates context-sensitive, on-line Help
systems and printed User Manuals for all of your FoxPro apps
in minutes. PowerHelp can create Windows 3.x Wlnhelp,
Windows 95/98/NT Winhelp, NEW HTML Help and printed
manuals in Word format. To learn more check out
www.micromason.com. Currently I am trying to forge marketing
strategies that broaden exposure to our new product. In light of
this, we are currently offering a 25% discount to all FoxPro User
Group officers and $25 discounts to ALL members of your
FoxPro user groups. We only ask that you display our
PowerHelp User Group/Partnership banner on your web sites.
Please feel free to contact me at any time to order PowerHeip
or sign up for this special offer that will benefit all of your FUG
members. Thank you!

Top 5 Reasons for
C0000005 errors in VFP
From the UT (Universal Thread)
In the Letterman tradition:
Reason #5: MS Alpha-testers were too hung-over from the “We
Made Visual Studio 6!” party to notice it.
Reason #4: A new Fox Team coder is an ex-Ashton/Tate
employee on a suicide mission.
Reason #3: A lousy attempt at what would have been a great
Easter Egg.
Reason #2: Secret MS memo reveals that VFP has to be
stopped!
And, finally....
Reason #1: Because VFP developers needed *something* to
moan about in the new release!

John S. Koziol
MCP - Visual FoxPro

6