The Sales Conduit

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:

Desktop overwrites handheld

The products database and the customers database are completely overwritten from the desktop; nothing happens to the orders database.

Handheld overwrites 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.

Format Used to Store Data on the Desktop

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 form:

                  Customer ID<tab>Name<tab>Address<tab>City<tab>Phone

The orders will be stored in a file named Orders.txt in the same directory. Each order is stored as:

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 Products.txt file and start with the categories, followed by the products:

                  Name of Category 0
                  Name of Category 1
...
Name of last ...

Get Palm Programming: The Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.