Tricks with the delete marker

By Richard Mullins NICAR/Missouri School of Journalism

When we process and scan paper records and lists, we often use a sort of check-mark system to digest the information. It turns out that FoxPro has a feature that can be used as a check mark for a row in a table, without adding any columns to the table.

What FoxPro calls the DELETE TAG is used to mark records to be permanently removed from the table by the PACK command. Unless that command is issued, the tag has no effect, so you can use it as a marker for all sorts of things.

The marker can be set row by row, by clicking the box at the very left of the table display, or it can be set by a command typed in the command window, with limits on the scope of the command specified by logical conditions. You can browse or select records based on this marker. You can remove the markers manually and individually, or by logical condition, you can remove them all.

Here is an example. You have a table with a column called "name." The problem is that it contains both individual and business names, and you want to untangle this by marking the business names.

You make a guess that business names will have certain words and characters in them that wouldn't typically be found in an individual name. You can test this theory by setting the delete tag on all the rows that have these. Then you browse only the marked records in the table and remove the marks from records that really are individuals. As you remove the marks, they disappear from the browse window, (not the table) leaving only the rows still to be examined.

Several commands in FoxPro, such as replace, delete, and browse, can have a logical condition specified to limit the extent of the command. This logical condition works just like the WHERE clause in SQL, except in FoxPro the word FOR introduces the condition.

If you haven't used the $ before, it creates a logical, or true/false test on an expression, just like the equal sign does in State = "WY"

An expression using the $ roughly translates to: "Is String1 found anywhere within String2?"

* set delete marker for names * that contain ampersands, * and business suffixes: delete for "Inc." $ Name delete for "Co." $ Name delete for "&" $ Name * now browse just the delete-flagged records browse for deleted

The deleted() function gives the answer true or false for each record in the table, depending on whether the delete tag is set.

When you browse through the records, you might find a row where the name column contains, "Smith, Mr. & Mrs. William." You would remove the delete tag for this record, and it would disappear from the browse window.

If you have to start over, remove the delete tag on some or all of the records:

remove delete tag for all records: recall all remove tag for some records: recall for "&" $ Name

Richard Mullins can be reached at (573) 882-2127, or send e-mail to richard@nicar.org