PART II.
SHORTENING THE PROGRAMMING CYCLE
by Wilson Ng

A programming cycle in software development may be explained simply as
follows:  Systems analysis and design, programming, testing, documentation,
then installation.  Obviously, it could be a lot more complicated than
above, but suppose we focus our attention on the
analysis-programming-documentation stage.  This can be done either by just
one person, or maybe a group of persons who do solely the analysis, and
another group doing mainly the programming.  However, whether you go by solo
or by team, some parts could be automated or standardized to make the 
task much simpler.

There was a time when the analysts would write the database file
specification,  the programmers would make the code to create the files, and
the writers had to write the database documentation all separately.  In
the preceeding example, we demonstrated how it is possible that upon
creation of the database files itself, the user could automatically use
a utility which would make technical and user documentation much easier.   
Now, with the following utility,  we are going to demonstrate another
utility which can again add to the convenience in making programs.  Since we
now have a standardized way in presenting the data structures of the file,
we could make a utility which would automatically read such specifications
and create the necessary database files when we need it.   

The program was written to conform so that it could read the output
of the 2USERMAN.prg and 2TECHDOC.prg programs.  The user may also 
create his own STR file, they may even edit the STR files generated by
the programs, write comments before, in between or after the tables, as long
as the following arrangement conventions are followed:


1.) Each line should end in a Carriage return and may not exceed 136
characters per line.
(Actually, the program may be modified to accommodate as many characters per
line as we desire, as long as it ends in a Carriage return. However, 136
characters may suffice for most applications.)

2.) FILE@,INDEX@, RELA@ and the tilde ~ should not be found anywhere else in
the STR file, except in the table, and they should follow one another. 
After reading the FILE@ reserved word, the program assumes that on the same
line, from the 10th to 18th character is the name of the database file. 
After reading the INDEX@ reserved word, the program assumes that on the same
line, the index tag is on the 10th to 20th position, and the index
expression on the 21st to 75th character.  After the RELA@ reserved word,
the string from the 10th to the 75th position will contain the names of
related files, delimited by commas.  The tilde ~ sign signifies the start of
the field name, and on the same line, the 3rd to the 11th space presumably
contains the field name, the 15th to 20th space contains the type, the 21st
to 26th space contains the width, and the 27th to 32nd space contains the
decimal  definitions. 

3.) Each file may have as many as 20 index tags, and up to 100 field names. 
An STR file may have as many file specifications as desired.

The above may seem to be a lot of rules to remember, but actually you don't
have to remember anything.  Once you have the table set up as produced by
the preceeding programs, it simply means filling up the blanks as to the
filename, index tags and others with just a little bit of precaution.

The program to process the STR file is MakeDbf. Prg.  The program accepts
two parameters, the first is the name of the STR file, and the second is the
name of the database file to be created (whose specifications must be found
in the STR file).  The second parameter may also 'ALLFILES'in which case, the program will create every database found in the specification.

You may test the program by invoking the following from the Foxpro command
box:

    Do makedbf with 'test', 'Allfiles'
                      in which case all three files will be created OR
    Do makedbf with 'test', 'items'
                    in which case only the items file will be created.

Therefore, with just the above program, we now have a simple expedient
wherein the programmer merely runs the program with the STR file, and
without effort, now has all the database files that his program will need.


MAKEDBF WITH A LITTLE MORE INTELLIGENCE

While the above program is generally useful and expedient for the
programmer, a shell or interface had to be made for it to be useful also for
the end-user.   The end-user may create all database files by just invoking
a command in which the response would be to "DO MAKEDBF WITH 'strname.str'
,'allfiles' ".  However, what if the end-user would like to recreate only
one file, and would not like to have all other files recreated because it
already contains valuable records?

The second program (NEW.PRG) solves this problem.  After invoking the
program with "DO NEW with 'TEST' ", we now see the following screen:

       CREATE DATABASES
Databases         Related Files

CUSTOMER          INVOICE
ITEMS
INVOICE



<Tag All>       <Create>
<Tag None>      <Cancel>
    Ctrl+Letter for Options
 

Use the up and down arrow to scroll through the file, and the Enter Key to
select the database files you want to create.  You may also press CTRL-A to
select all.  Note that when you are going through the database, a set of
related files is also shown on the right.  These are the related files that
was defined in the STR file.  The program was designed so that you cannot
create a database file WITHOUT creating the related files.  This is to
prevent referential integrity problems.  For instance, you previously
created a customer file in which you inputted a record with
customer code=0001.  Now, you create an invoice sold to customer code 0001. 
If you delete the customer file, you may be hard put to know who is
customer code 0001 .  Thus, the two are related files, and you either
create both of them or none at all.  You will also note that if any of the
file is already existing, the program will not create the database file, and
will also give you a warning through this window:

   Cannot create files.
   The following files
       exist:

       CUSTOMER
        INVOICE


This feature is also to prevent the user from inadvertently creating new
database files when an old one exists and may contain useful data. Thus, if
the user would like really to create certain new database files, then they
are advised to go out to DOS, delete the unwanted files, and create the new
database files using NEW.

The following two programs, therefore, when put together, may become the one
independent module of any program that will create the necessary database
files.  All the programmer has to do is to make sure that the necessary STR
file is present.  The STR file may be a document file, or it may be a help
file that at the same time, may be used to explain certain aspects of the
program. 

Thus, with the following two utilities, the programming cycle is shortened
now so that the programmer can now do the following things:
1.) Create the necessary database files.
2.) Run the previous two utilities to get what is the beggining of a
    technical and also user's documentation.
3.) Finish up one of the documentation.
4.) Put the NEW.PRG as one of the menus of his programs. When invoked,
    this program will automatically read the STR file that you have
    included, which doubles probably as a help or document file, and
    will give an interface to the user which will allow him to create
    the new database files the user wants.

All without any line of programming!
