Saving your data as a CSV file
Saving your text database as a CSV file.
What should the OnClick event handler of FileSave do?
- Clear the listbox.
- Make a record-string out of each row of the stringgrid and
add it to the listbox. For keeping with good modular coding practices,
we'll delegate these two tasks to a separate routine, that we named AddRecToList.
- Save the listbox contents to a file, with the same name as
from which it was loaded initially.
What should AddRecToList do with the row of a
- Start with an empty record-string.
- Start at column number 0 of the current row.
- Get the contents of the current cell into a variable for
the field value.
- If the field contains a space or a comma, put double quotes
- Add the field to the record-string.
- If more fields, then add a comma to the record-string
- Increment the column-counter.
- If more fields, repeat from step (3).
- When done with all the fields, add the record-string to the