Modify records: Edit
Editing records: modifying the contents of your database.
Improved versions for ParseRecord and SaveRecord, that follow all of
the CSV format rules.
Analysis
The easiest way to change a record, is by editing one or more
fields in the stringgrid of the database. But initially, when a
stringgrid is dropped on a form, it is in "read only" mode. We changed
this by modifying a few properties of the stringgrid (see above).
These changes will result in a few unexpected side effects,
but we'll arrange that in our next lesson ;)
Earlier, we also promised to develop a better ParseRecord
procedure, that fully follows all of the CSV format rules. We also
present an improved AddRecToList procedure to go with it.
The new ParseRecord procedure has a better way of
finding field separators, using the helper function PosFirstSep.
For the rest, it's pretty much the same as the routine in our previous
lesson.
The PosFirstSep helper function returns the
position of the first separator comma in a given record
string. That's not simply the first comma, because we also can have
commas and double quotes inside a field value, as in this example:
"begin, ","""loops"" in Pascal"
The improved AddRecToList procedure is almost like the routine
presented in lesson 16, except that now we also encode double quotes
that are contained in a field values.
|