We extend the Sales conduit so that our shell from the previous chapter also supports “Desktop overwrites handheld” and “Handheld overwrites desktop.” We are postponing syncing until Chapter 13.
For our conduit, we’ve got to define what it means to do each of these types of overwriting. Here’s the logic that we think makes sense for the Sales application:
The products database and the customers database are completely overwritten from the desktop; nothing happens to the orders database.
The products are ignored (since they can’t have changed on the handheld). The customers and orders databases are copied to the desktop. Any archived customers are appended to a separate file; deleted customers are removed from the handheld.
We store data on the desktop as tab-delimited text files.
The customers will be stored in a file named
Customers.txt in the user’s directory
within the Sales conduit directory. Each line in the file is of the
The orders will be stored in a file named
Orders.txt in the same directory. Each order is
ORDER Customer ID quantity<tab>Product ID quantity<tab>Product ID ... quantity<tab>Product ID
Orders follow one another in the file.
The products are stored in a
and start with the categories, followed by the products:
Name of Category 0 Name of Category 1 ... Name of last ...