5.9 A Simple Form

In the following sections, we will create a mailing list system for a company that sends out magazines. The computer keeps track of the names and addresses of subscribers that are receiving magazines and which magazines they receive.

This is the demonstration application (the demo database) that is distributed with C/Base. If you want to try creating the formfiles on your system as you read the following sections, you can access the demo database from toolkit with the command:

c:\> toolkit demo

If you prefer to access the demo database from the shell, enter the following command to set the default database:

c:\> set DBASE=demo

In the following sections you will create logical formfiles named mysub, mymag, and myscript. If these formfiles already exist, you may remove them with the M2 - Remove Data Entry Form choice in the Data Entry Forms menu in toolkit, or with the command:

c:\> formrm formfile

First, we create a form for maintaining a list of subscriber names and addresses. Figure 5 below describes the fields of the subscriber RMSfile, sub. Each subscriber has a code which uniquely identifies that subscriber. Also included in the RMSfile is the subscriber's name, address, and other information.

subscriber, 16 character string, key

subscriber code

name, 36 character string

subscriber name

address, two 36 character strings

two lines of street address

city, 32 character string

subscriber city

state, 8 character string

subscriber state

zip, 12 character string

subscriber zip code

Figure 5

To create a formfile containing a data entry form for the subscriber RMSfile, enter the command:

c:\> formedit -c mysub

Alternately, select D1 - Create a Data Entry Form from the Data Entry Forms Menu in toolkit.

The first form displayed is a blank Form Description screen. Press the ADD <F6> key to add a new Form Description. It should be filled in as shown on the screen below.

gifs/00000001.gif

The exact form name used is not important, but the Form Name field and the Next Form Name field should contain the same name. Then, whenever the operator presses the NEXTFORM <F7> key, form will redisplay the same form. Note that the Beginning Form field is set to yes; this form should be the first displayed by form. The Unique Records field is also set to yes, and thus each record entered must have a unique subscriber code. The Repeating Form field is also set to yes. This causes form to clear just the field contents between each data record. This is included for the operator's convenience. If this field were instead set to no, form would erase the entire screen and redisplay the same form after the operator stores the record.

After you store the Form Description screen, formdef clears the screen, and the form itself is ready to be entered. Next, we will enter the data entry fields and background text as shown below.

gifs/00000001.gif

The background text is typed in on the screen where it should appear. Move the cursor to where each part of the background text should start and enter it. To enter a data entry field into the form, position the cursor to where the field should begin, and push the ADD <F6> key.

It would be redundant to show each of the different Field Description forms for the form being built. Instead, only the Field Description form for the first field is shown.

gifs/00000001.gif

The other field descriptions would be similar. You have to choose only whether each field should have input required or not. Figure 9 below lists the other fields on the form. The output is from the pform command.

Contents of formfile sub

Form Name: subscribers

Data File: sub

Beginning form yes Unique records yes

Repeating form no Append form no

Freeze form no Additional form no

Required form no for one record

Next form name: subscribers

gifs/00000001.gif

Line 3, Column 17, Field name: subscriber , Field length 15

Entry Allowed yes Input required yes

In Data File yes Invisible no

Line 3, Column 48, Field name: telephone , Field length 12

Entry Allowed yes Input required no

In Data File yes Invisible no

Line 5, Column 17, Field name: name , Field length 35

Entry Allowed yes Input required yes

In Data File yes Invisible no

Line 7, Column 17, Field name: address[1] , Field length 35

Entry Allowed yes Input required yes

In Data File yes Invisible no

Line 8, Column 17, Field name: address[2] , Field length 35

Entry Allowed yes Input required no

In Data File yes Invisible no

Line 10, Column 17, Field name: city , Field length 31

Entry Allowed yes Input required yes

In Data File yes Invisible no

Line 12, Column 17, Field name: state , Field length 7

Entry Allowed yes Input required yes

In Data File yes Invisible no

Line 12, Column 41, Field name: zip , Field length 11

Entry Allowed yes Input required yes

In Data File yes Invisible no

Figure 9

After you create the formfile, enter the following command to test your formfile:

c:\> form -qfuad mysub

Alternatively, in toolkit you can select D3 - Test a Data Entry Form in the Data Entry Forms Menu.

You can now add, delete, query, and update subscribers in the subscriber RMSfile named sub.