Welcome to the CSIG, a Special Interest Group of the ACGNJ. The subject for this month is a discussion about the "State Method" of designing or coding programs in C++. A utility will be created using this concept for converting a general text file into a "tab separated data file" suitable for importing into a MySQL database. It uses the latest C++ compiler in Microsoft's Visual Studio 2005.
Even the smallest of programs can benefit from the STATE METHOD. It is simply a way of looking at a problem and dividing it into smaller and smaller parts until each part is in its simplest form.
As some of you may know, I am the webmaster for a Bible website that shows many Bibles. It was requested that I add the Douday Rheims version to the database. I had a PDF file which was 1500 pages long. Adobe lets you write a PDF to a TXT file which becomes about 100,000 lines. The source file consisted of multi-line paragraphs for each verse with a page footer containing the Book and Chapter. In the target database, a record consists of four (4) fields: Book, Chapter, Verse Number, and Verse Text. The MySQL database accepts for input a single tab delimited line for each record. The problem was to convert the data from one form to the other form. Thus there would be over 100, 000 conversions.
The problem was defined in terms of a STATE DIAGRAM. Using VS2005 in text mode I then mapped the State Diagram into C++ code to accomplish the conversion. By the way, the running time of the program is about 5 seconds.